Search in sources :

Example 1 with JFaceMenuBuilder

use of org.whole.lang.e4.ui.menu.JFaceMenuBuilder in project whole by wholeplatform.

the class ModelMergeViewer method createMergeArea.

protected Control createMergeArea(Composite parent) {
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(ImportAsModelDialogFactory.class, getContext());
    IEclipseContext params = EclipseContextFactory.create();
    params.set("parent", parent);
    params.set(IImportAsModelDialogFactory.class, factory);
    viewer = ContextInjectionFactory.make(E4GraphicalViewer.class, getContext(), params);
    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateSelection(E4Utils.createSelectionBindings(event, getContext()));
        }
    });
    viewer.getControl().addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent event) {
        }

        @SuppressWarnings("unchecked")
        @Override
        public void focusGained(FocusEvent event) {
            getContext().set(IEntityPartViewer.class, viewer);
            getContext().set(ActionRegistry.class, actionRegistry);
            updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, getContext()));
        }
    });
    viewer.addPartFocusListener(new IPartFocusListener() {

        @SuppressWarnings("unchecked")
        public void focusChanged(IEntityPart oldPart, IEntityPart newPart) {
            updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, getContext()));
        }
    });
    E4KeyHandler keyHandler = new E4KeyHandler(getContext());
    keyHandler.setParent(new E4NavigationKeyHandler(getContext()));
    viewer.setKeyHandler(keyHandler);
    viewer.setEntityContents(createDefaultContents());
    getContext().set(IEntityPartViewer.class, viewer);
    actionRegistry = ContextInjectionFactory.make(ActionRegistry.class, getContext());
    actionRegistry.registerWorkbenchActions();
    getContext().set(ActionRegistry.class, actionRegistry);
    JFaceMenuBuilder uiBuilder = ContextInjectionFactory.make(JFaceMenuBuilder.class, getContext());
    contextMenuProvider = new PopupMenuProvider<IContributionItem, IMenuManager>(uiBuilder);
    viewer.setContextMenu(new ContextMenuProvider(viewer) {

        @Override
        public void buildContextMenu(IMenuManager menuManager) {
            contextMenuProvider.populate(menuManager);
        }
    });
    return parent;
}
Also used : E4GraphicalViewer(org.whole.lang.e4.ui.viewers.E4GraphicalViewer) IContributionItem(org.eclipse.jface.action.IContributionItem) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) ActionRegistry(org.whole.lang.e4.ui.actions.ActionRegistry) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) JFaceMenuBuilder(org.whole.lang.e4.ui.menu.JFaceMenuBuilder) E4KeyHandler(org.whole.lang.e4.ui.actions.E4KeyHandler) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) GridData(org.eclipse.swt.layout.GridData) E4NavigationKeyHandler(org.whole.lang.e4.ui.actions.E4NavigationKeyHandler) IMenuManager(org.eclipse.jface.action.IMenuManager) FocusListener(org.eclipse.swt.events.FocusListener) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 2 with JFaceMenuBuilder

use of org.whole.lang.e4.ui.menu.JFaceMenuBuilder in project whole by wholeplatform.

the class AbstractE4Part method configureContextMenu.

protected void configureContextMenu() {
    JFaceMenuBuilder uiBuilder = ContextInjectionFactory.make(JFaceMenuBuilder.class, context);
    contextMenuProvider = new PopupMenuProvider<IContributionItem, IMenuManager>(uiBuilder);
    viewer.setContextMenu(new ContextMenuProvider(viewer) {

        @Override
        public void buildContextMenu(IMenuManager menuManager) {
            try {
                if (!getViewer().getEditDomain().isDisabled())
                    contextMenuProvider.populate(menuManager);
            } catch (Exception e) {
                getMenu().setVisible(false);
            }
        }
    });
}
Also used : JFaceMenuBuilder(org.whole.lang.e4.ui.menu.JFaceMenuBuilder) IContributionItem(org.eclipse.jface.action.IContributionItem) IMenuManager(org.eclipse.jface.action.IMenuManager) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider)

Example 3 with JFaceMenuBuilder

use of org.whole.lang.e4.ui.menu.JFaceMenuBuilder in project whole by wholeplatform.

the class E4Dialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    if (E4Utils.isLegacyApplication())
        HandlersBehavior.registerHandlers(handlerService);
    IEclipseContext params = EclipseContextFactory.create();
    params.set("parent", parent);
    viewer = ContextInjectionFactory.make(E4GraphicalViewer.class, context, params);
    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateSelection(E4Utils.createSelectionBindings(event, context));
        }
    });
    viewer.getControl().addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent event) {
        }

        @SuppressWarnings("unchecked")
        @Override
        public void focusGained(FocusEvent event) {
            context.set(IEntityPartViewer.class, viewer);
            context.set(ActionRegistry.class, actionRegistry);
            updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, context));
        }
    });
    viewer.addPartFocusListener(new IPartFocusListener() {

        @SuppressWarnings("unchecked")
        public void focusChanged(IEntityPart oldPart, IEntityPart newPart) {
            updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, context));
            context.activateBranch();
        }
    });
    E4KeyHandler keyHandler = new E4KeyHandler(context);
    keyHandler.setParent(new E4NavigationKeyHandler(context));
    context.set(IEntityPartViewer.class, viewer);
    viewer.setKeyHandler(keyHandler);
    viewer.setEntityContents(createDefaultContents());
    actionRegistry = ContextInjectionFactory.make(ActionRegistry.class, context);
    actionRegistry.registerWorkbenchActions();
    context.set(ActionRegistry.class, actionRegistry);
    JFaceMenuBuilder uiBuilder = ContextInjectionFactory.make(JFaceMenuBuilder.class, context);
    contextMenuProvider = new PopupMenuProvider<IContributionItem, IMenuManager>(uiBuilder);
    viewer.setContextMenu(new ContextMenuProvider(viewer) {

        @Override
        public void buildContextMenu(IMenuManager menuManager) {
            contextMenuProvider.populate(menuManager);
        }
    });
    return parent;
}
Also used : E4GraphicalViewer(org.whole.lang.e4.ui.viewers.E4GraphicalViewer) IContributionItem(org.eclipse.jface.action.IContributionItem) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) ActionRegistry(org.whole.lang.e4.ui.actions.ActionRegistry) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) JFaceMenuBuilder(org.whole.lang.e4.ui.menu.JFaceMenuBuilder) E4KeyHandler(org.whole.lang.e4.ui.actions.E4KeyHandler) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) GridData(org.eclipse.swt.layout.GridData) E4NavigationKeyHandler(org.whole.lang.e4.ui.actions.E4NavigationKeyHandler) IMenuManager(org.eclipse.jface.action.IMenuManager) FocusListener(org.eclipse.swt.events.FocusListener) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 4 with JFaceMenuBuilder

use of org.whole.lang.e4.ui.menu.JFaceMenuBuilder in project whole by wholeplatform.

the class E4PaletteGraphicalPart method configureContextMenu.

@Override
protected void configureContextMenu() {
    JFaceMenuBuilder uiBuilder = ContextInjectionFactory.make(JFaceMenuBuilder.class, context);
    contextMenuProvider = new PopupMenuProvider<IContributionItem, IMenuManager>(uiBuilder) {

        @Override
        public void populate(IMenuManager menu) {
            uiBuilder.setContainer(menu);
            uiBuilder.before();
            uiBuilder.addCopyItem();
            uiBuilder.addCopyEntityPathItem();
            uiBuilder.addCopyAsImageItem();
            uiBuilder.after();
        }
    };
    viewer.setContextMenu(new ContextMenuProvider(viewer) {

        @Override
        public void buildContextMenu(IMenuManager menuManager) {
            try {
                if (!getViewer().getEditDomain().isDisabled())
                    contextMenuProvider.populate(menuManager);
            } catch (Exception e) {
                getMenu().setVisible(false);
            }
        }
    });
}
Also used : JFaceMenuBuilder(org.whole.lang.e4.ui.menu.JFaceMenuBuilder) IContributionItem(org.eclipse.jface.action.IContributionItem) IMenuManager(org.eclipse.jface.action.IMenuManager) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider)

Aggregations

ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)4 IContributionItem (org.eclipse.jface.action.IContributionItem)4 IMenuManager (org.eclipse.jface.action.IMenuManager)4 JFaceMenuBuilder (org.whole.lang.e4.ui.menu.JFaceMenuBuilder)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 FocusListener (org.eclipse.swt.events.FocusListener)2 GridData (org.eclipse.swt.layout.GridData)2 ActionRegistry (org.whole.lang.e4.ui.actions.ActionRegistry)2 E4KeyHandler (org.whole.lang.e4.ui.actions.E4KeyHandler)2 E4NavigationKeyHandler (org.whole.lang.e4.ui.actions.E4NavigationKeyHandler)2 E4GraphicalViewer (org.whole.lang.e4.ui.viewers.E4GraphicalViewer)2 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)2 IPartFocusListener (org.whole.lang.ui.editparts.IPartFocusListener)2 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)2 IImportAsModelDialogFactory (org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)1