Search in sources :

Example 26 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project dbeaver by serge-rider.

the class SimpleCommandContext method refreshCommandState.

protected void refreshCommandState() {
    ICommandService commandService = DBeaverUI.getActiveWorkbenchWindow().getService(ICommandService.class);
    if (commandService != null) {
        commandService.refreshElements(IWorkbenchCommandConstants.EDIT_UNDO, null);
        commandService.refreshElements(IWorkbenchCommandConstants.EDIT_REDO, null);
    }
}
Also used : ICommandService(org.eclipse.ui.commands.ICommandService)

Example 27 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project dbeaver by serge-rider.

the class WorkbenchContextListener method listenWindowEvents.

private void listenWindowEvents(IWorkbenchWindow window) {
    window.addPageListener(this);
    for (IWorkbenchPage page : window.getPages()) {
        page.addPartListener(this);
    }
    if (commandExecutionListener == null) {
        final ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
        if (commandService != null) {
            commandExecutionListener = new CommandExecutionListener();
            commandService.addExecutionListener(commandExecutionListener);
        }
    }
}
Also used : ICommandService(org.eclipse.ui.commands.ICommandService)

Example 28 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project eclipse.platform.text by eclipse.

the class IncrementalFindTarget method uninstall.

/**
 * Uninstalls itself. I.e. removes all listeners installed in <code>install</code>.
 */
private void uninstall() {
    fTextViewer.removeTextListener(this);
    ISelectionProvider selectionProvider = fTextViewer.getSelectionProvider();
    if (selectionProvider != null)
        selectionProvider.removeSelectionChangedListener(this);
    StyledText text = fTextViewer.getTextWidget();
    if (text != null) {
        text.removeMouseListener(this);
        text.removeFocusListener(this);
    }
    if (fTextViewer instanceof ITextViewerExtension) {
        ((ITextViewerExtension) fTextViewer).removeVerifyKeyListener(this);
    } else {
        if (text != null)
            text.removeVerifyKeyListener(this);
    }
    ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    if (commandService != null)
        commandService.removeExecutionListener(this);
    fInstalled = false;
}
Also used : ITextViewerExtension(org.eclipse.jface.text.ITextViewerExtension) StyledText(org.eclipse.swt.custom.StyledText) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 29 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project eclipse.platform.text by eclipse.

the class CompoundEditExitStrategy method addListeners.

private void addListeners(ITextViewer viewer) {
    fWidgetEventSource = viewer.getTextWidget();
    if (fWidgetEventSource != null) {
        fWidgetEventSource.addVerifyKeyListener(fEventListener);
        fWidgetEventSource.addMouseListener(fEventListener);
        fWidgetEventSource.addFocusListener(fEventListener);
    }
    ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    if (commandService != null)
        commandService.addExecutionListener(fEventListener);
}
Also used : ICommandService(org.eclipse.ui.commands.ICommandService)

Example 30 with ICommandService

use of org.eclipse.ui.commands.ICommandService in project eclipse.platform.text by eclipse.

the class CompoundEditExitStrategy method removeListeners.

private void removeListeners() {
    ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    if (commandService != null)
        commandService.removeExecutionListener(fEventListener);
    if (fWidgetEventSource != null) {
        fWidgetEventSource.removeFocusListener(fEventListener);
        fWidgetEventSource.removeMouseListener(fEventListener);
        fWidgetEventSource.removeVerifyKeyListener(fEventListener);
        fWidgetEventSource = null;
    }
}
Also used : ICommandService(org.eclipse.ui.commands.ICommandService)

Aggregations

ICommandService (org.eclipse.ui.commands.ICommandService)38 Command (org.eclipse.core.commands.Command)24 IHandlerService (org.eclipse.ui.handlers.IHandlerService)8 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)7 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)7 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)6 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)6 ExecutionException (org.eclipse.core.commands.ExecutionException)4 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)4 IEvaluationService (org.eclipse.ui.services.IEvaluationService)4 HashMap (java.util.HashMap)3 NotEnabledException (org.eclipse.core.commands.NotEnabledException)3 NotHandledException (org.eclipse.core.commands.NotHandledException)3 State (org.eclipse.core.commands.State)3 ISelection (org.eclipse.jface.viewers.ISelection)3 StyledText (org.eclipse.swt.custom.StyledText)3 Composite (org.eclipse.swt.widgets.Composite)3 Test (org.junit.Test)3 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)2 IHandler (org.eclipse.core.commands.IHandler)2