List of usage examples for org.eclipse.jface.action Action getImageDescriptor
@Override
public ImageDescriptor getImageDescriptor()
From source file:cc.warlock.rcp.ui.ConnectionAction.java
License:Open Source License
public ConnectionAction(Action action) { this.action = action; if (action.getImageDescriptor() != null) { this.image = action.getImageDescriptor().createImage(); }// ww w .ja va 2s. c om }
From source file:com.gorillalogic.monkeyconsole.actions.DropDownMenuAction.java
License:Open Source License
public void setSelectedAction(Action selectedAction) { this.selectedAction = selectedAction; this.setToolTipText(selectedAction.getToolTipText()); this.setImageDescriptor(selectedAction.getImageDescriptor()); this.setText(selectedAction.getText()); }
From source file:fr.inria.linuxtools.tmf.ui.views.uml2sd.SDView.java
License:Open Source License
/** * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br> * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br> * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br> * * @see ISDGraphNodeSupporter Action support definition * @see SDView#setSDFilterProvider(ISDFilterProvider) * @see SDView#setSDFindProvider(ISDFindProvider) * @see SDView#setSDPagingProvider(ISDPagingProvider) */// w ww . ja v a2s .co m protected void createCoolbarContent() { IActionBars bar = getViewSite().getActionBars(); bar.getMenuManager().removeAll(); bar.getToolBarManager().removeAll(); createMenuGroup(); Zoom resetZoom = new Zoom(this, ZoomType.ZOOM_RESET); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, resetZoom); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, resetZoom); Zoom noZoom = new Zoom(this, ZoomType.ZOOM_NONE); noZoom.setChecked(true); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, noZoom); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, noZoom); Zoom zoomIn = new Zoom(this, ZoomType.ZOOM_IN); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomIn); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomIn); Zoom zoomOut = new Zoom(this, ZoomType.ZOOM_OUT); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomOut); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomOut); MenuManager navigation = new MenuManager(Messages.SequenceDiagram_Navigation); ShowNodeStart showNodeStart = new ShowNodeStart(this); showNodeStart.setText(Messages.SequenceDiagram_ShowNodeStart); showNodeStart.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$ showNodeStart.setActionDefinitionId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$ navigation.add(showNodeStart); ShowNodeEnd showNodeEnd = new ShowNodeEnd(this); showNodeEnd.setText(Messages.SequenceDiagram_ShowNodeEnd); showNodeEnd.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$ showNodeEnd.setActionDefinitionId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$ navigation.add(showNodeEnd); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, navigation); ConfigureMinMax minMax = new ConfigureMinMax(this); minMax.setText(Messages.SequenceDiagram_ConfigureMinMax); minMax.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$ bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, minMax); if ((fSdWidget.getFrame() != null) && (fSdWidget.getFrame().hasTimeInfo())) { minMax.setEnabled(true); } else { minMax.setEnabled(false); } // Do we need to display a paging item if (fSdPagingProvider != null) { fNextPageButton = new NextPage(this); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fNextPageButton); fNextPageButton.setEnabled(fSdPagingProvider.hasNextPage()); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fNextPageButton); fPrevPageButton = new PrevPage(this); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fPrevPageButton); fPrevPageButton.setEnabled(fSdPagingProvider.hasPrevPage()); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fPrevPageButton); fFirstPageButton = new FirstPage(this); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fFirstPageButton); fFirstPageButton.setEnabled(fSdPagingProvider.hasPrevPage()); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fFirstPageButton); fLastPageButton = new LastPage(this); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fLastPageButton); fLastPageButton.setEnabled(fSdPagingProvider.hasNextPage()); bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fLastPageButton); } if (fSdExFilterProvider != null) { Action action = fSdExFilterProvider.getFilterAction(); if (action != null) { if (action.getId() == null) { action.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$ } if (action.getImageDescriptor() == null) { action.setImageDescriptor( Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS)); } if (action.getText() == null || action.getText().length() == 0) { action.setText(Messages.SequenceDiagram_EditFilters); } bar.getMenuManager().prependToGroup(UML2SD_FILTERING_SEPARATOR, action); bar.getToolBarManager().prependToGroup(UML2SD_FILTERING_SEPARATOR, action); } } // Both systems can be used now: commenting out else keyword if (fSdFilterProvider != null) { bar.getMenuManager().appendToGroup(UML2SD_FILTERING_SEPARATOR, new OpenSDFiltersDialog(this, fSdFilterProvider)); } if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) { IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID); if (sdPaging != null) { bar.getMenuManager().remove(sdPaging); sdPaging = null; } bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) fSdPagingProvider)); updatePagesMenuItem(bar); } if (fSdExFindProvider != null) { Action action = fSdExFindProvider.getFindAction(); if (action != null) { if (action.getId() == null) { action.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$ } if (action.getImageDescriptor() == null) { action.setImageDescriptor(Activator.getDefault() .getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ)); } if (action.getText() == null) { action.setText(Messages.SequenceDiagram_Find + "..."); //$NON-NLS-1$ } bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, action); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, action); } } else if (fSdFindProvider != null) { bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDFindDialog(this)); bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDFindDialog(this)); } if (fSdExtendedActionBarProvider != null) { fSdExtendedActionBarProvider.supplementCoolbarContent(bar); } bar.updateActionBars(); }
From source file:fr.opensagres.mongodb.ide.ui.actions.ActionMenu.java
License:Open Source License
public ActionMenu(List<Action> actions) { this.actions = actions; if (this.actions.size() > 0) { Action firstAction = this.actions.get(0); setToolTipText(firstAction.getToolTipText()); setImageDescriptor(firstAction.getImageDescriptor()); if (this.actions.size() > 1) setMenuCreator(this); }/*ww w . j av a 2 s. co m*/ }
From source file:org.eclipse.emf.ecp.edit.internal.swt.Activator.java
License:Open Source License
/** * Loads an image for the given Action./* ww w . j a v a 2 s. c o m*/ * * @param action the action * @return the {@link Image} */ public static Image getImage(Action action) { final String path = action.toString(); if (!getDefault().imageRegistry.containsKey(path)) { getDefault().imageRegistry.put(path, new ImageDescriptorToImage(action.getImageDescriptor())); } return getDefault().imageRegistry.get(path).getImage(); }
From source file:org.eclipse.emf.ecp.editor.mecontrols.melinkcontrol.MESingleLinkControl.java
License:Open Source License
/** * Creates a button for an action./*from w ww . j a v a 2 s. co m*/ * * @param action the action */ protected void createButtonForAction(final Action action) { Button selectButton = getToolkit().createButton(composite, "", SWT.PUSH); selectButton.setImage(action.getImageDescriptor().createImage()); selectButton.setToolTipText(action.getToolTipText()); selectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { action.run(); } }); }
From source file:org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView.java
License:Open Source License
/** * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br> * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br> * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br> * //w w w . ja v a2 s. c o m * @see ISDGraphNodeSupporter Action support definition * @see SDView#setSDFilterProvider(ISDFilterProvider) * @see SDView#setSDFindProvider(ISDFindProvider) * @see SDView#setSDPagingProvider(ISDPagingProvider) */ protected void createCoolbarContent() { IActionBars bar = getViewSite().getActionBars(); bar.getMenuManager().removeAll(); bar.getToolBarManager().removeAll(); createMenuGroup(); Zoom resetZoom = new Zoom(this, ZoomType.ZOOM_RESET); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom);//$NON-NLS-1$ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom); //$NON-NLS-1$ Zoom noZoom = new Zoom(this, ZoomType.ZOOM_NONE); noZoom.setChecked(true); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom);//$NON-NLS-1$ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom); //$NON-NLS-1$ Zoom zoomIn = new Zoom(this, ZoomType.ZOOM_IN); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn);//$NON-NLS-1$ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn); //$NON-NLS-1$ Zoom zoomOut = new Zoom(this, ZoomType.ZOOM_OUT); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut);//$NON-NLS-1$ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut); //$NON-NLS-1$ MenuManager navigation = new MenuManager(SDMessages._77); ShowNodeStart showNodeStart = new ShowNodeStart(this); showNodeStart.setText(SDMessages.uml_25); showNodeStart.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$ showNodeStart.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$ navigation.add(showNodeStart); ShowNodeEnd showNodeEnd = new ShowNodeEnd(this); showNodeEnd.setText(SDMessages.uml_23); showNodeEnd.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$ showNodeEnd.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$ navigation.add(showNodeEnd); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation); //$NON-NLS-1$ ConfigureMinMax minMax = new ConfigureMinMax(this); minMax.setText(SDMessages.uml_45); minMax.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$ bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax); //$NON-NLS-1$ if ((sdWidget.getFrame() != null) && (sdWidget.getFrame().hasTimeInfo())) minMax.setEnabled(true); else minMax.setEnabled(false); // Do we need to display a paging item if (sdPagingProvider != null) { nextPageButton = new NextPage(this); bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton); //$NON-NLS-1$ nextPageButton.setEnabled(sdPagingProvider.hasNextPage()); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton); //$NON-NLS-1$ prevPageButton = new PrevPage(this); bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton); //$NON-NLS-1$ prevPageButton.setEnabled(sdPagingProvider.hasPrevPage()); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton); //$NON-NLS-1$ firstPageButton = new FirstPage(this); bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton); //$NON-NLS-1$ firstPageButton.setEnabled(sdPagingProvider.hasPrevPage()); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton); //$NON-NLS-1$ lastPageButton = new LastPage(this); bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton); //$NON-NLS-1$ lastPageButton.setEnabled(sdPagingProvider.hasNextPage()); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton); //$NON-NLS-1$ } if (sdExFilterProvider != null) { Action action = sdExFilterProvider.getFilterAction(); if (action != null) { if (action.getId() == null) action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$ if (action.getImageDescriptor() == null) action.setImageDescriptor( TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS)); if (action.getText() == null || action.getText().length() == 0) action.setText(SDMessages._42); bar.getMenuManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$ bar.getToolBarManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$ } } // Both systems can be used now: commenting out else keyword /* else */if (sdFilterProvider != null) { bar.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$ // No longer in the coolbar: commenting out next statement //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$ } if (sdPagingProvider != null && sdPagingProvider instanceof ISDAdvancedPagingProvider) { IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID); if (sdPaging != null) { bar.getMenuManager().remove(sdPaging); sdPaging = null; } bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", //$NON-NLS-1$ new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) sdPagingProvider)); updatePagesMenuItem(bar); } if (sdExFindProvider != null) { Action action = sdExFindProvider.getFindAction(); if (action != null) { if (action.getId() == null) action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$ if (action.getImageDescriptor() == null) action.setImageDescriptor(TmfUiPlugin.getDefault() .getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ)); if (action.getText() == null) action.setText(SDMessages._41); bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$ } } else if (sdFindProvider != null) { bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$ bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$ } if (sdExtendedActionBarProvider != null) { sdExtendedActionBarProvider.supplementCoolbarContent(bar); } bar.updateActionBars(); }
From source file:org.eclipse.mat.ui.util.PopupMenu.java
License:Open Source License
private void addToMenu(Menu menu, Listener hide, Listener show, Listener arm, Listener selection) { for (Object item : children) { if (item instanceof Action) { Action action = (Action) item; int flags = SWT.PUSH; int style = action.getStyle(); if (style == IAction.AS_CHECK_BOX) flags = SWT.CHECK;//w w w. j av a 2 s . c om else if (style == IAction.AS_RADIO_BUTTON) flags = SWT.RADIO; MenuItem menuItem = new MenuItem(menu, flags); String acceleratorText = null; ExternalActionManager.ICallback callback = ExternalActionManager.getInstance().getCallback(); String commandId = action.getActionDefinitionId(); if (commandId != null && callback != null) acceleratorText = callback.getAcceleratorText(commandId); if (acceleratorText == null) menuItem.setText(action.getText()); else menuItem.setText(action.getText() + '\t' + acceleratorText); if (flags != SWT.PUSH) menuItem.setSelection(action.isChecked()); if (showImages()) { ImageDescriptor id = action.getImageDescriptor(); if (id != null) menuItem.setImage(id.createImage()); } menuItem.setData(action); menuItem.addListener(SWT.Selection, selection); menuItem.addListener(SWT.Arm, arm); } else if (item instanceof PopupMenu) { PopupMenu popup = (PopupMenu) item; if (!popup.isEmpty()) { ImageDescriptor imageDescriptor = popup.getImageDescriptor(); Menu subMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); subMenu.addListener(SWT.Hide, hide); subMenu.addListener(SWT.Show, show); popup.addToMenu(subMenu, hide, show, arm, selection); MenuItem menuItem = new MenuItem(menu, SWT.CASCADE); String acceleratorText = null; ExternalActionManager.ICallback callback = ExternalActionManager.getInstance().getCallback(); if (popup.actionDefinitionId != null && callback != null) acceleratorText = callback.getAcceleratorText(popup.actionDefinitionId); if (acceleratorText == null) menuItem.setText(popup.name); else menuItem.setText(popup.name + '\t' + acceleratorText); if (imageDescriptor != null) menuItem.setImage(imageDescriptor.createImage()); menuItem.setMenu(subMenu); } } else if (item == SEPARATOR) { int count = menu.getItemCount(); if (count > 0 && ((menu.getItem(count - 1).getStyle() & SWT.SEPARATOR) != SWT.SEPARATOR)) { new MenuItem(menu, SWT.SEPARATOR); } } } }
From source file:org.eclipse.osee.ats.client.integration.tests.ats.actions.AbstractAtsActionTest.java
License:Open Source License
@Test public void getImageDescriptor() throws Exception { Action action = createAction(); Assert.assertNotNull("Image should be specified", action.getImageDescriptor()); }
From source file:org.eclipse.osee.ats.util.AtsUtil.java
License:Open Source License
public static MenuItem actionToMenuItem(Menu menu, final Action action, final int buttonType) { final Action fAction = action; MenuItem item = new MenuItem(menu, buttonType); item.setText(action.getText());//from w w w . j a v a 2 s. c o m if (action.getImageDescriptor() != null) { item.setImage(action.getImageDescriptor().createImage()); } item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (buttonType == SWT.CHECK) { action.setChecked(!action.isChecked()); } fAction.run(); } }); return item; }