Search in sources :

Example 66 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project webtools.sourceediting by eclipse.

the class StructuredTextEditor method createActions.

protected void createActions() {
    super.createActions();
    ResourceBundle resourceBundle = SSEUIMessages.getResourceBundle();
    IWorkbenchHelpSystem helpSystem = SSEUIPlugin.getDefault().getWorkbench().getHelpSystem();
    // TextView Action - moving the selected text to
    // the clipboard
    // override the cut/paste/delete action to make
    // them run on read-only
    // files
    // $NON-NLS-1$
    Action action = new TextOperationAction(resourceBundle, "Editor_Cut_", this, ITextOperationTarget.CUT);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.CUT);
    setAction(ITextEditorActionConstants.CUT, action);
    helpSystem.setHelp(action, IAbstractTextEditorHelpContextIds.CUT_ACTION);
    // TextView Action - inserting the clipboard
    // content at the current
    // position
    // override the cut/paste/delete action to make
    // them run on read-only
    // files
    // $NON-NLS-1$
    action = new TextOperationAction(resourceBundle, "Editor_Paste_", this, ITextOperationTarget.PASTE);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE);
    setAction(ITextEditorActionConstants.PASTE, action);
    helpSystem.setHelp(action, IAbstractTextEditorHelpContextIds.PASTE_ACTION);
    // TextView Action - deleting the selected text or
    // if selection is
    // empty the character at the right of the current
    // position
    // override the cut/paste/delete action to make
    // them run on read-only
    // files
    // $NON-NLS-1$
    action = new TextOperationAction(resourceBundle, "Editor_Delete_", this, ITextOperationTarget.DELETE);
    action.setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE);
    setAction(ITextEditorActionConstants.DELETE, action);
    helpSystem.setHelp(action, IAbstractTextEditorHelpContextIds.DELETE_ACTION);
    // SourceView Action - requesting content assist to
    // show completetion
    // proposals for the current insert position
    action = new ContentAssistAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS + UNDERSCORE, this);
    helpSystem.setHelp(action, IHelpContextIds.CONTMNU_CONTENTASSIST_HELPID);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    setAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, action);
    markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, true);
    // SourceView Action - requesting content assist to
    // show the content
    // information for the current insert position
    action = new TextOperationAction(SSEUIMessages.getResourceBundle(), StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION + UNDERSCORE, this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
    setAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION, action);
    markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION, true);
    // StructuredTextViewer Action - requesting format
    // of the whole
    // document
    action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT + UNDERSCORE, this, StructuredTextViewer.FORMAT_DOCUMENT);
    helpSystem.setHelp(action, IHelpContextIds.CONTMNU_FORMAT_DOC_HELPID);
    action.setActionDefinitionId(ActionDefinitionIds.FORMAT_DOCUMENT);
    setAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, action);
    markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, true);
    markAsSelectionDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, true);
    // StructuredTextViewer Action - requesting format
    // of the active
    // elements
    action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS + UNDERSCORE, this, StructuredTextViewer.FORMAT_ACTIVE_ELEMENTS);
    helpSystem.setHelp(action, IHelpContextIds.CONTMNU_FORMAT_ELEMENTS_HELPID);
    action.setActionDefinitionId(ActionDefinitionIds.FORMAT_ACTIVE_ELEMENTS);
    setAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, action);
    markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, true);
    markAsSelectionDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, true);
    // StructuredTextEditor Action - add breakpoints (falling back to the
    // current double-click if they can't be added)
    action = new ToggleBreakpointAction(this, getVerticalRuler());
    setAction(ActionDefinitionIds.TOGGLE_BREAKPOINTS, action);
    // StructuredTextEditor Action - manage breakpoints
    action = new ManageBreakpointAction(this, getVerticalRuler());
    setAction(ActionDefinitionIds.MANAGE_BREAKPOINTS, action);
    // StructuredTextEditor Action - edit breakpoints
    action = new EditBreakpointAction(this, getVerticalRuler());
    setAction(ActionDefinitionIds.EDIT_BREAKPOINTS, action);
    // StructuredTextViewer Action - open file on selection
    action = new OpenHyperlinkAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE + UNDERSCORE, this, getSourceViewer());
    action.setActionDefinitionId(ActionDefinitionIds.OPEN_FILE);
    setAction(StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE, action);
    computeAndSetDoubleClickAction();
    // add handlers to handler service
    IHandlerService handlerService = getSite().getService(IHandlerService.class);
    if (handlerService != null) {
        IHandler gotoHandler = new GotoMatchingBracketHandler();
        handlerService.activateHandler(ActionDefinitionIds.GOTO_MATCHING_BRACKET, gotoHandler);
        fOutlineHandler = new QuickOutlineHandler();
        handlerService.activateHandler(ActionDefinitionIds.SHOW_OUTLINE, fOutlineHandler);
        IHandler toggleCommentHandler = new ToggleLineCommentHandler();
        handlerService.activateHandler(ActionDefinitionIds.TOGGLE_COMMENT, toggleCommentHandler);
        IHandler addCommentBlockHandler = new AddBlockCommentHandler();
        handlerService.activateHandler(ActionDefinitionIds.ADD_BLOCK_COMMENT, addCommentBlockHandler);
        IHandler removeCommentBlockHandler = new RemoveBlockCommentHandler();
        handlerService.activateHandler(ActionDefinitionIds.REMOVE_BLOCK_COMMENT, removeCommentBlockHandler);
    }
    fShowPropertiesAction = new ShowPropertiesAction(getEditorPart(), getSelectionProvider());
    fFoldingGroup = new FoldingActionGroup(this, getSourceViewer());
}
Also used : AddBlockCommentHandler(org.eclipse.wst.sse.ui.internal.handlers.AddBlockCommentHandler) RemoveBlockCommentHandler(org.eclipse.wst.sse.ui.internal.handlers.RemoveBlockCommentHandler) ContentAssistAction(org.eclipse.ui.texteditor.ContentAssistAction) ToggleBreakpointAction(org.eclipse.wst.sse.ui.internal.debug.ToggleBreakpointAction) IAction(org.eclipse.jface.action.IAction) EditBreakpointAction(org.eclipse.wst.sse.ui.internal.debug.EditBreakpointAction) OpenHyperlinkAction(org.eclipse.wst.sse.ui.internal.hyperlink.OpenHyperlinkAction) Action(org.eclipse.jface.action.Action) BreakpointRulerAction(org.eclipse.wst.sse.ui.internal.debug.BreakpointRulerAction) ShowPropertiesAction(org.eclipse.wst.sse.ui.internal.properties.ShowPropertiesAction) ManageBreakpointAction(org.eclipse.wst.sse.ui.internal.debug.ManageBreakpointAction) TextOperationAction(org.eclipse.ui.texteditor.TextOperationAction) EditBreakpointAction(org.eclipse.wst.sse.ui.internal.debug.EditBreakpointAction) ShowPropertiesAction(org.eclipse.wst.sse.ui.internal.properties.ShowPropertiesAction) TextOperationAction(org.eclipse.ui.texteditor.TextOperationAction) ToggleLineCommentHandler(org.eclipse.wst.sse.ui.internal.handlers.ToggleLineCommentHandler) IWorkbenchHelpSystem(org.eclipse.ui.help.IWorkbenchHelpSystem) OpenHyperlinkAction(org.eclipse.wst.sse.ui.internal.hyperlink.OpenHyperlinkAction) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ContentAssistAction(org.eclipse.ui.texteditor.ContentAssistAction) ManageBreakpointAction(org.eclipse.wst.sse.ui.internal.debug.ManageBreakpointAction) IHandler(org.eclipse.core.commands.IHandler) ResourceBundle(java.util.ResourceBundle) QuickOutlineHandler(org.eclipse.wst.sse.ui.internal.quickoutline.QuickOutlineHandler) ToggleBreakpointAction(org.eclipse.wst.sse.ui.internal.debug.ToggleBreakpointAction)

Example 67 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project eclipse-integration-commons by spring-projects.

the class QuickSearchDialog method close.

/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.jface.window.Window#close()
	 */
public boolean close() {
    this.progressJob.cancel();
    this.progressJob = null;
    // this.refreshProgressMessageJob.cancel();
    if (showViewHandler != null) {
        IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
        service.deactivateHandler(showViewHandler);
        showViewHandler.getHandler().dispose();
        showViewHandler = null;
    }
    if (menuManager != null)
        menuManager.dispose();
    if (contextMenuManager != null)
        contextMenuManager.dispose();
    storeDialog(getDialogSettings());
    if (searcher != null) {
        searcher.cancel();
    }
    return super.close();
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService)

Example 68 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project eclipse-integration-commons by spring-projects.

the class QuickSearchDialog method createViewMenu.

private void createViewMenu(Composite parent) {
    toolBar = new ToolBar(parent, SWT.FLAT);
    toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.END;
    toolBar.setLayoutData(data);
    toolBar.addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent e) {
            showViewMenu();
        }
    });
    toolItem.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
    toolItem.setToolTipText(WorkbenchMessages.FilteredItemsSelectionDialog_menu);
    toolItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            showViewMenu();
        }
    });
    menuManager = new MenuManager();
    fillViewMenu(menuManager);
    IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
    IHandler handler = new AbstractHandler() {

        public Object execute(ExecutionEvent event) {
            showViewMenu();
            return null;
        }
    };
    showViewHandler = service.activateHandler(IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU, handler, new ActiveShellExpression(getShell()));
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) AbstractHandler(org.eclipse.core.commands.AbstractHandler) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IHandler(org.eclipse.core.commands.IHandler) ActiveShellExpression(org.eclipse.ui.ActiveShellExpression) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 69 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project eclipse-integration-commons by spring-projects.

the class MultiPageDashboardEditor method getConfiguredDiscoveryWizardCommand.

/**
 * Copied from TasksUiInternal to avoid initialization of
 * org.eclipse.mylyn.tasks.ui.
 */
private static Command getConfiguredDiscoveryWizardCommand() {
    ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    final Command discoveryWizardCommand = service.getCommand(// $NON-NLS-1$
    "org.eclipse.mylyn.discovery.ui.discoveryWizardCommand");
    if (discoveryWizardCommand != null) {
        IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
        EvaluationContext evaluationContext = createDiscoveryWizardEvaluationContext(handlerService);
        // update enabled state in case something has changed (ProxyHandler
        // caches state)
        discoveryWizardCommand.setEnabled(evaluationContext);
    }
    return discoveryWizardCommand;
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) Command(org.eclipse.core.commands.Command) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 70 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project org.csstudio.display.builder by kasemir.

the class SendToElogAction method makeLogEntry.

/**
 * Make a logbook entry.
 */
public void makeLogEntry() {
    try {
        final Attachment image_attachment = createImageAttachment();
        final String text = Messages.LogentryDefaultTitle + "\n" + Messages.LogentryDefaultBody;
        final LogEntryBuilder entry = LogEntryBuilder.withText(text).attach(AttachmentBuilder.attachment(image_attachment));
        // get the command from plugin.xml
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        List<LogEntryBuilder> logList = new ArrayList<LogEntryBuilder>();
        logList.add(entry);
        Event event = new Event();
        event.data = logList;
        // execute the command
        IHandlerService handlerService = window.getService(IHandlerService.class);
        handlerService.executeCommand(OPEN_LOGENTRY_BUILDER_DIALOG_ID, event);
    } catch (Exception e) {
        MessageDialog.openError(null, "Logbook Error", "Failed to make logbook entry: \n" + e.getMessage());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ArrayList(java.util.ArrayList) Event(org.eclipse.swt.widgets.Event) Attachment(org.csstudio.logbook.Attachment) LogEntryBuilder(org.csstudio.logbook.LogEntryBuilder)

Aggregations

IHandlerService (org.eclipse.ui.handlers.IHandlerService)102 ActionHandler (org.eclipse.jface.commands.ActionHandler)44 Action (org.eclipse.jface.action.Action)41 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)25 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)18 Command (org.eclipse.core.commands.Command)17 ICommandService (org.eclipse.ui.commands.ICommandService)17 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)15 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 AbstractHandler (org.eclipse.core.commands.AbstractHandler)10 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 IHandler (org.eclipse.core.commands.IHandler)8 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)8 ArrayList (java.util.ArrayList)7 ExecutionException (org.eclipse.core.commands.ExecutionException)7 IAction (org.eclipse.jface.action.IAction)7 IContextService (org.eclipse.ui.contexts.IContextService)7