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

The following examples show how to use org.eclipse.jface.action.Action#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: FollowModeAction.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private Action createAction(final User user) {
  // The additional @ is needed because @ has special meaning in
  // Action#setText(), see JavaDoc of Action().

  String followUserMessage = getFollowUserMessage(user);

  if (followUserMessage.contains("@")) followUserMessage += "@";

  Action action =
      new Action(followUserMessage) {

        @Override
        public void run() {
          followUser(user);
        }
      };

  action.setImageDescriptor(followModeEnabledImageDescriptor);
  return action;
}
 
Example 2
Source File: CounterView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private Action getCumulativeAction() {
    Action action = new Action(Messages.CounterView_CumulativeAction_Text, IAction.AS_CHECK_BOX) {

        @Override
        public void run() {
            boolean isCumulative = isChecked();
            setToolTipText(isCumulative ? Messages.CounterView_CumulativeAction_DifferentialTooltipText : Messages.CounterView_CumulativeAction_CumulativeTooltipText);
            TmfXYChartViewer chart = getChartViewer();
            if (chart instanceof CounterChartViewer) {
                ((CounterChartViewer) chart).toggleCumulative();
            }
        }
    };

    action.setToolTipText(Messages.CounterView_CumulativeAction_CumulativeTooltipText);
    action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.tracecompass.tmf.ui", "icons/elcl16/sigma.gif")); //$NON-NLS-1$ //$NON-NLS-2$
    return action;
}
 
Example 3
Source File: MemoryUsageView2.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private Action getFilterAction() {
    Action action = new Action(Messages.MemoryView_FilterAction_Text, IAction.AS_CHECK_BOX) {
        // memory view is filtered by default.
        private boolean isFiltered = true;

        @Override
        public void run() {
            isFiltered ^= true;
            setToolTipText(isFiltered ? Messages.MemoryView_FilterAction_FilteredTooltipText : Messages.MemoryView_FilterAction_UnfilteredTooltipText);
            TmfViewer tree = getLeftChildViewer();
            if (tree instanceof MemoryUsageTreeViewer2) {
                MemoryUsageTreeViewer2 memoryUsageTreeViewer = (MemoryUsageTreeViewer2) tree;
                memoryUsageTreeViewer.setFiltered(isFiltered);
            }
        }
    };
    action.setToolTipText(Messages.MemoryView_FilterAction_FilteredTooltipText);
    action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.tracecompass.tmf.ui", "icons/elcl16/filter_items.gif")); //$NON-NLS-1$ //$NON-NLS-2$
    // filtered by default, to not change the default behavior
    action.setChecked(true);
    return action;
}
 
Example 4
Source File: LocalAppEngineConsolePageParticipant.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void configureToolBar(IToolBarManager toolbarManager) {
  terminateAction = new Action(Messages.actionStop) {
    @Override
    public void run() {
      //code to execute when button is pressed
      LocalAppEngineServerBehaviour serverBehaviour = console.getServerBehaviourDelegate();
      if (serverBehaviour != null) {
        // try to initiate a nice shutdown
        boolean force = serverBehaviour.getServer().getServerState() == IServer.STATE_STOPPING;
        serverBehaviour.stop(force);
      }
      update();
    }
  };
  terminateAction.setToolTipText(Messages.actionStopToolTip);
  terminateAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_STOP));
  terminateAction.setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_STOP));
  terminateAction.setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_STOP));

  toolbarManager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, terminateAction);
}
 
Example 5
Source File: LamiViewerControl.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Build a new control for a graph viewer.
 *
 * @param parent
 *            The parent composite
 * @param data
 *            The {@link LamiReportViewTabPage} parent page
 * @param model
 *            The graph model
 */
public LamiViewerControl(Composite parent, ChartData data, ChartModel model) {
    fToggleAction = new Action() {
        @Override
        public void run() {
            TmfViewer viewer = fViewer;
            if (viewer == null) {
                fViewer = (TmfViewer) IChartViewer.createChart(parent, data, model);
            } else {
                viewer.dispose();
                fViewer = null;
            }
            parent.layout();
        }
    };
    fToggleAction.setText(Messages.LamiReportView_ToggleAction_ButtonNamePrefix + ' ' + model.getTitle());
    fToggleAction.setToolTipText(Messages.LamiReportView_ToggleAction_ButtonTooltip);
    fToggleAction.setImageDescriptor(getIconForGraphType(model.getChartType()));
}
 
Example 6
Source File: SARLOperationOutlineFilter.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText(Messages.SARLOperationOutlineFilter_0);
	action.setDescription(Messages.SARLOperationOutlineFilter_0);
	action.setToolTipText(Messages.SARLOperationOutlineFilter_0);
	action.setImageDescriptor(this.imageHelper.getImageDescriptor(ICON_BASENAME));
}
 
Example 7
Source File: ShowSyntheticMembersContribution.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText("Show Synthetic Members");
	action.setDescription("Show Synthetic Members");
	action.setToolTipText("Show Synthetic Members");
	action.setImageDescriptor(imageHelper.getImageDescriptor("generated_code_view.png"));
}
 
Example 8
Source File: LinkWithEditorOutlineContribution.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText(XtextUIMessages.ToggleLinkWithEditorAction_label);
	action.setToolTipText(XtextUIMessages.ToggleLinkWithEditorAction_toolTip);
	action.setDescription(XtextUIMessages.ToggleLinkWithEditorAction_description);
	action.setImageDescriptor(XtextPluginImages.DESC_LINK_WITH_EDITOR);
	action.setDisabledImageDescriptor(XtextPluginImages.DESC_LINK_WITH_EDITOR_DISABLED);
}
 
Example 9
Source File: SortOutlineContribution.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText(XtextUIMessages.LexicalSortingAction_label);
	action.setToolTipText(XtextUIMessages.LexicalSortingAction_tooltip);
	action.setDescription(XtextUIMessages.LexicalSortingAction_description);
	action.setImageDescriptor(XtextPluginImages.DESC_ALPHAB_SORT_CO);
	action.setDisabledImageDescriptor(XtextPluginImages.DESC_ALPHAB_SORT_CO_DISABLED);
}
 
Example 10
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * configures the outline viewer
 */
protected void configureOutlineViewer() {
	getViewer().setEditDomain(getEditDomain());
	getViewer().setEditPartFactory(getOutlineViewEditPartFactory());

	MenuManager outlineContextMenuProvider = getOutlineContextMenuProvider(getViewer());
	if (outlineContextMenuProvider != null) {
		getViewer().setContextMenu(outlineContextMenuProvider);
	}

	getViewer().setKeyHandler(getKeyHandler());
	IToolBarManager tbm = this.getSite().getActionBars().getToolBarManager();
	showOutlineAction = new Action() {

		public void run() {
			showPage(ID_OUTLINE);
		}
	};
	showOutlineAction.setImageDescriptor(DiagramUIPluginImages.DESC_OUTLINE);
	showOutlineAction.setToolTipText(DiagramUIMessages.OutlineView_OutlineTipText);
	//  tbm.add(showOutlineAction);
	showOverviewAction = new Action() {

		public void run() {
			showPage(ID_OVERVIEW);
		}
	};
	showOverviewAction.setImageDescriptor(DiagramUIPluginImages.DESC_OVERVIEW);
	showOverviewAction.setToolTipText(DiagramUIMessages.OutlineView_OverviewTipText);

	// tbm.add(showOverviewAction);
	showPage(ID_OVERVIEW);
}
 
Example 11
Source File: FilterViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Fill the context menu for the tree viewer.
 *
 * @param manager
 *            The menu manager
 */
protected void fillContextMenu(IMenuManager manager) {
    final ISelection selection = fViewer.getSelection();
    ITmfFilterTreeNode filterTreeNode = null;
    if (selection instanceof StructuredSelection) {
        Object element = ((StructuredSelection) selection).getFirstElement();
        if (element instanceof ITmfFilterTreeNode) {
            filterTreeNode = (ITmfFilterTreeNode) element;
        }
    }

    final ITmfFilterTreeNode selectedNode = filterTreeNode;
    if (selectedNode != null) {
        fillContextMenuForNode(selectedNode, manager);
    }

    manager.add(new Separator("delete")); //$NON-NLS-1$

    if (fIsDialog && (selectedNode != null)) {
        Action deleteAction = new Action(Messages.FilterViewer_DeleteActionText) {
            @Override
            public void run() {
                selectedNode.remove();
                fViewer.refresh();
            }
        };
        deleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
        manager.add(deleteAction);
    }
    manager.add(new Separator("edit")); //$NON-NLS-1$

    if (fViewer.getInput() instanceof TmfFilterRootNode || filterTreeNode == null) {
        manager.add(new Separator());
        ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();
        fillContextMenuForNode(root, manager);
    }
}
 
Example 12
Source File: FilterTerminalRulesContribution.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText(Messages.FilterTerminalRulesContribution_title);
	action.setDescription(Messages.FilterTerminalRulesContribution_description);
	action.setToolTipText(Messages.FilterTerminalRulesContribution_tooltip);
	action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));  
	action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
}
 
Example 13
Source File: SourceGraphView.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private Action createAction(String label, int style, String tooltip, ImageDescriptor image,
		Consumer<Action> onRun) {
	final Action result = new Action(label, style) {
		@Override
		public void run() {
			onRun.accept(this);
		}
	};
	result.setText(label);
	result.setToolTipText(tooltip);
	result.setImageDescriptor(image);
	getViewSite().getActionBars().getToolBarManager().add(result);
	return result;
}
 
Example 14
Source File: SwitchOutlineModeContribution.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText("Jvm View");
	action.setToolTipText("Jvm Model View");
	action.setDescription("Switch between Source and Jvm model perspectives.");
	action.setImageDescriptor(imageHelper.getImageDescriptor("jvm_mode.gif"));
	action.setDisabledImageDescriptor(imageHelper.getImageDescriptor("jvm_mode.gif"));
}
 
Example 15
Source File: N4JSFilterNonPublicMembersOutlineContribution.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText("Hide Non-Public Members");
	action.setDescription("Hide Non-Public Members");
	action.setToolTipText("Hide Non-Public Fields and Methods");
	action.setImageDescriptor(imageHelper.getImageDescriptor("public_co.png"));
}
 
Example 16
Source File: SARLBehaviorUnitOutlineFilter.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText(Messages.SARLBehaviorUnitOutlineFilter_0);
	action.setDescription(Messages.SARLBehaviorUnitOutlineFilter_0);
	action.setToolTipText(Messages.SARLBehaviorUnitOutlineFilter_0);
	action.setImageDescriptor(this.imageHelper.getImageDescriptor(ICON_BASENAME));
}
 
Example 17
Source File: GamlLinkWithEditorOutlineContribution.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void configureAction(final Action action) {
	super.configureAction(action);
	action.setImageDescriptor(GamaIcons.create("navigator/navigator.link2").descriptor());
}
 
Example 18
Source File: KonsDetailView.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
private void makeActions(){
	
	versionDisplayAction = new Action() {
		private String versionText;
		
		@Override
		public String getText(){
			return versionText;
		}
		
		@Override
		public void setText(String text){
			versionText = text;
		}
		
		@Override
		public boolean isEnabled(){
			return false;
		}
	};
	
	purgeAction = new LockedRestrictedAction<IEncounter>(AccessControlDefaults.AC_PURGE,
		Messages.KonsDetailView_PurgeOldEntries) {
		
		@Override
		public IEncounter getTargetedObject(){
			return actEncounter;
		}
		
		@Override
		public void doRun(IEncounter element){
			element.getVersionedEntry().purge();
			ElexisEventDispatcher.fireSelectionEvent(Konsultation.load(element.getId()));
		}
		
	};
	versionBackAction = new Action(Messages.KonsDetailView_PreviousEntry) { // $NON-NLS-1$
		
		@Override
		public void run(){
			if (actEncounter == null) {
				return;
			}
			if (MessageDialog.openConfirm(getViewSite().getShell(),
				Messages.KonsDetailView_ReplaceKonsTextCaption, // $NON-NLS-1$
				Messages.KonsDetailView_ReplaceKonsTextBody)) { // $NON-NLS-1$
				setKonsText(actEncounter, displayedVersion - 1);
				text.setDirty(true);
			}
		}
		
	};
	versionFwdAction = new Action(Messages.KonsDetailView_nextEntry) { // $NON-NLS-1$
		@Override
		public void run(){
			if (actEncounter == null) {
				return;
			}
			if (MessageDialog.openConfirm(getViewSite().getShell(),
				Messages.KonsDetailView_ReplaceKonsTextCaption, // $NON-NLS-1$
				Messages.KonsDetailView_ReplaceKonsTextBody2)) { // $NON-NLS-1$
				setKonsText(actEncounter, displayedVersion + 1);
				text.setDirty(true);
			}
		}
	};
	saveAction = new LockedAction<IEncounter>(Messages.KonsDetailView_SaveEntry) {
		{
			setImageDescriptor(Images.IMG_DISK.getImageDescriptor());
			setToolTipText(Messages.KonsDetailView_SaveExplicit); // $NON-NLS-1$
		}
		
		@Override
		public IEncounter getTargetedObject(){
			return actEncounter;
		}
		
		@Override
		public void doRun(IEncounter element){
			save();
		}
	};
	
	versionFwdAction.setImageDescriptor(Images.IMG_NEXT.getImageDescriptor());
	versionBackAction.setImageDescriptor(Images.IMG_PREVIOUS.getImageDescriptor());
	purgeAction.setImageDescriptor(Images.IMG_DELETE.getImageDescriptor());
	assignStickerAction = new Action("Sticker...") {
		{
			setToolTipText("Der Konsultation einer Sticker zuweisen");
		}
		
		@Override
		public void run(){
			if (actEncounter != null) {
				AssignStickerDialog asd =
					new AssignStickerDialog(getViewSite().getShell(), actEncounter);
				asd.open();
			}
		}
	};
}
 
Example 19
Source File: TerminologyViewPart.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建视图工具栏的按钮。
 */
private void createAction() {
	firstAction = new Action() {
		@Override
		public void run() {
			if (rowIndex < 0) {
				return;
			}
			if (tempEditor == null || rowIndex < 0) {
				return;
			}
			TransUnitBean transUnit = tempEditor.getRowTransUnitBean(rowIndex);
			Hashtable<String, String> tuProp = transUnit.getTuProps();
			if (tuProp != null) {
				String translate = tuProp.get("translate");
				if (translate != null && translate.equalsIgnoreCase("no")) {
					MessageDialog.openInformation(getSite().getShell(),
							Messages.getString("view.TerminologyViewPart.msgTitle"),
							Messages.getString("view.TerminologyViewPart.msg1"));
					return;
				}
			}

			String tarTerm = "";
			GridItem[] items = gridTable.getSelection();
			if (items.length <= 0) {
				return;
			} else {
				tarTerm = items[0].getText(2);
			}

			try {
				tempEditor.insertCell(rowIndex, tempEditor.getTgtColumnIndex(), tarTerm);
				// tempEditor.setFocus(); // 焦点给回编辑器
			} catch (ExecutionException e) {
				if (Constant.RUNNING_MODE == Constant.MODE_DEBUG) {
					e.printStackTrace();
				}
				MessageDialog.openInformation(parent.getShell(),
						Messages.getString("view.TerminologyViewPart.msgTitle"),
						Messages.getString("view.TerminologyViewPart.msg2") + e.getMessage());
			}
		}
	};
	firstAction.setText(Messages.getString("view.TerminologyViewPart.menu.inserttermtarget"));
	firstAction.setImageDescriptor(Activator.getIconDescriptor(ImageConstants.ACCPTE_TERM));
	firstAction.setToolTipText(Messages.getString("view.TerminologyViewPart.firstAction"));
	firstAction.setEnabled(false);
	//getViewSite().getActionBars().getToolBarManager().add(firstAction);
}
 
Example 20
Source File: BreadcrumbItemDropDown.java    From birt 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));
	setAccessibilityText(fToolBar, Messages.getString( "BreadcrumbItemDropDown.showDropDownMenu.action.toolTip") ); //$NON-NLS-1$
	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(Messages.getString( "BreadcrumbItemDropDown.showDropDownMenu.action.toolTip")); //$NON-NLS-1$
	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();
			}
		});
	}
}