org.eclipse.jface.action.Action Java Examples
The following examples show how to use
org.eclipse.jface.action.Action.
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: FindingsComposite.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void fillContextMenu(IMenuManager contextMenu, FindingsTemplate findingsTemplate){ contextMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); contextMenu.add(new Action("Entfernen") { @Override public ImageDescriptor getImageDescriptor(){ return Images.IMG_DELETE.getImageDescriptor(); } @Override public void run(){ if (getModel().isPresent()) { EcoreUtil.delete(findingsTemplate); getViewer().refresh(); } } }); }
Example #2
Source File: AbapGitStagingView.java From ADT_Frontend with MIT License | 6 votes |
/** * Action for switching a repository */ private void createRepositorySelectionToolbarAction() { this.actionSwitchRepository = new Action(Messages.AbapGitStaging_switch_repository, SWT.DROP_DOWN) { @Override public void runWithEvent(Event event) { Widget widget = event.widget; if (widget instanceof ToolItem) { ToolItem item = (ToolItem) widget; Rectangle bounds = item.getBounds(); event.detail = SWT.ARROW; event.x = bounds.x; event.y = bounds.y + bounds.height; item.notifyListeners(SWT.Selection, event); } } }; this.actionSwitchRepository .setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/obj/repository.png")); //$NON-NLS-1$ this.actionSwitchRepository.setMenuCreator(new SwitchRepositoryMenuCreator(this, this.stagingUtil)); }
Example #3
Source File: EigenleistungCodeSelectorFactory.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void makeActions(){ createAction = new Action("neu erstellen") { { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.BlockDetailDisplay_addSelfDefinedServices); } @Override public void run(){ Shell parent = PlatformUI.getWorkbench().getDisplay().getActiveShell(); EigenLeistungDialog dialog = new EigenLeistungDialog(parent, null); dialog.open(); cv.notify(CommonViewer.Message.update); } }; }
Example #4
Source File: PluginConfigManage.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
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: FollowModeAction.java From saros with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: CodeDetailView.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void makeActions(){ importAction = new Action(Messages.CodeDetailView_importActionTitle) { //$NON-NLS-1$ @Override public void run(){ CTabItem it = ctab.getSelection(); if (it != null) { ImporterPage top = importers.get(it.getText()); if (top != null) { ImportDialog dlg = new ImportDialog(getViewSite().getShell(), top); dlg.create(); dlg.setTitle(top.getTitle()); dlg.setMessage(top.getDescription()); dlg.getShell().setText(Messages.CodeDetailView_importerCaption); //$NON-NLS-1$ if (dlg.open() == Dialog.OK) { top.run(false); } } } } }; }
Example #7
Source File: JaretTableActionFactory.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public Action createStdAction(JaretTable table, String name) { if (_actionMap == null) { _actionMap = new HashMap<String, Action>(); } Action result = _actionMap.get(name); if (result != null) { return result; } if (name.equals(ACTION_CONFIGURECOLUMNS)) { result = new ConfigureColumnsAction(table); } else if (name.equals(ACTION_OPTROWHEIGHT)) { result = new OptimizeRowHeightAction(table); } else if (name.equals(ACTION_OPTALLROWHEIGHTS)) { result = new OptimizeAllRowHeightsAction(table); } else if (name.equals("s")) { result = null; } if (result != null) { _actionMap.put(name, result); } return result; }
Example #8
Source File: AbstractThemeableEditor.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override protected void createActions() { super.createActions(); setAction(FilterThroughCommandAction.COMMAND_ID, FilterThroughCommandAction.create(this)); this.fThemeableEditorFindBarExtension.createFindBarActions(); // Code formatter setup Action action = new TextOperationAction(Messages.getBundleForConstructedKeys(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$ action.setActionDefinitionId(ICommonConstants.FORMATTER_ACTION_DEFINITION_ID); setAction(ICommonConstants.FORMATTER_ACTION_ID, action); markAsStateDependentAction(ICommonConstants.FORMATTER_ACTION_ID, true); markAsSelectionDependentAction(ICommonConstants.FORMATTER_ACTION_ID, true); // Folding setup foldingActionsGroup = new FoldingActionsGroup(this); }
Example #9
Source File: ApiCompareView.java From n4js with Eclipse Public License 1.0 | 6 votes |
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 #10
Source File: KonsListe.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void makeActions(){ filterAction = new Action(Messages.KonsListe_FilterListAction, Action.AS_CHECK_BOX) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_FILTER.getImageDescriptor()); setToolTipText(Messages.KonsListe_FilterListToolTip); //$NON-NLS-1$ } @Override public void run(){ if (!isChecked()) { filter = null; } else { KonsFilterDialog kfd = new KonsFilterDialog(actPatient, filter); if (kfd.open() == Dialog.OK) { filter = kfd.getResult(); } else { kfd = null; setChecked(false); } } restart(null); } }; }
Example #11
Source File: ProcessContributionSection.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void bindActions(TableViewer viewer, Section section) { Action add = Actions.onAdd(this::onAdd); Action remove = Actions.onRemove(this::onRemove); Action copy = TableClipboard.onCopy(viewer); Actions.bind(section, add, remove); Actions.bind(viewer, add, remove, copy); Tables.onDoubleClick(viewer, (event) -> { TableItem item = Tables.getItem(viewer, event); if (item == null) onAdd(); else { ReportProcess process = Viewers.getFirstSelected(viewer); if (process != null) App.openEditor(process.descriptor); } }); Tables.onDeletePressed(viewer, (e) -> onRemove()); }
Example #12
Source File: FindingsUiUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * Returns all actions from the sub toolbar * * @param c * @param iObservation * @param horizontalGrap * @return */ public static List<Action> createToolbarSubComponents(Composite c, IObservation iObservation, int horizontalGrap){ List<Action> actions = new ArrayList<>(); String comment = iObservation.getComment().orElse(""); ToolBarManager menuManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.NO_FOCUS); Action commentableAction = new CommentAction(c.getShell(), comment); menuManager.add(commentableAction); menuManager.createControl(c) .setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, horizontalGrap, 1)); actions.add(commentableAction); return actions; }
Example #13
Source File: NodeCompactor.java From depan with Apache License 2.0 | 6 votes |
private Action buildAddHierarchy(final ViewEditor editor) { Action action = new Action("Add hierarchy..", IAction.AS_PUSH_BUTTON) { @Override public void run() { PropertyDocumentReference<GraphEdgeMatcherDescriptor> matcher = EdgeMatcherSaveLoadConfig.CONFIG.loadResource( editor.getEditorSite().getShell(), editor.getResourceProject()); if (null != matcher) { editor.addNodeTreeHierarchy(matcher.getDocument()); } } }; return action; }
Example #14
Source File: CounterView.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
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 #15
Source File: MarkOccurrenceActionContributor.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void contributeActions(XtextEditor editor) { editor2marker.computeIfAbsent(editor, (e)->{ Action action = getAction(); editor.setAction(action.getId(), action); IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager(); if(toolBarManager.find(action.getId())==null) { ActionContributionItem item = new ActionContributionItem(action); item.setVisible(false); toolBarManager.add(item); } OccurrenceMarker occurrenceMarker = occurrenceMarkerProvider.get(); occurrenceMarker.connect(editor, isPropertySet()); return occurrenceMarker; }); }
Example #16
Source File: AbstractFindbugsView.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
protected void makeActions() { actionShowBugTreeView = new Action() { @Override public void run() { showBugTreeView(); } }; configureAction(actionShowBugTreeView, "Show Bug Explorer View", "Show Bug Explorer View", TREE_VIEW_IMG); actionShowDetailsView = new Action() { @Override public void run() { showDetailsView(); } }; configureAction(actionShowDetailsView, "Show Bug Info View", "Show Bug Info View", DETAILS_VIEW_IMG); actionShowPerspective = new Action() { @Override public void run() { showPerspective(); } }; configureAction(actionShowPerspective, "Switch to SpotBugs Perspective", "Switch to SpotBugs Perspective", PERSPECTIVE_IMG); }
Example #17
Source File: EditorUtility.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Maps the localized modifier name to a code in the same * manner as #findModifier. * * @param modifierName the modifier name * @return the SWT modifier bit, or <code>0</code> if no match was found * @since 2.1.1 */ public static int findLocalizedModifier(String modifierName) { if (modifierName == null) return 0; if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.CTRL))) return SWT.CTRL; if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT))) return SWT.SHIFT; if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.ALT))) return SWT.ALT; if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND))) return SWT.COMMAND; return 0; }
Example #18
Source File: Actions.java From olca-app with Mozilla Public License 2.0 | 6 votes |
public static Action onSave(Runnable runnable) { return new Action() { { setText(M.Save); setToolTipText(M.Save); setImageDescriptor( Icon.SAVE.descriptor()); setDisabledImageDescriptor( Icon.SAVE_DISABLED.descriptor()); } @Override public void run() { runnable.run(); } }; }
Example #19
Source File: SvnPropertiesView.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * fill the popup menu for the table */ private void fillTableMenu(IMenuManager manager) { manager.add(getRefreshAction()); Action action = getAddPropertyAction(); try { if (resource != null) action.setEnabled(resource.isManaged()); else action.setEnabled(false); } catch (SVNException e) { action.setEnabled(false); } manager.add(action); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); }
Example #20
Source File: MemoryUsageView.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
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 MemoryUsageTreeViewer) { MemoryUsageTreeViewer memoryUsageTreeViewer = (MemoryUsageTreeViewer) 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 #21
Source File: DeployConsolePageParticipant.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private Action createTerminateAction() { Action terminate = new Action(Messages.getString("action.stop")) { @Override public void run() { DeployJob job = console.getJob(); if (job != null) { job.cancel(); update(); } } }; terminate.setToolTipText(Messages.getString("action.stop")); terminate.setImageDescriptor(getSharedImage(ISharedImages.IMG_ELCL_STOP)); terminate.setHoverImageDescriptor(getSharedImage(ISharedImages.IMG_ELCL_STOP)); terminate.setDisabledImageDescriptor(getSharedImage(ISharedImages.IMG_ELCL_STOP_DISABLED)); return terminate; }
Example #22
Source File: GenerateBuildPathActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void fillViewSubMenu(IMenuManager source) { int added= 0; int i=0; for (Iterator<Action> iter= fActions.iterator(); iter.hasNext();) { Action action= iter.next(); if (action instanceof IUpdate) ((IUpdate) action).update(); if (i == 2) source.add(new Separator(GROUP_BUILDPATH)); else if (i == 8) source.add(new Separator(GROUP_FILTER)); else if (i == 10) source.add(new Separator(GROUP_CUSTOMIZE)); added+= addAction(source, action); i++; } if (added == 0) { source.add(fNoActionAvailable); } }
Example #23
Source File: SocialAspectsPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void createEntrySection(FormToolkit tk, Composite body) { Section section = UI.section(body, tk, M.SocialAssessment); Composite comp = UI.sectionClient(section, tk, 1); UI.gridData(section, true, true); createTree(comp); Trees.onDoubleClick(tree, (e) -> editAspect()); Action add = Actions.onAdd(this::addIndicator); Action edit = Actions.create(M.Edit, Icon.EDIT.descriptor(), this::editAspect); Action delete = Actions.onRemove(this::deleteAspect); CommentAction.bindTo(section, "socialAspects", editor.getComments(), add, edit, delete); Actions.bind(tree, add, edit, delete); }
Example #24
Source File: DocumentsView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void makeActions(){ doubleClickAction = new Action() { public void run(){ ISelection selection = viewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj instanceof IDocument) { IDocument dh = (IDocument) obj; DocumentStoreServiceHolder.getService().getPersistenceObject(dh) .ifPresent(po -> { ICommandService commandService = (ICommandService) PlatformUI .getWorkbench().getService(ICommandService.class); Command command = commandService .getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); PlatformUI.getWorkbench().getService(IEclipseContext.class).set( command.getId().concat(".selection"), new StructuredSelection(po)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(getSite().getShell(), "Fehler", "Das Dokument konnte nicht geöffnet werden."); e.printStackTrace(); } }); ContextServiceHolder.get().postEvent(ElexisEventTopics.EVENT_UPDATE, dh); } } }; }
Example #25
Source File: FilterViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Fill the context menu with the valid children of the provided node * * @param node * The target node * @param manager * The menu manager */ protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) { for (final String child : node.getValidChildren()) { final Action action = new Action() { @Override public void run() { ITmfFilterTreeNode newNode = null; if (TmfFilterNode.NODE_NAME.equals(child)) { newNode = new TmfFilterNode(node, ""); //$NON-NLS-1$ } else if (TmfFilterTraceTypeNode.NODE_NAME.equals(child)) { newNode = new TmfFilterTraceTypeNode(node); } else if (TmfFilterAndNode.NODE_NAME.equals(child)) { newNode = new TmfFilterAndNode(node); } else if (TmfFilterOrNode.NODE_NAME.equals(child)) { newNode = new TmfFilterOrNode(node); } else if (TmfFilterContainsNode.NODE_NAME.equals(child)) { newNode = new TmfFilterContainsNode(node); } else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) { newNode = new TmfFilterEqualsNode(node); } else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) { newNode = new TmfFilterMatchesNode(node); } else if (TmfFilterCompareNode.NODE_NAME.equals(child)) { newNode = new TmfFilterCompareNode(node); } if (newNode != null) { fViewer.refresh(); fViewer.setSelection(new StructuredSelection(newNode), true); } } }; if (TmfFilterNode.NODE_NAME.equals(child)) { action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$ } else { action.setText(child); } manager.add(action); } }
Example #26
Source File: AbapGitStagingView.java From ADT_Frontend with MIT License | 5 votes |
/** * Refresh AbapGit repository action */ private void createRefreshAction() { this.actionRefresh = new Action() { public void run() { if (AbapGitStagingView.this.repository != null && AbapGitStagingView.this.project != null) { fetchCredentialsAndRefresh(); } } }; this.actionRefresh.setText(Messages.AbapGitView_action_refresh); this.actionRefresh.setToolTipText(Messages.AbapGitView_action_refresh); this.actionRefresh .setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/etool/refresh.png")); //$NON-NLS-1$ }
Example #27
Source File: ResetUtil.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * 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 #28
Source File: TableClipboard.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private static Action onPaste(Table table, Consumer<String> fn) { table.addListener(SWT.KeyUp, e -> { if (((e.stateMask & SWT.CTRL) == SWT.CTRL) && (e.keyCode == 'v' || e.keyCode == 'V')) { paste(table, fn); } }); ImageDescriptor image = Icon.PASTE.descriptor(); return Actions.create(M.Paste, image, () -> paste(table, fn)); }
Example #29
Source File: GraphConfig.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private Action loadAction(IConfigurationElement element) { try { return (Action) element.createExecutableExtension("class"); } catch (ClassCastException | CoreException e) { IStatus status = new Status(IStatus.ERROR, RcpActivator.PLUGIN_ID, "Error while loading action extensions for graphical editor", e); RcpActivator.getDefault().getLog().log(status); return null; } }
Example #30
Source File: AbstractTimeGraphView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Returns an action for hiding / showing empty rows * * @return the hide empty rows action. * @since 6.0 */ protected Action getHideEmptyRowsAction() { HideEmptyRowsAction hideEmptyRowsAction = fHideEmptyRowsAction; if (hideEmptyRowsAction == null) { hideEmptyRowsAction = new HideEmptyRowsAction(); fHideEmptyRowsAction = hideEmptyRowsAction; } return hideEmptyRowsAction; }