Java Code Examples for org.eclipse.jface.action.IAction#setImageDescriptor()

The following examples show how to use org.eclipse.jface.action.IAction#setImageDescriptor() . 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: XFilteredTree.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the button that clears the text.
 *
 * @param parent parent <code>Composite</code> of toolbar button
 */
private void createClearTextOld(Composite parent) {
   // only create the button if the text widget doesn't support one
   // natively
   if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) {
      filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
      filterToolBar.createControl(parent);

      IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
            /**
             * @see org.eclipse.jface.action.Action#run()
             */
            @Override
            public void run() {
               clearText();
            }
         };

      clearTextAction.setToolTipText(XViewerText.get("button.clear")); //$NON-NLS-1$
      clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON));
      clearTextAction.setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON));

      filterToolBar.add(clearTextAction);
   }
}
 
Example 2
Source File: FilteredTreeComposite.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the button that clears the text.
 *
 * @param parent parent <code>Composite</code> of toolbar button
 */
private void createClearText(Composite parent) {
   // only create the button if the text widget doesn't support one
   // natively
   if ((filterText.getStyle() & SWT.CANCEL) == 0) {
      filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
      filterToolBar.createControl(parent);

      IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
            @Override
            public void run() {
               clearText();
            }
         };

      clearTextAction.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip);
      clearTextAction.setImageDescriptor(XViewerImageCache.getImageDescriptor("clear.gif")); //$NON-NLS-1$
      clearTextAction.setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON));

      filterToolBar.add(clearTextAction);
   }
}
 
Example 3
Source File: TexOutlinePage.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
private IAction createHideAction(String desc, final int nodeType, ImageDescriptor img) {
    IAction action = new Action(desc, IAction.AS_CHECK_BOX) {
        public void run() {
            boolean oldState = filter.isTypeVisible(nodeType);
            filter.toggleType(nodeType, !oldState);
            TreeViewer viewer = getTreeViewer();
            if (oldState == false) {
                revealNodes(nodeType);
            }
            viewer.refresh();
        }
    };
    action.setToolTipText(desc);
    action.setImageDescriptor(img);
    return action;
}
 
Example 4
Source File: MenuProvider.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
/** Undo, Redo, and Delete */
private void addEditActions(final IMenuManager menu) {
	GEFActionConstants.addStandardActionGroups(menu);
	IAction undoAction = registry.getAction(ActionFactory.UNDO.getId());
	undoAction.setImageDescriptor(Icon.UNDO.descriptor());
	undoAction.setDisabledImageDescriptor(Icon.UNDO_DISABLED.descriptor());
	IAction redoAction = registry.getAction(ActionFactory.REDO.getId());
	redoAction.setImageDescriptor(Icon.REDO.descriptor());
	redoAction.setDisabledImageDescriptor(Icon.REDO_DISABLED.descriptor());
	menu.appendToGroup(GEFActionConstants.GROUP_UNDO, undoAction);
	menu.appendToGroup(GEFActionConstants.GROUP_UNDO, redoAction);
	IAction deleteAction = registry.getAction(ActionFactory.DELETE.getId());
	deleteAction.setText(M.Delete);
	deleteAction.setImageDescriptor(Icon.DELETE.descriptor());
	deleteAction.setDisabledImageDescriptor(Icon.DELETE_DISABLED.descriptor());
	menu.appendToGroup(GEFActionConstants.GROUP_EDIT, deleteAction);
}
 
Example 5
Source File: ShowWhitespaceCharactersActionContributor.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
	public void contributeActions(XtextEditor editor) {
		IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
		IAction action = editor.getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
		action.setImageDescriptor(imageHelper
				.getImageDescriptor("full/etool16/show_whitespace_chars.gif"));
		action.setDisabledImageDescriptor(imageHelper
				.getImageDescriptor("full/dtool16/show_whitespace_chars.gif"));
		if(toolBarManager.find(action.getId())==null) {
			toolBarManager.add(new ActionContributionItemExtension(action));				
//			toolBarManager.add(action);				
		}
	}
 
Example 6
Source File: JavaPluginImages.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static void setImageDescriptors(IAction action, String type, String relPath) {
	ImageDescriptor id= create("d" + type, relPath, false); //$NON-NLS-1$
	if (id != null)
		action.setDisabledImageDescriptor(id);

	/*
	 * id= create("c" + type, relPath, false); //$NON-NLS-1$
	 * if (id != null)
	 * 		action.setHoverImageDescriptor(id);
	 */

	ImageDescriptor descriptor= create("e" + type, relPath, true); //$NON-NLS-1$
	action.setHoverImageDescriptor(descriptor);
	action.setImageDescriptor(descriptor);
}
 
Example 7
Source File: AnnotationStyleViewPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
        IStatusLineManager statusLineManager) {
  super.makeContributions(menuManager, toolBarManager, statusLineManager);
  
  // TODO: Figure out how to use open properties dialog action here correctly
  // see http://wiki.eclipse.org/FAQ_How_do_I_open_a_Property_dialog%3F
  
  IAction action = new Action() {
    @Override
    public void run() {
      super.run();
      
      ISelection sel = new StructuredSelection(new AnnotationTypeNode(editor, null));
      PropertyPage page = new EditorAnnotationPropertyPage();
      page.setElement(new AnnotationTypeNode(editor, null));
      page.setTitle("Styles");
      PreferenceManager mgr = new PreferenceManager();
      IPreferenceNode node = new PreferenceNode("1", page);
      mgr.addToRoot(node);
      PropertyDialog dialog = new PropertyDialog(getSite().getShell(), mgr, sel);
      dialog.create();
      dialog.setMessage(page.getTitle());
      dialog.open();
    }
  };
  
  action.setImageDescriptor(CasEditorPlugin
          .getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));
  
  toolBarManager.add(action);
}
 
Example 8
Source File: ControlFlowView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void fillLocalToolBar(IToolBarManager manager) {
    // add "Optimization" Button to local tool bar of Controlflow
    IAction optimizationAction = getOptimizationAction();
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, optimizationAction);

    // add a separator to local tool bar
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new Separator());

    super.fillLocalToolBar(manager);
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    IDialogSettings section = settings.getSection(getClass().getName());
    if (section == null) {
        section = settings.addNewSection(getClass().getName());
    }

    IAction hideArrowsAction = getTimeGraphViewer().getHideArrowsAction(section);
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, hideArrowsAction);

    IAction followArrowBwdAction = getTimeGraphViewer().getFollowArrowBwdAction();
    followArrowBwdAction.setText(Messages.ControlFlowView_followCPUBwdText);
    followArrowBwdAction.setToolTipText(Messages.ControlFlowView_followCPUBwdText);
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, followArrowBwdAction);

    IAction followArrowFwdAction = getTimeGraphViewer().getFollowArrowFwdAction();
    followArrowFwdAction.setText(Messages.ControlFlowView_followCPUFwdText);
    followArrowFwdAction.setToolTipText(Messages.ControlFlowView_followCPUFwdText);
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, followArrowFwdAction);

    IAction previousEventAction = new SearchEventAction(false, PackageMessages.ControlFlowView_PreviousEventJobName);
    previousEventAction.setText(PackageMessages.ControlFlowView_PreviousEventActionName);
    previousEventAction.setToolTipText(PackageMessages.ControlFlowView_PreviousEventActionTooltip);
    previousEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(PREV_EVENT_ICON_PATH));
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, previousEventAction);

    IAction nextEventAction = new SearchEventAction(true, PackageMessages.ControlFlowView_NextEventJobName);
    nextEventAction.setText(PackageMessages.ControlFlowView_NextEventActionName);
    nextEventAction.setToolTipText(PackageMessages.ControlFlowView_NextEventActionTooltip);
    nextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(NEXT_EVENT_ICON_PATH));
    manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, nextEventAction);
}
 
Example 9
Source File: JavaCompareUtilities.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
static void initAction(IAction a, ResourceBundle bundle, String prefix) {

		String labelKey= "label"; //$NON-NLS-1$
		String tooltipKey= "tooltip"; //$NON-NLS-1$
		String imageKey= "image"; //$NON-NLS-1$
		String descriptionKey= "description"; //$NON-NLS-1$

		if (prefix != null && prefix.length() > 0) {
			labelKey= prefix + labelKey;
			tooltipKey= prefix + tooltipKey;
			imageKey= prefix + imageKey;
			descriptionKey= prefix + descriptionKey;
		}

		a.setText(getString(bundle, labelKey, labelKey));
		a.setToolTipText(getString(bundle, tooltipKey, null));
		a.setDescription(getString(bundle, descriptionKey, null));

		String relPath= getString(bundle, imageKey, null);
		if (relPath != null && relPath.trim().length() > 0) {

			String dPath;
			String ePath;

			if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
				String path= relPath.substring(1);
				dPath= 'd' + path;
				ePath= 'e' + path;
			} else {
				dPath= "dlcl16/" + relPath; //$NON-NLS-1$
				ePath= "elcl16/" + relPath; //$NON-NLS-1$
			}

			ImageDescriptor id= JavaCompareUtilities.getImageDescriptor(dPath);	// we set the disabled image first (see PR 1GDDE87)
			if (id != null)
				a.setDisabledImageDescriptor(id);
			id= JavaCompareUtilities.getImageDescriptor(ePath);
			if (id != null) {
				a.setImageDescriptor(id);
				a.setHoverImageDescriptor(id);
			}
		}
	}
 
Example 10
Source File: CommonViewer.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public void setObjectCreateAction(IViewSite site, IAction action){
	site.getActionBars().getToolBarManager().add(action);
	action.setImageDescriptor(Images.IMG_NEW.getImageDescriptor());
	createObjectAction = action;
}
 
Example 11
Source File: LaborView.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createPartControl(final Composite parent){
	setTitleImage(Images.IMG_VIEW_LABORATORY.getImage());
	
	tabFolder = new CTabFolder(parent, SWT.TOP);
	tabFolder.setLayout(new FillLayout());
	
	final CTabItem resultsTabItem = new CTabItem(tabFolder, SWT.NULL);
	resultsTabItem.setText("Resultate");
	resultsComposite = new LaborResultsComposite(tabFolder, SWT.NONE);
	resultsTabItem.setControl(resultsComposite);
	
	final CTabItem ordersTabItem = new CTabItem(tabFolder, SWT.NULL);
	ordersTabItem.setText("Verordnungen");
	ordersComposite = new LaborOrdersComposite(tabFolder, SWT.NONE);
	ordersTabItem.setControl(ordersComposite);
	
	tabFolder.setSelection(0);
	tabFolder.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e){
			resultsComposite.reload();
			ordersComposite.reload();
		}
	});
	makeActions();
	menu = new ViewMenus(getViewSite());
	menu.createMenu(newAction, backAction, fwdAction, printAction, importAction, xmlAction);
	// Orders
	final LaborOrderPulldownMenuCreator menuCreator =
		new LaborOrderPulldownMenuCreator(parent.getShell());
	if (menuCreator.getSelected() != null) {
		IAction dropDownAction = menuCreator.getAction();
		
		IActionBars actionBars = getViewSite().getActionBars();
		IToolBarManager toolbar = actionBars.getToolBarManager();
		
		toolbar.add(dropDownAction);
		
		// Set data
		dropDownAction.setText(menuCreator.getSelected().getText());
		dropDownAction.setToolTipText(menuCreator.getSelected().getToolTipText());
		dropDownAction.setImageDescriptor(menuCreator.getSelected().getImageDescriptor());
	}
	// Importers
	IToolBarManager tm = getViewSite().getActionBars().getToolBarManager();
	List<IAction> importers =
		Extensions.getClasses(
			Extensions.getExtensions(ExtensionPointConstantsUi.LABORDATENIMPORT),
			"ToolbarAction", //$NON-NLS-1$ //$NON-NLS-2$
			false);
	for (IAction ac : importers) {
		tm.add(ac);
	}
	if (importers.size() > 0) {
		tm.add(new Separator());
	}
	tm.add(refreshAction);
	tm.add(newColumnAction);
	tm.add(newAction);
	tm.add(backAction);
	tm.add(fwdAction);
	tm.add(expandAllAction);
	tm.add(collapseAllAction);
	tm.add(printAction);
	
	// register event listeners
	ElexisEventDispatcher.getInstance().addListeners(eeli_labitem, eeli_laborder,
		eeli_labresult, eeli_pat);
	Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class);
	if ((act != null && act != resultsComposite.getPatient())) {
		resultsComposite.selectPatient(act);
	}
	getSite().getPage().addPartListener(udpateOnVisible);
}
 
Example 12
Source File: NavigatorUIPluginImages.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets all available image descriptors for the given action.
 * 
 * @param action
 *            - The action associated with the icon.
 * @param type
 *            - The type of icon.
 * @param relPath
 *            - The relative path of the icon.
 */
public static void setImageDescriptors(IAction action, String type, String relPath) {
	// /*relPath= relPath.substring(NAVIGATORUI_NAME_PREFIX_LENGTH);*/
	// action.setDisabledImageDescriptor(create("d" + type, relPath));
	// //$NON-NLS-1$
	// action.setHoverImageDescriptor(create("c" + type, relPath));
	// //$NON-NLS-1$
	action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
}
 
Example 13
Source File: NavigatorUIPluginImages.java    From tmxeditor8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets all available image descriptors for the given action.
 * 
 * @param action
 *            - The action associated with the icon.
 * @param type
 *            - The type of icon.
 * @param relPath
 *            - The relative path of the icon.
 */
public static void setImageDescriptors(IAction action, String type, String relPath) {
	// /*relPath= relPath.substring(NAVIGATORUI_NAME_PREFIX_LENGTH);*/
	// action.setDisabledImageDescriptor(create("d" + type, relPath));
	// //$NON-NLS-1$
	// action.setHoverImageDescriptor(create("c" + type, relPath));
	// //$NON-NLS-1$
	action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
}