Search in sources :

Example 36 with IContextService

use of org.eclipse.ui.contexts.IContextService in project titan.EclipsePlug-ins by eclipse.

the class TTCN3Editor method createSourceViewer.

@Override
protected ISourceViewer createSourceViewer(final Composite parent, final IVerticalRuler ruler, final int styles) {
    ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
    getSourceViewerDecorationSupport(viewer);
    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(foldingListener);
    // Context setting is placed here because getEditorSite() must
    // be called after the editor is initialized.
    IContextService contextService = (IContextService) getEditorSite().getService(IContextService.class);
    // As the service is retrieved from the editor instance it will
    // be active only within the editor.
    contextService.activateContext(EDITOR_SCOPE);
    return viewer;
}
Also used : IContextService(org.eclipse.ui.contexts.IContextService) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ProjectionViewer(org.eclipse.jface.text.source.projection.ProjectionViewer)

Example 37 with IContextService

use of org.eclipse.ui.contexts.IContextService in project erlide_eclipse by erlang.

the class ErlangOutlinePage method createControl.

@Override
public void createControl(final Composite parent) {
    final Tree tree = new Tree(parent, SWT.MULTI);
    fOutlineViewer = new TreeViewer(tree);
    fOutlineViewer.setAutoExpandLevel(0);
    fOutlineViewer.setUseHashlookup(true);
    fOutlineViewer.setContentProvider(fEditor.createOutlineContentProvider());
    fOutlineViewer.setLabelProvider(fEditor.createOutlineLabelProvider());
    fOutlineViewer.addPostSelectionChangedListener(this);
    fOutlineViewer.setInput(fModule);
    final IPageSite site = getSite();
    fOpenAndLinkWithEditorHelper = new OpenAndLinkWithEditorHelper(fOutlineViewer, fEditor, site.getPage());
    final IContextService service = site.getService(IContextService.class);
    if (service != null) {
        service.activateContext("org.erlide.ui.erlangOutlineAndNavigatorScope");
    }
    final MenuManager manager = new MenuManager();
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(this::contextMenuAboutToShow);
    final Menu menu = manager.createContextMenu(tree);
    tree.setMenu(menu);
    site.registerContextMenu(ErlangCore.PLUGIN_ID + ".outline", manager, fOutlineViewer);
    fActionGroups = new CompositeActionGroup(new ActionGroup[] { new ErlangSearchActionGroup(this) });
    // register global actions
    final IActionBars actionBars = site.getActionBars();
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fEditor.getAction(ITextEditorActionConstants.UNDO));
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fEditor.getAction(ITextEditorActionConstants.REDO));
    fActionGroups.fillActionBars(actionBars);
    registerToolbarActions(actionBars);
    final IHandlerService handlerService = site.getService(IHandlerService.class);
    if (handlerService != null) {
        handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
    }
    fPartListener = new IPartListener() {

        @Override
        public void partOpened(final IWorkbenchPart part) {
            // JC borde filter-metoden ovan r�cka?
            addFilters();
        }

        @Override
        public void partDeactivated(final IWorkbenchPart part) {
        }

        @Override
        public void partClosed(final IWorkbenchPart part) {
        }

        @Override
        public void partBroughtToTop(final IWorkbenchPart part) {
        }

        @Override
        public void partActivated(final IWorkbenchPart part) {
            addFilters();
        }
    };
    getSite().getPage().addPartListener(fPartListener);
}
Also used : CompositeActionGroup(org.erlide.ui.actions.CompositeActionGroup) ErlangSearchActionGroup(org.erlide.ui.actions.ErlangSearchActionGroup) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IPartListener(org.eclipse.ui.IPartListener) IPageSite(org.eclipse.ui.part.IPageSite) IHandlerService(org.eclipse.ui.handlers.IHandlerService) ActionGroup(org.eclipse.ui.actions.ActionGroup) ErlangSearchActionGroup(org.erlide.ui.actions.ErlangSearchActionGroup) CompositeActionGroup(org.erlide.ui.actions.CompositeActionGroup) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) IContextService(org.eclipse.ui.contexts.IContextService) Menu(org.eclipse.swt.widgets.Menu) ActionHandler(org.eclipse.jface.commands.ActionHandler) IActionBars(org.eclipse.ui.IActionBars)

Example 38 with IContextService

use of org.eclipse.ui.contexts.IContextService in project erlide_eclipse by erlang.

the class ConsolePageParticipant method activated.

@Override
public void activated() {
    // add EOF submissions
    final IPageSite site = fPage.getSite();
    final IHandlerService handlerService = site.getService(IHandlerService.class);
    final IContextService contextService = site.getService(IContextService.class);
    if (handlerService == null || contextService == null) {
        return;
    }
    fActivatedContext = contextService.activateContext(ConsolePageParticipant.fContextId);
    fActivatedHandler = handlerService.activateHandler("org.eclipse.debug.ui.commands.eof", // $NON-NLS-1$
    fEOFHandler);
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) IPageSite(org.eclipse.ui.part.IPageSite) IContextService(org.eclipse.ui.contexts.IContextService)

Example 39 with IContextService

use of org.eclipse.ui.contexts.IContextService in project erlide_eclipse by erlang.

the class ConsolePageParticipant method deactivated.

@Override
public void deactivated() {
    // remove EOF submissions
    final IPageSite site = fPage.getSite();
    final IHandlerService handlerService = site.getService(IHandlerService.class);
    final IContextService contextService = site.getService(IContextService.class);
    if (handlerService == null || contextService == null) {
        return;
    }
    handlerService.deactivateHandler(fActivatedHandler);
    contextService.deactivateContext(fActivatedContext);
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) IPageSite(org.eclipse.ui.part.IPageSite) IContextService(org.eclipse.ui.contexts.IContextService)

Aggregations

IContextService (org.eclipse.ui.contexts.IContextService)39 IContextActivation (org.eclipse.ui.contexts.IContextActivation)8 IHandlerService (org.eclipse.ui.handlers.IHandlerService)8 FocusEvent (org.eclipse.swt.events.FocusEvent)7 FocusListener (org.eclipse.swt.events.FocusListener)7 SQLEditorBase (org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase)6 INavigatorModelView (org.jkiss.dbeaver.ui.navigator.INavigatorModelView)6 ActionHandler (org.eclipse.jface.commands.ActionHandler)5 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)5 ProjectionViewer (org.eclipse.jface.text.source.projection.ProjectionViewer)4 DBSDataContainer (org.jkiss.dbeaver.model.struct.DBSDataContainer)4 ResultSetViewer (org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer)4 EntityEditor (org.jkiss.dbeaver.ui.editors.entity.EntityEditor)4 SQLEditor (org.jkiss.dbeaver.ui.editors.sql.SQLEditor)4 IAction (org.eclipse.jface.action.IAction)3 Shell (org.eclipse.swt.widgets.Shell)3 IPageSite (org.eclipse.ui.part.IPageSite)3 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IExecutionListener (org.eclipse.core.commands.IExecutionListener)2