org.eclipse.ui.IWorkbenchCommandConstants Java Examples

The following examples show how to use org.eclipse.ui.IWorkbenchCommandConstants. 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: ImportsAwareClipboardAction.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates the action.
 * 
 * @param bundle
 *            the resource bundle
 * @param prefix
 *            a prefix to be prepended to the various resource keys (described in <code>ResourceAction</code>
 *            constructor), or <code>null</code> if none
 * @param editor
 *            the text editor. May not be <code>null</code>.
 * @param operationCode
 *            the operation code
 */
public ImportsAwareClipboardAction(ResourceBundle bundle, String prefix, ITextEditor editor,
		final int operationCode) {
	super(bundle, prefix, editor);
	this.operationCode = operationCode;

	if (operationCode == ITextOperationTarget.CUT) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
	} else if (operationCode == ITextOperationTarget.COPY) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
	} else if (operationCode == ITextOperationTarget.PASTE) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
	} else {
		Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
	}
	update();
}
 
Example #2
Source File: OpenXFindPanelHandler.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override // IHandler
public Object execute(ExecutionEvent event) throws ExecutionException {

    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    IEditorPart part = window.getActivePage().getActiveEditor();

    XFindPanel panel = XFindPanelManager.getXFindPanel(part, true);
    if (panel != null) {
        panel.showPanel();
    }
    else {
        // failed to create XFindPanel, execute standard command "Find and Replace".   
        IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
        try {
            handlerService.executeCommand(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE, null);
        } catch (Exception ex) {
            LogHelper.logError("Command " + IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE + " not found");   //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    return null;
}
 
Example #3
Source File: AboutDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create the context menu for the text widget.
 * 
 * @since 3.4
 */
private void createTextMenu() {
	final MenuManager textManager = new MenuManager();
	textManager.add(new CommandContributionItem(
			new CommandContributionItemParameter(PlatformUI
					.getWorkbench(), null, IWorkbenchCommandConstants.EDIT_COPY,
					CommandContributionItem.STYLE_PUSH)));
	textManager.add(new CommandContributionItem(
			new CommandContributionItemParameter(PlatformUI
					.getWorkbench(), null, IWorkbenchCommandConstants.EDIT_SELECT_ALL,
					CommandContributionItem.STYLE_PUSH)));
	text.setMenu(textManager.createContextMenu(text));
	text.addDisposeListener(new DisposeListener() {

		public void widgetDisposed(DisposeEvent e) {
			textManager.dispose();
		}
	});
	
}
 
Example #4
Source File: ClipboardOperationAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the action.
 * @param bundle the resource bundle
 * @param prefix a prefix to be prepended to the various resource keys
 *   (described in <code>ResourceAction</code> constructor), or
 *   <code>null</code> if none
 * @param editor the text editor
 * @param operationCode the operation code
 */
public ClipboardOperationAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) {
	super(bundle, prefix, editor);
	fOperationCode= operationCode;

	if (operationCode == ITextOperationTarget.CUT) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
	} else if (operationCode == ITextOperationTarget.COPY) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
	} else if (operationCode == ITextOperationTarget.PASTE) {
		setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
		setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
	} else {
		Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
	}
	update();
}
 
Example #5
Source File: PackageExplorerActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setGlobalActionHandlers(IActionBars actionBars) {
	// Navigate Go Into and Go To actions.
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
	actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
	actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
	actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction);
	actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
	actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);

	fRefactorActionGroup.retargetFileMenuActions(actionBars);

	IHandlerService handlerService= (IHandlerService) fPart.getViewSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
	handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
}
 
Example #6
Source File: AbstractInfoView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fills the actions bars.
 * <p>
 * Subclasses may extend.
 *
 * @param actionBars the action bars
 */
protected void fillActionBars(IActionBars actionBars) {
	IToolBarManager toolBar= actionBars.getToolBarManager();
	fillToolBar(toolBar);

	IAction action;

	action= getCopyToClipboardAction();
	if (action != null)
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), action);

	action= getSelectAllAction();
	if (action != null)
		actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), action);

	IHandlerService handlerService= (IHandlerService) getSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkAction));
}
 
Example #7
Source File: EditActionProvider.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
protected void makeActions() {
	clipboard = new Clipboard(shell.getDisplay());

	pasteAction = new PasteAction(shell, clipboard);
	pasteAction.setImageDescriptor(GamaIcons.create("menu.paste2").descriptor());
	pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);

	copyAction = new CopyAction(shell, clipboard, pasteAction);
	copyAction.setImageDescriptor(GamaIcons.create("menu.copy2").descriptor());
	copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);

	final IShellProvider sp = () -> shell;

	deleteAction = new DeleteResourceAction(sp);
	deleteAction.setImageDescriptor(GamaIcons.create("menu.delete2").descriptor());
	deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);

}
 
Example #8
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void registerToolbarActions(IActionBars actionBars) {
	IToolBarManager toolBarManager= actionBars.getToolBarManager();

	fCollapseAllAction= new CollapseAllAction(fOutlineViewer);
	fCollapseAllAction.setActionDefinitionId(CollapseAllHandler.COMMAND_ID);
	toolBarManager.add(fCollapseAllAction);

	toolBarManager.add(new LexicalSortingAction());

	fMemberFilterActionGroup= new MemberFilterActionGroup(fOutlineViewer, "org.eclipse.jdt.ui.JavaOutlinePage"); //$NON-NLS-1$
	fMemberFilterActionGroup.contributeToToolBar(toolBarManager);

	fCustomFiltersActionGroup.fillActionBars(actionBars);

	IMenuManager viewMenuManager= actionBars.getMenuManager();
	viewMenuManager.add(new Separator("EndFilterGroup")); //$NON-NLS-1$

	fToggleLinkingAction= new ToggleLinkingAction();
	fToggleLinkingAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR);
	viewMenuManager.add(new ClassOnlyAction());
	viewMenuManager.add(fToggleLinkingAction);

	fCategoryFilterActionGroup= new CategoryFilterActionGroup(fOutlineViewer, "org.eclipse.jdt.ui.JavaOutlinePage", new IJavaElement[] {fInput}); //$NON-NLS-1$
	fCategoryFilterActionGroup.contributeToViewMenu(viewMenuManager);
}
 
Example #9
Source File: ShowFilteredPreferencePageHandler.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public final Object execute(final ExecutionEvent event)
{
	final String preferencePageId = event.getParameter(IWorkbenchCommandConstants.WINDOW_PREFERENCES_PARM_PAGEID);
	final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);

	final Shell shell;
	if (activeWorkbenchWindow == null)
	{
		shell = null;
	}
	else
	{
		shell = activeWorkbenchWindow.getShell();
	}

	final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, preferencePageId,
			new String[] { preferencePageId }, null);
	dialog.open();

	return null;
}
 
Example #10
Source File: BuildActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private BuildActionGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider, RefreshAction refreshAction) {
	fSelectionProvider= specialSelectionProvider != null ? specialSelectionProvider : site.getSelectionProvider();

	fBuildAction= new BuildAction(new ShellProviderAdapter(site.getShell()), IncrementalProjectBuilder.INCREMENTAL_BUILD);
	fBuildAction.setText(ActionMessages.BuildAction_label);
	fBuildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);

	fRefreshAction= refreshAction;
	fRefreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);

	if (specialSelectionProvider != null) {
		fRefreshAction.setSpecialSelectionProvider(specialSelectionProvider);
	}

	fSelectionProvider.addSelectionChangedListener(fBuildAction);
	fSelectionProvider.addSelectionChangedListener(fRefreshAction);
}
 
Example #11
Source File: AbstractInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createTitleMenuArea(Composite parent) {
	fViewMenuButtonComposite= (Composite) super.createTitleMenuArea(parent);

	// If there is a header, then the filter text must be created
	// underneath the title and menu area.

	if (hasHeader()) {
		fFilterText= createFilterText(parent);
	}

	// Create show view menu action
	fShowViewMenuAction= new Action("showViewMenu") { //$NON-NLS-1$
		/*
		 * @see org.eclipse.jface.action.Action#run()
		 */
		@Override
		public void run() {
			showDialogMenu();
		}
	};
	fShowViewMenuAction.setEnabled(true);
	fShowViewMenuAction.setActionDefinitionId(IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU);

	return fViewMenuButtonComposite;
}
 
Example #12
Source File: RefactorActionGroup.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
protected void makeActions() {
	IShellProvider sp = new IShellProvider() {
		public Shell getShell() {
			return shell;
		}
	};

	moveAction = new MoveResourceAction(sp);
	moveAction.setText(WorkbenchNavigatorMessages.actions_RefactorActionGroup_moveAction);
	moveAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_MOVE);

	renameAction = new RenameResourceAndCloseEditorAction(sp, tree);
	renameAction.setText(WorkbenchNavigatorMessages.actions_RefactorActionGroup_renameAction);
	renameAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_RENAME);
}
 
Example #13
Source File: OccurrencesSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public OccurrencesSearchResultPage() {
	super(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
	fLinkWithEditorListener= new LinkWithEditorListener();
	fLinkingEnabled= false;
	fToggleLinkingAction= new ToggleLinkingAction();
	fToggleLinkingAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR);
}
 
Example #14
Source File: OccurrencesSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	super.createControl(parent);

	IActionBars bars= getSite().getActionBars();
	IMenuManager menu= bars.getMenuManager();
	menu.add(fToggleLinkingAction);

	IHandlerService handlerService= (IHandlerService) getSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
}
 
Example #15
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void createActions() {
	fActionGroups= new CompositeActionGroup(new ActionGroup[] {
			new NewWizardsActionGroup(this.getSite()),
			fOpenEditorGroup= new OpenEditorActionGroup(this),
			new OpenViewActionGroup(this),
			fCCPActionGroup= new CCPActionGroup(this),
			new GenerateActionGroup(this),
			new RefactorActionGroup(this),
			new ImportActionGroup(this),
			fBuildActionGroup= new BuildActionGroup(this),
			new JavaSearchActionGroup(this)});


	if (fHasWorkingSetFilter) {
		String viewId= getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
		Assert.isNotNull(viewId);
		IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent event) {
				doWorkingSetChanged(event);
			}
		};
		fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(getSite(), workingSetListener);
		fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
	}

	// Custom filter group
	if (fHasCustomFilter)
		fCustomFiltersActionGroup= new CustomFiltersActionGroup(this, fViewer);

	fToggleLinkingAction= new ToggleLinkingAction(this);
	fToggleLinkingAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR);
}
 
Example #16
Source File: PropertiesActionProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void init(final ICommonActionExtensionSite aSite) {
	
	delegateSelectionProvider = new DelegateSelectionProvider( aSite.getViewSite().getSelectionProvider());
	propertiesAction = new PropertyDialogAction(new IShellProvider() {
		public Shell getShell() {
			return aSite.getViewSite().getShell();
		}
	},delegateSelectionProvider);
	propertiesAction.setText("属性");
	propertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES); 
}
 
Example #17
Source File: EditActionGroup.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
protected void makeActions() {
	clipboard = new Clipboard(shell.getDisplay());

	pasteAction = new PasteAction(shell, clipboard);
	pasteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_pasteAction);
	ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
	pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
	pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
	pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);

	copyAction = new CopyAction(shell, clipboard, pasteAction);
	copyAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_copyAction);
	copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
	copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
	copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);

	IShellProvider sp = new IShellProvider() {
		public Shell getShell() {
			return shell;
		}
	};

	deleteAction = new DeleteResourceAndCloseEditorAction(sp);
	deleteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_deleteAction);
	deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
	deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
	deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
}
 
Example #18
Source File: RepeatedContentAssistProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String getStatusMessage() {
	String binding = "<binding>";
	if (workbench != null) {
		IBindingService bindingService = workbench.getAdapter(IBindingService.class);
		binding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST);
	}
	String category = getModeAwareProposalProvider().getNextCategory();
	return binding + " to show " + category;
}
 
Example #19
Source File: CalcitePane.java    From mat-calcite-plugin with Apache License 2.0 5 votes vote down vote up
private void installUndoRedoSupport() {
	IUndoContext undoContext = ((IUndoManagerExtension) queryViewer.getUndoManager()).getUndoContext();

	UndoActionHandler undoAction = new UndoActionHandler(getSite(), undoContext);
	RedoActionHandler redoAction = new RedoActionHandler(getSite(), undoContext);

	undoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO);
	redoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO);

	IActionBars actionBars = getEditor().getEditorSite().getActionBars();
	actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
	actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);

	actionBars.updateActionBars();
}
 
Example #20
Source File: PropertiesActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void init(final ICommonActionExtensionSite aSite) {
	
	delegateSelectionProvider = new DelegateSelectionProvider( aSite.getViewSite().getSelectionProvider());
	propertiesAction = new PropertyDialogAction(new IShellProvider() {
		public Shell getShell() {
			return aSite.getViewSite().getShell();
		}
	},delegateSelectionProvider);
	propertiesAction.setText("属性");
	propertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES); 
}
 
Example #21
Source File: EditActionGroup.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected void makeActions() {
	clipboard = new Clipboard(shell.getDisplay());

	pasteAction = new PasteAction(shell, clipboard);
	pasteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_pasteAction);
	ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
	pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
	pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
	pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);

	copyAction = new CopyAction(shell, clipboard, pasteAction);
	copyAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_copyAction);
	copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
	copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
	copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);

	IShellProvider sp = new IShellProvider() {
		public Shell getShell() {
			return shell;
		}
	};

	deleteAction = new DeleteResourceAndCloseEditorAction(sp);
	deleteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_deleteAction);
	deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
	deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
	deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
}
 
Example #22
Source File: RefactorActionGroup.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected void makeActions() {
	IShellProvider sp = new IShellProvider() {
		public Shell getShell() {
			return shell;
		}
	};

	moveAction = new MoveResourceAction(sp);
	moveAction.setText(WorkbenchNavigatorMessages.actions_RefactorActionGroup_moveAction);
	moveAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_MOVE);

	renameAction = new RenameResourceAndCloseEditorAction(sp, tree);
	renameAction.setText(WorkbenchNavigatorMessages.actions_RefactorActionGroup_renameAction);
	renameAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_RENAME);
}
 
Example #23
Source File: LangNavigatorActionProvider.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public BuildOperationsActionGroup(IViewPart viewPart) {
	super(viewPart);
	
	buildAction = new BuildAction(() -> viewPart.getSite().getShell(), 
		IncrementalProjectBuilder.INCREMENTAL_BUILD);
	buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);
}
 
Example #24
Source File: ApplicationActionBarAdvisor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void menuAboutToShow(IMenuManager manager){
	IContributionItem[] items = manager.getItems();
	for (IContributionItem iContributionItem : items) {
		if(iContributionItem instanceof ActionContributionItem) {
			ActionContributionItem aci = (ActionContributionItem) iContributionItem;		
			IAction action = aci.getAction();
			if(action instanceof RestrictedAction) {
				RestrictedAction ra = (RestrictedAction) aci.getAction();
				ra.reflectRight();
				continue;
			}
			String id = action.getActionDefinitionId();
			if(id==null) {
				continue;
			}
			switch (id) {
			case IWorkbenchCommandConstants.FILE_EXIT:
				action.setEnabled(CoreHub.acl.request(AccessControlDefaults.AC_EXIT));
				break;
			case IWorkbenchCommandConstants.WINDOW_NEW_WINDOW:
				action.setEnabled(CoreHub.acl.request(AccessControlDefaults.AC_NEWWINDOW));
				break;
			case IWorkbenchCommandConstants.HELP_ABOUT:
				action.setEnabled(CoreHub.acl.request(AccessControlDefaults.AC_ABOUT));
				break;
			case IWorkbenchCommandConstants.WINDOW_PREFERENCES:
				action.setEnabled(CoreHub.acl.request(AccessControlDefaults.AC_PREFS));
				break;
			default:
				break;
			}
		}
	}
}
 
Example #25
Source File: RefreshElementAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the action to refresh a single element in the call hierarchy.
 *
 * @param viewer the call hierarchy viewer
 */
public RefreshElementAction(CallHierarchyViewer viewer) {
	fViewer= viewer;
	setText(CallHierarchyMessages.RefreshSingleElementAction_text);
	setToolTipText(CallHierarchyMessages.RefreshSingleElementAction_tooltip);
	setDescription(CallHierarchyMessages.RefreshSingleElementAction_description);
	JavaPluginImages.setLocalImageDescriptors(this, "refresh.gif");//$NON-NLS-1$
	setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_REFRESH_SINGLE_ELEMENT_ACTION);
	setEnabled(true);
}
 
Example #26
Source File: LocationCopyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
LocationCopyAction(IViewSite viewSite, Clipboard clipboard, LocationViewer locationViewer) {
	fClipboard= clipboard;
	fViewSite= viewSite;
	fLocationViewer= locationViewer;

	setText(CallHierarchyMessages.LocationCopyAction_copy);
	setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
	setEnabled(!fLocationViewer.getSelection().isEmpty());

	locationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			setEnabled(! event.getSelection().isEmpty());
		}
	});
}
 
Example #27
Source File: AbstractInfoView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the actions and action groups for this view.
 */
protected void createActions() {
	fGotoInputAction= new GotoInputAction(this);
	fGotoInputAction.setEnabled(false);
	fCopyToClipboardAction= new CopyToClipboardAction(getViewSite());

	fToggleLinkAction= new LinkAction();
	fToggleLinkAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR);
	fToggleLinkAction.updateLinkImage(false);

	ISelectionProvider provider= getSelectionProvider();
	if (provider != null)
		provider.addSelectionChangedListener(fCopyToClipboardAction);
}
 
Example #28
Source File: OpenViewActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String getShowInMenuLabel() {
	String keyBinding= null;

	IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
	if (bindingService != null)
		keyBinding= bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU);

	if (keyBinding == null)
		keyBinding= ""; //$NON-NLS-1$

	return ActionMessages.OpenViewActionGroup_showInAction_label + '\t' + keyBinding;
}
 
Example #29
Source File: OpenViewActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createSiteActions(IWorkbenchSite site, ISelectionProvider specialProvider) {
	fOpenImplementation= new OpenImplementationAction(site);
	fOpenImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_IMPLEMENTATION);
	fOpenImplementation.setSpecialSelectionProvider(specialProvider);
	
	fOpenSuperImplementation= new OpenSuperImplementationAction(site);
	fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
	fOpenSuperImplementation.setSpecialSelectionProvider(specialProvider);

	fOpenAttachedJavadoc= new OpenAttachedJavadocAction(site);
	fOpenAttachedJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_ATTACHED_JAVADOC);
	fOpenAttachedJavadoc.setSpecialSelectionProvider(specialProvider);

	fOpenTypeHierarchy= new OpenTypeHierarchyAction(site);
	fOpenTypeHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
	fOpenTypeHierarchy.setSpecialSelectionProvider(specialProvider);

	fOpenCallHierarchy= new OpenCallHierarchyAction(site);
	fOpenCallHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
	fOpenCallHierarchy.setSpecialSelectionProvider(specialProvider);

	ISelectionProvider provider= specialProvider != null ? specialProvider : site.getSelectionProvider();

	fOpenPropertiesDialog= new PropertyDialogAction(site, provider);
	fOpenPropertiesDialog.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);

	initialize(provider);
}
 
Example #30
Source File: CCPActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new <code>CCPActionGroup</code>. The group requires that the selection provided by
 * the given selection provider is of type {@link IStructuredSelection}.
 * 
 * @param site the site that will own the action group.
 * @param specialSelectionProvider the selection provider used instead of the sites selection
 *            provider.
 * @param includeOnlyCopyActions <code>true</code> if the group only included the copy actions,
 *            <code>false</code> otherwise
 * @since 3.7
 */
private CCPActionGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider, boolean includeOnlyCopyActions) {
	fSelectionProvider= specialSelectionProvider == null ? site.getSelectionProvider() : specialSelectionProvider;

	fCopyAction= new CopyToClipboardAction(site);
	fCopyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);

	fCopyQualifiedNameAction= new CopyQualifiedNameAction(site);
	fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.ACTION_DEFINITION_ID);


	if (!includeOnlyCopyActions) {
		fPasteAction= new PasteAction(site);
		fPasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
		fDeleteAction= new DeleteAction(site);
		fDeleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
		fCutAction= new CutAction(site);
		fCutAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
		fActions= new SelectionDispatchAction[] { fCutAction, fCopyAction, fCopyQualifiedNameAction, fPasteAction, fDeleteAction };
	} else {
		fPasteAction= null;
		fDeleteAction= null;
		fCutAction= null;
		fActions= new SelectionDispatchAction[] { fCopyAction, fCopyQualifiedNameAction };
	}

	if (specialSelectionProvider != null) {
		for (int i= 0; i < fActions.length; i++) {
			fActions[i].setSpecialSelectionProvider(specialSelectionProvider);
		}
	}

	registerActionsAsSelectionChangeListeners();
}