Search in sources :

Example 1 with IImportAsModelDialogFactory

use of org.whole.lang.ui.dialogs.IImportAsModelDialogFactory in project whole by wholeplatform.

the class EditorPart method createPartControl.

@Override
public void createPartControl(Composite parent) {
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(ImportAsModelDialogFactory.class, getContext());
    getContext().set(IImportAsModelDialogFactory.class, factory);
    super.createPartControl(parent);
    getContext().get(MPart.class).setElementId("org.eclipse.e4.ui.compatibility.editor");
    setPartName(getEditorInput().getName());
    final IEntityPartViewer viewer = getComponent().getViewer();
    viewer.getCommandStack().addCommandStackEventListener(listener = new CommandStackEventListener() {

        @Override
        public void stackChanged(CommandStackEvent event) {
            if ((event.getDetail() & CommandStack.POST_MASK) != 0)
                setDirtyState(viewer.isDirty());
        }
    });
    undoAction = new UndoAction(getContext(), UNDO_LABEL);
    undoAction.update();
    redoAction = new RedoAction(getContext(), REDO_LABEL);
    redoAction.update();
    if (getEditorInput() instanceof IFileEditorInput) {
        IWorkspace workspace = ((IFileEditorInput) getEditorInput()).getFile().getWorkspace();
        workspace.addResourceChangeListener(resourceListener = new ResourceChangeListener());
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IFileEditorInput(org.eclipse.ui.IFileEditorInput) RedoAction(org.whole.lang.e4.ui.actions.RedoAction) IWorkspace(org.eclipse.core.resources.IWorkspace) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) CommandStackEventListener(org.eclipse.gef.commands.CommandStackEventListener) CommandStackEvent(org.eclipse.gef.commands.CommandStackEvent) UndoAction(org.whole.lang.e4.ui.actions.UndoAction) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 2 with IImportAsModelDialogFactory

use of org.whole.lang.ui.dialogs.IImportAsModelDialogFactory 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 3 with IImportAsModelDialogFactory

use of org.whole.lang.ui.dialogs.IImportAsModelDialogFactory in project whole by wholeplatform.

the class ViewPart method createPartControl.

@Override
public void createPartControl(Composite parent) {
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(ImportAsModelDialogFactory.class, getContext());
    getContext().set(IImportAsModelDialogFactory.class, factory);
    super.createPartControl(parent);
    getContext().get(MPart.class).setElementId(partId);
    undoAction = new UndoAction(getContext(), UNDO_LABEL);
    undoAction.update();
    redoAction = new RedoAction(getContext(), REDO_LABEL);
    redoAction.update();
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) RedoAction(org.whole.lang.e4.ui.actions.RedoAction) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory) UndoAction(org.whole.lang.e4.ui.actions.UndoAction)

Example 4 with IImportAsModelDialogFactory

use of org.whole.lang.ui.dialogs.IImportAsModelDialogFactory in project whole by wholeplatform.

the class AssignmentsDialogFactory method createDialog.

public Dialog createDialog(Shell shell, String title, String message, Assignments assignments, IBindingManager bindings) {
    IEclipseContext params = EclipseContextFactory.create();
    params.set("dialogTitle", title);
    params.set("dialogMessage", message);
    params.set("dialogAssignments", assignments);
    IEclipseContext context = (IEclipseContext) bindings.wGetValue("eclipse#eclipseContext");
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(DisabledImportAsModelDialogFactory.class, context);
    params.set(IImportAsModelDialogFactory.class, factory);
    return ContextInjectionFactory.make(AssignmentsDialog.class, context, params);
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)

Example 5 with IImportAsModelDialogFactory

use of org.whole.lang.ui.dialogs.IImportAsModelDialogFactory in project whole by wholeplatform.

the class ChooseModelsDialogFactory method createDialog.

public Dialog createDialog(Shell shell, String title, String message, Assignments assignments, IBindingManager bindings) {
    IEclipseContext params = EclipseContextFactory.create();
    params.set("dialogTitle", title);
    params.set("dialogMessage", message);
    params.set("dialogAssignments", assignments);
    IEclipseContext context = (IEclipseContext) bindings.wGetValue("eclipse#eclipseContext");
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(DisabledImportAsModelDialogFactory.class, context);
    params.set(IImportAsModelDialogFactory.class, factory);
    return ContextInjectionFactory.make(ChooseModelsDialog.class, context, params);
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)

Aggregations

IImportAsModelDialogFactory (org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)4 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)2 RedoAction (org.whole.lang.e4.ui.actions.RedoAction)2 UndoAction (org.whole.lang.e4.ui.actions.UndoAction)2 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)2 PostConstruct (javax.annotation.PostConstruct)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)1 CommandStackEvent (org.eclipse.gef.commands.CommandStackEvent)1 CommandStackEventListener (org.eclipse.gef.commands.CommandStackEventListener)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 GridData (org.eclipse.swt.layout.GridData)1 IFileEditorInput (org.eclipse.ui.IFileEditorInput)1