Java Code Examples for org.eclipse.jface.action.ToolBarManager#update()

The following examples show how to use org.eclipse.jface.action.ToolBarManager#update() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryToolBar.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param parent
 *            parent composite
 * @param viewer
 *            the dataset editor's tree viewer
 * @param style
 */
public HistoryToolBar( Composite parent, TreeViewer viewer, int style )
{
	super( parent, SWT.NONE );
	
	GridLayout toolbarLayout = new GridLayout( );
	toolbarLayout.marginHeight = 0;
	toolbarLayout.verticalSpacing = 0;
	setLayout( toolbarLayout );
	setLayoutData( new GridData( SWT.END, SWT.FILL, false, true ) );
	
	ToolBar toolBar = new ToolBar( this, style);
	toolBar.setLayoutData( new GridData( SWT.END, SWT.FILL, false, true ) );
	toolbarManager = new ToolBarManager( toolBar );

	this.viewer = viewer;
	createHistoryControls( toolBar );
	toolbarManager.update( false );
	
	initAccessible();
}
 
Example 2
Source File: JavaStructureDiffViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setSmartButtonVisible(boolean visible) {
	if (fSmartActionItem == null)
		return;
	Control c= getControl();
	if (c == null || c.isDisposed())
		return;

	fSmartActionItem.setVisible(visible);
	ToolBarManager tbm= CompareViewerPane.getToolBarManager(c.getParent());
	if (tbm != null) {
		tbm.update(true);
		ToolBar tb= tbm.getControl();
		if (!tb.isDisposed())
			tb.getParent().layout(true);
	}
}
 
Example 3
Source File: OverrideMethodDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected CheckboxTreeViewer createTreeViewer(Composite composite) {
	initializeDialogUnits(composite);
	ViewerPane pane= new ViewerPane(composite, SWT.BORDER | SWT.FLAT);
	pane.setText(JavaUIMessages.OverrideMethodDialog_dialog_description);
	CheckboxTreeViewer treeViewer= super.createTreeViewer(pane);
	pane.setContent(treeViewer.getControl());
	GridLayout paneLayout= new GridLayout();
	paneLayout.marginHeight= 0;
	paneLayout.marginWidth= 0;
	paneLayout.numColumns= 1;
	pane.setLayout(paneLayout);
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.widthHint= convertWidthInCharsToPixels(55);
	gd.heightHint= convertHeightInCharsToPixels(15);
	pane.setLayoutData(gd);
	ToolBarManager manager= pane.getToolBarManager();
	manager.add(new OverrideFlatTreeAction()); // create after tree is created
	manager.update(true);
	treeViewer.getTree().setFocus();
	return treeViewer;
}
 
Example 4
Source File: AbstractDocumentationHover.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public IInformationControl doCreateInformationControl(Shell parent)
{
	if (BrowserInformationControl.isAvailable(parent))
	{
		ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
		CustomBrowserInformationControl iControl = new CustomBrowserInformationControl(parent, null, tbm);
		iControl.setBackgroundColor(documentationHover.getBackgroundColor());
		iControl.setForegroundColor(documentationHover.getForegroundColor());
		documentationHover.populateToolbarActions(tbm, iControl);
		tbm.update(true);
		documentationHover.installLinkListener(iControl);
		return iControl;
	}
	else
	{
		return new DefaultInformationControl(parent, true);
	}
}
 
Example 5
Source File: AggregateEditorComposite.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void placeComponents( )
{
	GridLayout layout = new GridLayout( 2, false );
	layout.horizontalSpacing = 2;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout( layout );

	fBtnDropDown = new ToolBar( this, SWT.FLAT );
	ChartUIUtil.addScreenReaderAccessbility( fBtnDropDown, "Aggregation");
	if( fEnabled && this.isEnabled( ) )
	{
		fBtnDropDown.setToolTipText( Messages.getString("AggregateEditorComposite.Tooltip.SetAggregateFunction") ); //$NON-NLS-1$
	}
	ToolBarManager toolManager = new ToolBarManager( fBtnDropDown );
	toolManager.add( new AggregationAction( fEnabled ) );
	toolManager.update( true );
	fBtnDropDown.addMouseListener( this );

	fBtnDropDown.addKeyListener( new KeyAdapter( ) {

		public void keyReleased( KeyEvent e )
		{
			if ( e.keyCode == SWT.ARROW_DOWN )
			{
				toggleDropDown( );
			}
		}
	} );
}
 
Example 6
Source File: TestResultsView.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void contributeToActionBars() {
	final IActionBars bars = getViewSite().getActionBars();
	fillLocalPullDown(bars.getMenuManager());
	fillLocalToolBar(bars.getToolBarManager());
	// a custom tool bar works slightly differently:
	final ToolBarManager m = new ToolBarManager(toolBar);
	fillCustomToolBar(m);
	m.update(true);
}
 
Example 7
Source File: DialogPackageExplorerActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a toolbar manager for a given
 * <code>ViewerPane</code>
 *
 * @param pane the pane to create the help toolbar for
 * @return the created <code>ToolBarManager</code>
 */
public ToolBarManager createLeftToolBar(ViewerPane pane) {
    ToolBar tb= new ToolBar(pane, SWT.FLAT);
    pane.setTopRight(tb);
    ToolBarManager tbm= new ToolBarManager(tb);

    tbm.add(fCreateLinkedSourceFolderAction);
    tbm.add(fCreateSourceFolderAction);
    tbm.add(fResetAllAction);
    tbm.add(new HelpAction());

    tbm.update(true);
    return tbm;
}
 
Example 8
Source File: SearchText.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createActionMenu(Composite composite) {
	ToolBar toolBar = new ToolBar(composite, SWT.NONE);
	ToolBarManager manager = new ToolBarManager(toolBar);
	action = new DropDownAction();
	manager.add(action);
	manager.update(true);
	toolBar.pack();
}
 
Example 9
Source File: NLSStringHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	ToolBarManager tbm= new ToolBarManager(SWT.FLAT);
	NLSHoverControl iControl= new NLSHoverControl(parent, tbm);
	OpenPropertiesFileAction openPropertiesFileAction= new OpenPropertiesFileAction(iControl);
	tbm.add(openPropertiesFileAction);
	tbm.update(true);
	return iControl;
}
 
Example 10
Source File: AbstractAnnotationHover.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Fills the toolbar actions, if a toolbar is available. This
 * is called after the input has been set.
 */
protected void fillToolbar() {
	ToolBarManager toolBarManager= getToolBarManager();
	if (toolBarManager == null)
		return;
	fInput.fillToolBar(toolBarManager, this);
	toolBarManager.update(true);
}
 
Example 11
Source File: AbstractAnnotationHover.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Fills the toolbar actions, if a toolbar is available. This is called
 * after the input has been set.
 */
protected void fillToolbar() {
	ToolBarManager toolBarManager = getToolBarManager();
	if (toolBarManager == null)
		return;
	fInput.fillToolBar(toolBarManager, this);
	toolBarManager.update(true);
}
 
Example 12
Source File: XbaseHoverProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureControl(final IXtextBrowserInformationControl control, ToolBarManager tbm, String font) {
	final BackAction backAction = new BackAction(control);
	backAction.setEnabled(false);
	tbm.add(backAction);
	final ForwardAction forwardAction = new ForwardAction(control);
	tbm.add(forwardAction);
	forwardAction.setEnabled(false);
	final ShowInJavadocViewAction showInJavadocViewAction = new ShowInJavadocViewAction(control);
	tbm.add(showInJavadocViewAction);
	showInJavadocViewAction.setEnabled(false);
	final OpenDeclarationAction openDeclarationAction = new OpenDeclarationAction(control);
	tbm.add(openDeclarationAction);
	IInputChangedListener inputChangeListener = new IInputChangedListener() {
		@Override
		public void inputChanged(Object newInput) {
			backAction.update();
			forwardAction.update();
			if (newInput != null && newInput instanceof XbaseInformationControlInput) {
				openDeclarationAction.setEnabled(true);
				if (((XtextBrowserInformationControlInput) newInput).getInputElement() != null) {
					showInJavadocViewAction.setEnabled(true);
				}
			}
		}
	};
	control.addInputChangeListener(inputChangeListener);
	tbm.update(true);
	addLinkListener(control);
}
 
Example 13
Source File: DefaultEObjectHoverProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.3
 */
protected void configureControl(final IXtextBrowserInformationControl control, ToolBarManager tbm, String font){
		final BackAction backAction = new BackAction(control);
		backAction.setEnabled(false);
		tbm.add(backAction);
		final ForwardAction forwardAction = new ForwardAction(control);
		tbm.add(forwardAction);
		forwardAction.setEnabled(false);

		//				final ShowInJavadocViewAction showInJavadocViewAction= new ShowInJavadocViewAction(iControl);
		//				tbm.add(showInJavadocViewAction);
		final OpenDeclarationAction openDeclarationAction = new OpenDeclarationAction(control);
		tbm.add(openDeclarationAction);

		//				final SimpleSelectionProvider selectionProvider= new SimpleSelectionProvider();

		IInputChangedListener inputChangeListener = new IInputChangedListener() {
			@Override
			public void inputChanged(Object newInput) {
				backAction.update();
				forwardAction.update();
		
				if (newInput == null) {
					//							selectionProvider.setSelection(new StructuredSelection());
				} else if (newInput instanceof XtextBrowserInformationControlInput) {
					//							XtextBrowserInformationControlInput input= (XtextBrowserInformationControlInput) newInput;
					//							Object inputElement = input.getInputElement();
					//							selectionProvider.setSelection(new StructuredSelection(inputElement));
					//							boolean isJavaElementInput= inputElement instanceof IJavaElement;
					//							showInJavadocViewAction.setEnabled(isJavaElementInput);
					openDeclarationAction.setEnabled(true);
				}
			}
		};
		control.addInputChangeListener(inputChangeListener);
		tbm.update(true);
		addLinkListener(control);
}
 
Example 14
Source File: AnnotationWithQuickFixesHover.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Fills the toolbar actions, if a toolbar is available. This
 * is called after the input has been set.
 */
protected void fillToolbar() {
	ToolBarManager toolBarManager= getToolBarManager();
	if (toolBarManager == null)
		return;
	fInput.fillToolBar(toolBarManager, this);
	toolBarManager.update(true);
}
 
Example 15
Source File: CustomCSSHelpHoverProvider.java    From solidity-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected void configureControl(
		IXtextBrowserInformationControl control, ToolBarManager tbm,
		String font) {
	OpenInHelpAction openHelpAction = new OpenInHelpAction();
	openHelpAction.setEnabled(true);
	tbm.add(openHelpAction);
	tbm.update(true);
}
 
Example 16
Source File: BreadcrumbItemDropDown.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
public BreadcrumbItemDropDown(BreadcrumbItem parent, Composite composite) {
  fParent = parent;
  fParentComposite = composite;
  fMenuIsShown = false;
  fEnabled = true;

  fToolBar = new ToolBar(composite, SWT.FLAT);
  fToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
  // SWTUtil.setAccessibilityText(
  // fToolBar,
  // BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip);
  ToolBarManager manager = new ToolBarManager(fToolBar);

  final Action showDropDownMenuAction = new Action(null, SWT.NONE) {
    public void run() {
      Shell shell = fParent.getDropDownShell();
      if (shell != null)
        return;

      shell = fParent.getViewer().getDropDownShell();
      if (shell != null)
        shell.close();

      showMenu();

      fShell.setFocus();
    }
  };

  showDropDownMenuAction.setImageDescriptor(new AccessibelArrowImage(isLTR()));
  // showDropDownMenuAction.setToolTipText(BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip);
  manager.add(showDropDownMenuAction);

  manager.update(true);
  if (IS_MAC_WORKAROUND) {
    manager.getControl().addMouseListener(new MouseAdapter() {
      // see also BreadcrumbItemDetails#addElementListener(Control)
      public void mouseDown(MouseEvent e) {
        showDropDownMenuAction.run();
      }
    });
  }
}
 
Example 17
Source File: HelpHoverProvider.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected void configureControl(IXtextBrowserInformationControl control, ToolBarManager tbm, String font) {
	openExternalDocumentationAction.setEnabled(true);
	tbm.add(openExternalDocumentationAction);
	tbm.update(true);
}
 
Example 18
Source File: MakrosComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public MakrosComposite(Composite parent, int style){
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	CLabel lblHeader = new CLabel(this, SWT.NONE);
	lblHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	lblHeader.setText("Makros des Anwender " + CoreHub.getLoggedInContact().getLabel());

	
	SashForm sash = new SashForm(this, SWT.HORIZONTAL);
	sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	Composite selectionComposite = new Composite(sash, SWT.NONE);
	selectionComposite.setLayout(new GridLayout(1, true));
	ToolBarManager toolbar = new ToolBarManager();
	ToolBar toolbarControl = toolbar.createControl(selectionComposite);
	toolbarControl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
	
	viewer = new TableViewer(selectionComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
	viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setLabelProvider(new DefaultLabelProvider());
	viewer.setInput(getUserMakros(CoreHub.getLoggedInContact()));
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent event){
			StructuredSelection selection = (StructuredSelection) viewer.getSelection();
			if (selection != null && !selection.isEmpty()) {
				detailComposite.setMakro((MakroDTO) selection.getFirstElement());
			} else {
				detailComposite.setMakro(null);
			}
		}
	});
	viewer.setComparator(new ViewerComparator());
	
	MenuManager menuManager = new MenuManager();
	menuManager.add(new RemoveMakroAction(viewer));
	MenuManager subMenu = new MenuManager("Marko zu Anwender kopieren");
	subMenu.setRemoveAllWhenShown(true);
	subMenu.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager){
			addCopyToUserActions(manager);
		}
	});
	menuManager.add(subMenu);
	
	Menu menu = menuManager.createContextMenu(viewer.getTable());
	viewer.getTable().setMenu(menu);
	
	toolbar.add(new AddMakroAction(viewer));
	toolbar.add(new RemoveMakroAction(viewer));
	toolbar.add(new RefreshMakrosAction(viewer));
	toolbar.update(true);
	
	detailComposite = new MakroDetailComposite(sash, SWT.NONE);
	
	// can only be set after child components are available
	sash.setWeights(new int[] {
		1, 4
	});
}
 
Example 19
Source File: MOOSEFormEditor.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates the content used for the plant view.
 * 
 * @param section
 *            The {@code Section} that should contain the plant view.
 * @param toolkit
 *            The {@code FormToolkit} used to decorate widgets as necessary.
 */
private void populatePlantViewSection(Section section,
		FormToolkit toolkit) {
	// Get the background color to use later.
	Color background = section.getBackground();

	// Create an analysis composite to contain a ToolBar and an
	// analysis-based view.
	Composite analysisComposite = new Composite(section, SWT.NONE);
	analysisComposite.setBackground(background);
	analysisComposite.setLayout(new GridLayout(1, false));
	// Set the overall client of the plant view's Section.
	section.setClient(analysisComposite);

	// Create a ToolBarManager so we can add JFace Actions to it.
	ToolBarManager toolBarManager = new ToolBarManager(SWT.RIGHT);
	// Fill the ToolBar with customized controls.
	fillPlantViewToolBar(toolBarManager);
	toolBarManager.update(true);
	// Add it to the view.
	ToolBar toolBar = toolBarManager.createControl(analysisComposite);
	toolBar.setBackground(background);
	toolBar.setLayoutData(
			new GridData(SWT.FILL, SWT.BEGINNING, true, false));

	// Create the plant composite.
	TreeComposite components = findComponentBlock();
	factory.setTree(components);
	PlantComposite plant = factory.getPlant();
	
	//Get the factory and create a plant view from the composite
	ViewFactory viewFactory = new ViewFactory();
	viewFactory.setVizServiceFactory((BasicVizServiceFactory) VizServiceFactoryHolder.getFactory());
	plantView = viewFactory.createPlantView(plant);

	// Render the plant view in the analysis Composite.
	Composite plantComposite = plantView.createComposite(analysisComposite);
	plantComposite.setBackground(background);
	plantComposite
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	// Make sure the factory/plant is reset when the plant view is disposed.
	plantComposite.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			factory.setTree(new TreeComposite());
		}
	});

	return;
}
 
Example 20
Source File: BasicFormPage.java    From tlaplus with MIT License 4 votes vote down vote up
/**
  * Called during FormPage life cycle and delegates the form creation
  * to three methods {@link BasicFormPage#createBodyContent(IManagedForm)}, 
  * {@link BasicFormPage#loadData()}, {@link BasicFormPage#pageInitializationComplete()}
  */
 protected void createFormContent(IManagedForm managedForm)
 {
     ScrolledForm formWidget = managedForm.getForm();
     formWidget.setText(getTitle());
     if (imagePathTemplate != null)
     {
// Show the given image left of the form page's title and beneath the tab
// bar. E.g. the main model page displays three sliders left of its "Model
// Overview" label.
         formWidget.setImage(createRegisteredImage(24));
     }

     Composite body = formWidget.getBody();

     FormToolkit toolkit = managedForm.getToolkit();
     toolkit.decorateFormHeading(formWidget.getForm());

     /*
      * The head client is the second row of the header section, below the title; if we don't create this
      * with 'NO_FOCUS' then the toolbar will always take focus on a form page that gains focus.
      */
     ToolBar headClientTB = new ToolBar(formWidget.getForm().getHead(), SWT.HORIZONTAL | SWT.NO_FOCUS);
     headClientTBM = new ToolBarManager(headClientTB);
     // run button
     headClientTBM.add(new DynamicContributionItem(new RunAction()));
     // validate button
     headClientTBM.add(new DynamicContributionItem(new GenerateAction()));
     // stop button
     headClientTBM.add(new DynamicContributionItem(new StopAction()));

     // refresh the head client toolbar
     headClientTBM.update(true);

     formWidget.getForm().setHeadClient(headClientTB);

     // setup body layout
     body.setLayout(getBodyLayout());

     // create the body of the page
     createBodyContent(managedForm);

     super.createFormContent(managedForm);
     try
     {
         // load data from the model
     	//TODO decouple from UI thread (causes I/O)
         loadData();
     } catch (CoreException e)
     {
         TLCUIActivator.getDefault().logError("Error loading data from the model into the form fields", e);
     }

     // check the model is-running state
     refresh();

     // finalizes the page construction
     // activates the change listeners
     pageInitializationComplete();
     TLCUIHelper.setHelp(getPartControl(), helpId);

     getManagedForm().getForm().getForm().addMessageHyperlinkListener(errorMessageHyperLinkListener);
 }