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

The following examples show how to use org.eclipse.jface.action.Action#setText() . 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: LamiViewerControl.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Build a new control for a Lami table viewer.
 *
 * @param parent
 *            The parent composite
 * @param page
 *            The {@link LamiReportViewTabPage} page parent
 */
public LamiViewerControl(Composite parent, LamiReportViewTabPage page) {
    fToggleAction = new Action() {
        @Override
        public void run() {
            TmfViewer viewer = fViewer;
            if (viewer == null) {
                fViewer = LamiTableViewer.createLamiTable(parent, page);
            } else {
                viewer.dispose();
                fViewer = null;
            }
            parent.layout();
        }
    };
    fToggleAction.setText(Messages.LamiReportView_ActivateTableAction_ButtonName);
    fToggleAction.setToolTipText(Messages.LamiReportView_ActivateTableAction_ButtonTooltip);
    fToggleAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath("icons/table.gif")); //$NON-NLS-1$
}
 
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: 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 4
Source File: PluginConfigManage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void addPluginMenu(final PluginConfigBean bean) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始添加新的菜单
			Action action = new Action() {
				@Override
				public void run() {
					executePlugin(bean);
				}
			};
			action.setText(bean.getName());
			action.setId(bean.getId());
			if (!"".equals(bean.getShortcutKey())) {
				action.setText(bean.getName() + "\t" + bean.getShortcutKey());
			}

			pluginMenu.add(action);
			pluginMenu.update();
		}
	}
}
 
Example 5
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 6
Source File: CustomChartStubView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createPartControl(@Nullable Composite parent) {
    super.createPartControl(parent);
    SashForm sf = new SashForm(parent, SWT.NONE);
    fContainer = sf;

    /* Add a menu for adding charts */
    Action addChart = new NewChartAction();
    addChart.setText(MENU_TITLE);

    IMenuManager menuMgr = getViewSite().getActionBars().getMenuManager();
    menuMgr.add(addChart);
}
 
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: 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 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: MarkOccurrenceActionContributor.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.MarkOccurrenceActionContributor_text);
	action.setDescription(Messages.MarkOccurrenceActionContributor_description);
	action.setToolTipText(Messages.MarkOccurrenceActionContributor_toolTipText);
	action.setImageDescriptor(XtextPluginImages.DESC_MARK_OCCURRENCES);
	action.setDisabledImageDescriptor(XtextPluginImages.DESC_MARK_OCCURRENCES_DISABLED);
	addPropertyChangeListener();
}
 
Example 11
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 12
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 13
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 14
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 15
Source File: FeatureStructureBrowserViewPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the following actions to the toolbar: {@link FeatureStructureBrowserViewPage.CreateAction}
 * DeleteAction
 *
 * @param menuManager the menu manager
 * @param toolBarManager the tool bar manager
 * @param statusLineManager the status line manager
 */
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
        IStatusLineManager statusLineManager) {
  // create
  Action createAction = new CreateAction();
  createAction.setText("Create");
  createAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.ADD));
  toolBarManager.add(createAction);

  // delete
  toolBarManager.add(ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
}
 
Example 16
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 17
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 18
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 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: LamiReportView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createPartControl(@Nullable Composite parent) {
    LamiAnalysisReport report = fReport;
    if (report == null || parent == null) {
        return;
    }

    setPartName(report.getName());

    fTabFolder = new CTabFolder(parent, SWT.NONE);
    fTabFolder.setSimple(false);

    for (LamiResultTable table : report.getTables()) {
        String name = table.getTableClass().getTableTitle();

        CTabItem tabItem = new CTabItem(fTabFolder, SWT.NULL);
        tabItem.setText(name);

        SashForm sf = new SashForm(fTabFolder, SWT.NONE);
        fTabPages.add(new LamiReportViewTabPage(sf, table));
        tabItem.setControl(sf);
    }

    /* Add toolbar buttons */
    Action toggleTableAction = new ToggleTableAction();
    toggleTableAction.setText(Messages.LamiReportView_ActivateTableAction_ButtonName);
    toggleTableAction.setToolTipText(Messages.LamiReportView_ActivateTableAction_ButtonTooltip);
    toggleTableAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath("icons/table.gif")); //$NON-NLS-1$

    IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbarMgr = actionBars.getToolBarManager();
    toolbarMgr.add(toggleTableAction);

    fNewChartAction.setText(Messages.LamiReportView_NewCustomChart);

    fClearCustomViewsAction.setText(Messages.LamiReportView_ClearAllCustomViews);
    IMenuManager menuMgr = actionBars.getMenuManager();
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener((@Nullable IMenuManager manager) -> {
        if (manager != null) {
            populateMenu(manager);
        }
    });
    populateMenu(menuMgr);

    /* Select the first tab initially */
    CTabFolder tf = checkNotNull(fTabFolder);
    if (tf.getItemCount() > 0) {
        tf.setSelection(0);
    }

}