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

The following examples show how to use org.eclipse.jface.action.Action#setToolTipText() . 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: BibtexSearchView.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
private void makeActions() {
	exportKeysAction = new Action() {
		@Override
		public void run() {
			List<Document> docs = (List<Document>) viewer.getInput();
			String ret = "";
			for (Document d : docs) {
				ret += d.getKey() + ",";
			}
			ret = ret.substring(0, ret.length() - 1);

			Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
			StringSelection s = new StringSelection(ret);
			clipboard.setContents(s, null);
			System.out.println(ret);
		}
	};
	exportKeysAction.setText("Copy Keys");
	exportKeysAction.setToolTipText("Copy Bibtex Keys to Clipboard");
	exportKeysAction.setImageDescriptor(
			PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));

	IActionBars bars = getViewSite().getActionBars();
	bars.getToolBarManager().add(exportKeysAction);
}
 
Example 2
Source File: ApiCompareView.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private void makeActions() {
	actionUpdate = new Action() {
		@Override
		public void run() {
			updateComparison();
		}
	};
	actionUpdate.setText("Update");
	actionUpdate.setToolTipText(
			"Recompute comparison for all API project and their implementation projects in the workspace.");
	// action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
	// getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

	actionOpenInEditor = new Action() {
		@Override
		public void run() {
			ISelection selection = viewer.getSelection();
			Object obj = ((IStructuredSelection) selection).getFirstElement();
			if (obj instanceof ProjectComparisonEntry)
				showInEditor((ProjectComparisonEntry) obj, true, true);
		}
	};
	actionOpenInEditor.setText("Open in Editor");
	actionOpenInEditor.setToolTipText(
			"Open the currently selected API element and its implementations in N4JS editors.");
}
 
Example 3
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 4
Source File: ICEScrolledPropertiesBlock.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This operation creates actions in the toolbar for the block.
 * </p>
 * 
 * @param managedForm
 *            <p>
 *            The parent Form
 *            </p>
 */
@Override
protected void createToolBarActions(IManagedForm managedForm) {
	final ScrolledForm form = managedForm.getForm();
	Action haction = new Action("Horizontal Orientation",
			IAction.AS_RADIO_BUTTON) {
		@Override
		public void run() {
			sashForm.setOrientation(SWT.HORIZONTAL);
			form.reflow(true);
		}
	};
	haction.setChecked(true);
	haction.setToolTipText("Set Details to the Right of Masters");
	Action vaction = new Action("Vertical Orientation",
			IAction.AS_RADIO_BUTTON) {
		@Override
		public void run() {
			sashForm.setOrientation(SWT.VERTICAL);
			form.reflow(true);
		}
	};
	vaction.setChecked(false);
	vaction.setToolTipText("Set Details Below Masters");
	form.getToolBarManager().add(haction);
	form.getToolBarManager().add(vaction);
}
 
Example 5
Source File: N4JSFilterLocalTypesOutlineContribution.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText("Hide Local Types");
	action.setDescription("Hide Local Types");
	action.setToolTipText("Hide Local (not exported) types");
	action.setImageDescriptor(imageHelper.getImageDescriptor("localtypes_co.png"));
}
 
Example 6
Source File: ResetUtil.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create reset action to add to toolbar or use on doubleclick
 *
 * @param element
 *            View to reset
 * @return a reset time range action
 */
public static Action createResetAction(ITimeReset element) {
    Action resetAction = new Action(Messages.TmfView_ResetScaleActionNameText, Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU)) {
        @Override
        public void run() {
            element.resetStartFinishTime();
        }
    };
    resetAction.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText);
    return resetAction;
}
 
Example 7
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 8
Source File: HideReturnTypesContribution.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.HideReturnTypesAction_title);
	action.setToolTipText(Messages.HideReturnTypesAction_tooltip);
	action.setDescription(Messages.HideReturnTypesAction_description);
	action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif")); 
	action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
}
 
Example 9
Source File: SARLFieldOutlineFilter.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText(Messages.SARLFieldOutlineFilter_0);
	action.setDescription(Messages.SARLFieldOutlineFilter_0);
	action.setToolTipText(Messages.SARLFieldOutlineFilter_0);
	action.setImageDescriptor(this.imageHelper.getImageDescriptor(ICON_BASENAME));
}
 
Example 10
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 11
Source File: PerformanceView.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 12
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 13
Source File: N4JSShowInheritedMembersOutlineContribution.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText("Show Inherited Members");
	action.setDescription("Show Inherited Members");
	action.setToolTipText("Show inherited, consumed, and polyfilled members");
	action.setImageDescriptor(imageHelper.getImageDescriptor("inher_co.png"));
}
 
Example 14
Source File: N4JSFilterStaticMembersOutlineContribution.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureAction(Action action) {
	action.setText("Hide Static Members");
	action.setDescription("Hide Static Members");
	action.setToolTipText("Hide Static Fields and Methods");
	action.setImageDescriptor(imageHelper.getImageDescriptor("static_co.png"));
}
 
Example 15
Source File: BreadcrumbItemDropDown.java    From Eclipse-Postfix-Code-Completion 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) {
		@Override
		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)
			@Override
			public void mouseDown(MouseEvent e) {
				showDropDownMenuAction.run();
			}
		});
	}
}
 
Example 16
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();
			}
		});
	}
}
 
Example 17
Source File: SelectorPanel.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public SelectorPanel(Composite parent, IAction... actions){
	super(parent, SWT.NONE);
	setBackground(parent.getBackground());
	/*
	 * RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.fill = true; layout.pack = true;
	 */
	FormLayout layout = new FormLayout();
	layout.marginLeft = 0;
	layout.marginRight = 0;
	setLayout(layout);
	tActions = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.WRAP);
	
	aClr = new Action(Messages.SelectorPanel_clearFields) {
		{
			setImageDescriptor(Images.IMG_CLEAR.getImageDescriptor());
		}
		
		@Override
		public void run(){
			clearValues();
		}
	};
	tActions.add(aClr);
	
	autoSearchActivatedAction =
		new Action(Messages.SelectorPanel_automaticSearch, Action.AS_CHECK_BOX) {
			{
				setImageDescriptor(Images.IMG_REFRESH.getImageDescriptor());
			}
			
			@Override
			public void run(){
				autoSearchActivated = !autoSearchActivated;
				if (autoSearchActivated)
					contentsChanged(null);
				super.run();
			}
		};
	autoSearchActivatedAction.setToolTipText(Messages.SelectorPanel_activateAutomaticSearch);
	autoSearchActivatedAction.setChecked(autoSearchActivated);
	tActions.add(autoSearchActivatedAction);
	
	performSearchAction = new Action(Messages.SelectorPanel_performSearch) {
		{
			setImageDescriptor(Images.IMG_NEXT.getImageDescriptor());
		}
		
		@Override
		public void run(){
			boolean oldState = autoSearchActivated;
			autoSearchActivated = true;
			contentsChanged(null);
			autoSearchActivated = oldState;
			super.run();
		}
	};
	performSearchAction.setToolTipText(Messages.SelectorPanel_performSearchTooltip);
	tActions.add(performSearchAction);
	
	for (IAction ac : actions) {
		if (ac != null) {
			tActions.add(ac);
		} else {
			tActions.add(new Separator());
		}
	}
	tb = tActions.createControl(this);
	FormData fdActions = new FormData();
	fdActions.top = new FormAttachment(0, 0);
	fdActions.right = new FormAttachment(100, 0);
	tb.setLayoutData(fdActions);
	cFields = new Composite(this, SWT.NONE);
	FormData fd = new FormData();
	fd.left = new FormAttachment(0, 0);
	fd.top = new FormAttachment(0, 0);
	fd.right = new FormAttachment(100, 0);
	cFields.setLayoutData(fd);
	cFields.setLayout(new FillLayout());
	if (parent.getData("TEST_COMP_NAME") != null) {
		for (int idx = 0; idx < tb.getItemCount(); idx++)
		{
			tb.getItem(idx).setData("TEST_COMP_NAME",
				parent.getData("TEST_COMP_NAME") + "_" + idx + "_tbi");
		}
	}
	pack();
}
 
Example 18
Source File: CommonQuickOutlinePage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Contributes actions to quick outline menu.
 * 
 * @param manager
 *            - menu manager.
 */
void contributeToQuickOutlineMenu(IMenuManager manager)
{
	// add sort action
	Action sortAction = new Action(Messages.CommonQuickOutlinePage_SortAlphabetically, Action.AS_CHECK_BOX)
	{
		public void run()
		{
			// Hide tree control during redraw
			getTreeViewer().getControl().setVisible(false);

			// Set the sorting according to whether this Action is checked/unchecked
			// TODO Store this persistently across quick outlines per-language?
			if (this.isChecked())
			{
				getTreeViewer().setComparator(new ViewerComparator());
			}
			else
			{
				getTreeViewer().setComparator(null);
			}

			// Show the tree control
			getTreeViewer().getControl().setVisible(true);
		}
	};
	sortAction.setImageDescriptor(UIUtils.getImageDescriptor(CommonEditorPlugin.PLUGIN_ID, "icons/sort.gif")); //$NON-NLS-1$
	sortAction.setToolTipText(Messages.CommonQuickOutlinePage_SortAlphabetically);
	// this._sortItem = new ActionContributionItem(sortAction);
	manager.add(new ActionContributionItem(sortAction));

	// add Collapse All action
	Action collapseAction = new Action(Messages.CommonQuickOutlinePage_CollapseAll, Action.AS_PUSH_BUTTON)
	{
		public void run()
		{
			getTreeViewer().collapseAll();
		}
	};
	collapseAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
			.getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
	collapseAction.setToolTipText(Messages.CommonQuickOutlinePage_CollapseAll);
	manager.add(new ActionContributionItem(collapseAction));

	// Expand All action
	Action expandAction = new Action(Messages.CommonQuickOutlinePage_ExpandAll)
	{
		public void run()
		{
			getTreeViewer().expandAll();
		}
	};
	expandAction
			.setImageDescriptor(UIUtils.getImageDescriptor(CommonEditorPlugin.PLUGIN_ID, "icons/expandall.gif")); //$NON-NLS-1$
	expandAction.setToolTipText(Messages.CommonQuickOutlinePage_ExpandAll);
	manager.add(new ActionContributionItem(expandAction));
}
 
Example 19
Source File: FlameChartView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private Action getConfigureSymbolsAction() {
    if (fConfigureSymbolsAction != null) {
        return fConfigureSymbolsAction;
    }

    Action configureSymbolsAction = new Action(Messages.CallStackView_ConfigureSymbolProvidersText) {
        @Override
        public void run() {
            SymbolProviderConfigDialog dialog = new SymbolProviderConfigDialog(getSite().getShell(), getProviderPages());
            if (dialog.open() == IDialogConstants.OK_ID) {
                List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
                if (traceEntries != null) {
                    for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
                        ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = traceEntry.getProvider();
                        if (provider instanceof CallStackDataProvider) {
                            ((CallStackDataProvider) provider).resetFunctionNames(new NullProgressMonitor());
                        }

                        // reset full and zoomed events here
                        Iterable<TimeGraphEntry> flatten = Utils.flatten(traceEntry);
                        flatten.forEach(e -> e.setSampling(null));

                        // recompute full events
                        long start = traceEntry.getStartTime();
                        long end = traceEntry.getEndTime();
                        final long resolution = Long.max(1, (end - start) / getDisplayWidth());
                        zoomEntries(flatten, start, end, resolution, new NullProgressMonitor());
                    }
                    // zoomed events will be retriggered by refreshing
                    refresh();
                }
                synchingToTime(getTimeGraphViewer().getSelectionBegin());
            }
        }
    };

    configureSymbolsAction.setToolTipText(Messages.CallStackView_ConfigureSymbolProvidersTooltip);
    configureSymbolsAction.setImageDescriptor(Objects.requireNonNull(Activator.getDefault()).getImageDescripterFromPath(IMPORT_BINARY_ICON_PATH));

    /*
     * The updateConfigureSymbolsAction() method (called by refresh()) will set the
     * action to true if applicable after the symbol provider has been properly
     * loaded.
     */
    configureSymbolsAction.setEnabled(false);

    fConfigureSymbolsAction = configureSymbolsAction;
    return configureSymbolsAction;
}
 
Example 20
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);
}