Search in sources :

Example 11 with IContextService

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

the class TTCNPPEditor 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 12 with IContextService

use of org.eclipse.ui.contexts.IContextService in project webtools.servertools by eclipse.

the class ServersView method createPartControl.

/**
 * createPartControl method comment.
 *
 * @param parent a parent composite
 */
public void createPartControl(Composite parent) {
    treeTable = new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    treeTable.setHeaderVisible(true);
    treeTable.setLinesVisible(false);
    treeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    treeTable.setFont(parent.getFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(treeTable, ContextIds.VIEW_SERVERS);
    // add columns
    TreeColumn column = new TreeColumn(treeTable, SWT.SINGLE);
    column.setText(Messages.viewServer);
    column.setWidth(cols[0]);
    column.addSelectionListener(getHeaderListener(0));
    treeTable.setSortColumn(column);
    treeTable.setSortDirection(SWT.UP);
    TreeColumn column2 = new TreeColumn(treeTable, SWT.SINGLE);
    column2.setText(Messages.viewState);
    column2.setWidth(cols[1]);
    column2.addSelectionListener(getHeaderListener(1));
    TreeColumn column3 = new TreeColumn(treeTable, SWT.SINGLE);
    column3.setText(Messages.viewStatus);
    column3.setWidth(cols[2]);
    column3.addSelectionListener(getHeaderListener(2));
    IContextService contextSupport = (IContextService) getSite().getService(IContextService.class);
    contextSupport.activateContext(SERVERS_VIEW_CONTEXT);
    deferInitialization();
}
Also used : GridData(org.eclipse.swt.layout.GridData) IContextService(org.eclipse.ui.contexts.IContextService)

Example 13 with IContextService

use of org.eclipse.ui.contexts.IContextService in project webtools.servertools by eclipse.

the class ServersView2 method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // Add PageBook as parent composite
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    book = new PageBook(parent, SWT.NONE);
    super.createPartControl(book);
    // Main page for the Servers tableViewer
    mainPage = getCommonViewer().getControl();
    // Page prompting to define a new server
    noServersPage = createDefaultPage(toolkit);
    book.showPage(mainPage);
    IContextService contextSupport = (IContextService) getSite().getService(IContextService.class);
    contextSupport.activateContext(SERVERS_VIEW_CONTEXT);
    deferInitialization();
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) PageBook(org.eclipse.ui.part.PageBook) IContextService(org.eclipse.ui.contexts.IContextService)

Example 14 with IContextService

use of org.eclipse.ui.contexts.IContextService in project netxms by netxms.

the class ObjectTab method unselected.

/**
 * Called by framework when tab is unselected.
 */
public void unselected() {
    if (context == null)
        return;
    IContextService contextService = (IContextService) getViewPart().getSite().getService(IContextService.class);
    if (contextService != null) {
        contextService.deactivateContext(context);
        context = null;
    }
}
Also used : IContextService(org.eclipse.ui.contexts.IContextService)

Example 15 with IContextService

use of org.eclipse.ui.contexts.IContextService in project webtools.sourceediting by eclipse.

the class StructuredTextEditor method createPartControl.

/**
 * {@inheritDoc}
 * <p>
 * Use StructuredTextViewerConfiguration if a viewerconfiguration has not
 * already been set. Also initialize StructuredTextViewer.
 * </p>
 *
 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
 */
public void createPartControl(Composite parent) {
    IContextService contextService = getSite().getService(IContextService.class);
    if (contextService != null)
        contextService.activateContext(EDITOR_KEYBINDING_SCOPE_ID);
    if (getSourceViewerConfiguration() == null) {
        ConfigurationAndTarget cat = createSourceViewerConfiguration();
        fViewerConfigurationTargetId = cat.getTargetId();
        StructuredTextViewerConfiguration newViewerConfiguration = cat.getConfiguration();
        setSourceViewerConfiguration(newViewerConfiguration);
    }
    super.createPartControl(parent);
    // instead of calling setInput twice, use initializeSourceViewer() to
    // handle source viewer initialization previously handled by setInput
    initializeSourceViewer();
    // update editor context menu, vertical ruler context menu, infopop
    if (getInternalModel() != null) {
        updateEditorControlsForContentType(getInternalModel().getContentTypeIdentifier());
    } else {
        updateEditorControlsForContentType(null);
    }
    // used for Show Tooltip Description
    IInformationControlCreator informationControlCreator = new IInformationControlCreator() {

        public IInformationControl createInformationControl(Shell shell) {
            boolean cutDown = false;
            int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
            return new DefaultInformationControl(shell, SWT.RESIZE | SWT.TOOL, style, new HTMLTextPresenter(cutDown));
        }
    };
    fInformationPresenter = new InformationPresenter(informationControlCreator);
    fInformationPresenter.setSizeConstraints(60, 10, true, true);
    fInformationPresenter.install(getSourceViewer());
    addReconcilingListeners(getSourceViewerConfiguration(), getTextViewer());
    fPartListener = new PartListener(this);
    getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener);
    installSemanticHighlighting();
    if (fOutlineHandler != null) {
        IInformationPresenter presenter = configureOutlinePresenter(getSourceViewer(), getSourceViewerConfiguration());
        if (presenter != null) {
            presenter.install(getSourceViewer());
            fOutlineHandler.configure(presenter);
        }
    }
    installCharacterPairing();
    ISourceViewer viewer = getSourceViewer();
    if (viewer instanceof ITextViewerExtension) {
        ((ITextViewerExtension) viewer).appendVerifyKeyListener(fPairInserter);
        fPairInserter.installCompletionListener();
    }
    if (Platform.getProduct() != null) {
        // $NON-NLS-1$);
        String viewID = Platform.getProduct().getProperty("idPerspectiveHierarchyView");
        if (viewID != null) {
            // make sure the specified view ID is known
            if (PlatformUI.getWorkbench().getViewRegistry().find(viewID) != null) {
                fShowInTargetIds = new String[] { viewID, IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_RES_NAV, IPageLayout.ID_OUTLINE };
            }
        }
    }
}
Also used : DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) Point(org.eclipse.swt.graphics.Point) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) Shell(org.eclipse.swt.widgets.Shell) ITextViewerExtension(org.eclipse.jface.text.ITextViewerExtension) HTMLTextPresenter(org.eclipse.wst.sse.ui.internal.derived.HTMLTextPresenter) IContextService(org.eclipse.ui.contexts.IContextService) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPartListener(org.eclipse.ui.IPartListener)

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