Search in sources :

Example 1 with IPageSite

use of org.eclipse.ui.part.IPageSite 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(new IMenuListener() {

        @Override
        public void menuAboutToShow(final IMenuManager m) {
            // recursive loop?
            // menuAboutToShow(m);
            contextMenuAboutToShow(m);
        }
    });
    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) IMenuListener(org.eclipse.jface.action.IMenuListener) 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) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ActionHandler(org.eclipse.jface.commands.ActionHandler) IActionBars(org.eclipse.ui.IActionBars)

Example 2 with IPageSite

use of org.eclipse.ui.part.IPageSite 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 3 with IPageSite

use of org.eclipse.ui.part.IPageSite 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)

Example 4 with IPageSite

use of org.eclipse.ui.part.IPageSite in project mylyn.docs by eclipse.

the class MarkupEditorOutline method createControl.

@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    TreeViewer viewer = getTreeViewer();
    viewer.setUseHashlookup(true);
    viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    viewer.setContentProvider(new BaseWorkbenchContentProvider());
    viewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    viewer.setInput(editor.getOutlineModel());
    viewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent event) {
            revealInEditor(event.getSelection(), true);
        }
    });
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            revealInEditor(event.getSelection(), false);
        }
    });
    viewer.expandAll();
    new ToolTip(viewer.getControl(), ToolTip.RECREATE, false) {

        @Override
        protected Composite createToolTipContentArea(Event event, Composite parent) {
            Composite comp = new Composite(parent, SWT.NONE);
            comp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
            GridLayout gl = new GridLayout(1, false);
            gl.marginBottom = 2;
            gl.marginTop = 2;
            gl.marginHeight = 0;
            gl.marginWidth = 0;
            gl.marginLeft = 2;
            gl.marginRight = 2;
            gl.verticalSpacing = 1;
            comp.setLayout(gl);
            Object tipItem = getToolTipItem(new Point(event.x, event.y));
            if (tipItem instanceof OutlineItem) {
                OutlineItem outlineItem = (OutlineItem) tipItem;
                Label label = new Label(comp, SWT.WRAP);
                label.setBackground(comp.getBackground());
                label.setText(outlineItem.getTooltip());
            }
            return comp;
        }

        @Override
        protected boolean shouldCreateToolTip(Event event) {
            final Object eventItem = getToolTipItem(new Point(event.x, event.y));
            boolean shouldCreate = eventItem != null && eventItem instanceof OutlineItem && super.shouldCreateToolTip(event);
            if (!shouldCreate) {
                hide();
            }
            return shouldCreate;
        }

        protected Object getToolTipItem(Point point) {
            TreeItem item = ((Tree) getTreeViewer().getControl()).getItem(point);
            if (item != null) {
                return item.getData();
            }
            return null;
        }
    };
    IPageSite site = getSite();
    site.setSelectionProvider(viewer);
    configureActionBars(site);
    // $NON-NLS-1$
    MenuManager manager = new MenuManager("#PopUp");
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuManager) {
            contextMenuAboutToShow(menuManager);
        }
    });
    viewer.getTree().setMenu(manager.createContextMenu(viewer.getTree()));
    // $NON-NLS-1$
    site.registerContextMenu(MarkupEditor.ID + ".outlineContextMenu", manager, viewer);
    configureDnd();
    configureActions();
}
Also used : ToolTip(org.eclipse.jface.window.ToolTip) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) IPageSite(org.eclipse.ui.part.IPageSite) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Point(org.eclipse.swt.graphics.Point) IMenuListener(org.eclipse.jface.action.IMenuListener) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridLayout(org.eclipse.swt.layout.GridLayout) BaseWorkbenchContentProvider(org.eclipse.ui.model.BaseWorkbenchContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) OpenEvent(org.eclipse.jface.viewers.OpenEvent) Tree(org.eclipse.swt.widgets.Tree) IMenuManager(org.eclipse.jface.action.IMenuManager) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Aggregations

IPageSite (org.eclipse.ui.part.IPageSite)4 IContextService (org.eclipse.ui.contexts.IContextService)3 IHandlerService (org.eclipse.ui.handlers.IHandlerService)3 IMenuListener (org.eclipse.jface.action.IMenuListener)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 MenuManager (org.eclipse.jface.action.MenuManager)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 Tree (org.eclipse.swt.widgets.Tree)2 ActionHandler (org.eclipse.jface.commands.ActionHandler)1 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)1 IOpenListener (org.eclipse.jface.viewers.IOpenListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 OpenEvent (org.eclipse.jface.viewers.OpenEvent)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ToolTip (org.eclipse.jface.window.ToolTip)1 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)1 Point (org.eclipse.swt.graphics.Point)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Event (org.eclipse.swt.widgets.Event)1