Search in sources :

Example 36 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4GraphicalViewer method selectAndReveal.

// End Block Shared With E4TreeViewer
public void selectAndReveal(IEntity entity, boolean propagate) {
    IEntityPart entityPart = ModelObserver.getObserver(entity, getEditPartRegistry());
    if (entityPart != null) {
        getControl().getDisplay().syncExec(() -> reveal(entityPart));
        select(entityPart, propagate);
    }
}
Also used : IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 37 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4TreeViewer method select.

@Override
public void select(List<? extends IEntity> entities, boolean propagate) {
    List<IEntityPart> entityParts = new ArrayList<>();
    for (int i = entities.size() - 1; i >= 0; i--) {
        IEntityPart entityPart = ModelObserver.getObserver(entities.get(i), getEditPartRegistry());
        if (entityPart != null && entityPart.isSelectable())
            entityParts.add(entityPart);
    }
    setSelection(new StructuredSelection(entityParts), propagate);
}
Also used : ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) Point(org.eclipse.draw2d.geometry.Point)

Example 38 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4TreeViewer method rebuildNotation.

public void rebuildNotation(IEntity entity) {
    IEntityPart entityPart = ModelObserver.getObserver(entity, getEditPartRegistry());
    if (entityPart == null) {
        if (EntityUtils.isAncestorOrSelf(entity, getEntityContents()))
            entityPart = ModelObserver.getObserver(getEntityContents(), getEditPartRegistry());
        else
            return;
    }
    entityPart.rebuild();
}
Also used : IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 39 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class AbstractE4Part method createPartControl.

@PostConstruct
public void createPartControl(Composite parent) {
    restoreState();
    registerHandlers();
    parent.setLayout(new FillLayout());
    viewer = createEntityViewer(parent);
    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) {
        }

        @Override
        @SuppressWarnings("unchecked")
        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));
        }
    });
    E4KeyHandler keyHandler = new E4KeyHandler(context);
    keyHandler.setParent(new E4NavigationKeyHandler(context));
    context.set(IEntityPartViewer.class, viewer);
    viewer.setKeyHandler(keyHandler);
    viewer.setContents(modelInput, createDefaultContents());
    actionRegistry = ContextInjectionFactory.make(ActionRegistry.class, context);
    actionRegistry.registerKeyActions(viewer.getKeyHandler());
    context.set(ActionRegistry.class, actionRegistry);
    configureContextMenu();
    if (!E4Utils.isLegacyApplication())
        viewer.getCommandStack().addCommandStackEventListener(new CommandStackEventListener() {

            @Override
            public void stackChanged(CommandStackEvent event) {
                if ((event.getDetail() & CommandStack.POST_MASK) != 0)
                    part.setDirty(viewer.isDirty());
            }
        });
    reloader = new LazyConfirmationDialogReloader(viewer.getControl(), new Runnable() {

        @Override
        public void run() {
            viewer.setContents(modelInput, null);
        }
    });
}
Also used : LazyConfirmationDialogReloader(org.whole.lang.ui.dialogs.LazyConfirmationDialogReloader) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) CommandStackEventListener(org.eclipse.gef.commands.CommandStackEventListener) FocusEvent(org.eclipse.swt.events.FocusEvent) ActionRegistry(org.whole.lang.e4.ui.actions.ActionRegistry) E4KeyHandler(org.whole.lang.e4.ui.actions.E4KeyHandler) E4NavigationKeyHandler(org.whole.lang.e4.ui.actions.E4NavigationKeyHandler) CommandStackEvent(org.eclipse.gef.commands.CommandStackEvent) 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) PostConstruct(javax.annotation.PostConstruct)

Example 40 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4DebugGraphicalPart method updateUI.

protected void updateUI() {
    updateActions();
    IEventBroker eventBroker = context.get(IEventBroker.class);
    ExecutionState execution = executions.peek();
    if (execution != null) {
        final IEntity sourceEntity = execution.getSourceEntity();
        IEntity contents = EntityUtils.getCompoundRoot(sourceEntity);
        getViewer().setContents(contents);
        getViewer().setInteractive(contents, false, true, false);
        context.get(UISynchronize.class).asyncExec(new Runnable() {

            @Override
            public void run() {
                IEntity adaptee = sourceEntity.wGetAdaptee(false);
                IEntityPart sourceEntityPart = getViewer().getEditPartRegistry().get(adaptee);
                sourceEntityPart.installEditPolicy(SuspensionFeedbackEditPolicy.SUSPENSION_FEEDBACK_ROLE, new SuspensionFeedbackEditPolicy(getSuspensionKind(), execution.getThrowable()));
                getViewer().reveal(sourceEntity);
            }
        });
        eventBroker.post(IE4UIConstants.TOPIC_UPDATE_VARIABLES, execution.getVariablesModel());
    } else {
        getViewer().setEntityContents(createDefaultContents());
        eventBroker.post(IE4UIConstants.TOPIC_UPDATE_VARIABLES, null);
    }
}
Also used : ExecutionState(org.whole.lang.e4.ui.jobs.ExecutionState) IEntity(org.whole.lang.model.IEntity) SuspensionFeedbackEditPolicy(org.whole.lang.ui.editpolicies.SuspensionFeedbackEditPolicy) IEventBroker(org.eclipse.e4.core.services.events.IEventBroker) UISynchronize(org.eclipse.e4.ui.di.UISynchronize) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Aggregations

IEntityPart (org.whole.lang.ui.editparts.IEntityPart)49 IEntity (org.whole.lang.model.IEntity)21 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)12 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 ArrayList (java.util.ArrayList)6 EditPart (org.eclipse.gef.EditPart)6 Point (org.eclipse.draw2d.geometry.Point)5 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 FocusEvent (org.eclipse.swt.events.FocusEvent)4 FocusListener (org.eclipse.swt.events.FocusListener)4 IBindingManager (org.whole.lang.bindings.IBindingManager)4 ActionRegistry (org.whole.lang.e4.ui.actions.ActionRegistry)4 E4KeyHandler (org.whole.lang.e4.ui.actions.E4KeyHandler)4 E4NavigationKeyHandler (org.whole.lang.e4.ui.actions.E4NavigationKeyHandler)4 IPartFocusListener (org.whole.lang.ui.editparts.IPartFocusListener)4 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)3