Search in sources :

Example 41 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class DirectEditAction method update.

@Override
public void update() {
    setEnabled(false);
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    if (selectionService.getSelection() instanceof IBindingManager) {
        IBindingManager bm = (IBindingManager) selectionService.getSelection();
        if (bm.wIsSet("viewer")) {
            IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
            IEntity focusEntity = bm.wGet("focusEntity");
            IEntityPart entityPart = viewer.getEditPartRegistry().get(focusEntity);
            setEnabled(entityPart.understandsRequest(request));
        }
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 42 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class DirectEditAction method run.

@Override
public void run() {
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    IBindingManager bm = (IBindingManager) selectionService.getSelection();
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntity focusEntity = bm.wGet("focusEntity");
    IEntityPart entityPart = viewer.getEditPartRegistry().get(focusEntity);
    try {
        entityPart.performRequest(request);
    } catch (Exception e) {
        e.getCause();
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 43 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class E4DebugGraphicalPart method createEntityViewer.

@Override
protected IEntityPartViewer createEntityViewer(Composite parent) {
    IEntityPartViewer viewer = super.createEntityViewer(parent);
    viewer.setOperationExecutable(false);
    return viewer;
}
Also used : IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 44 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class TextualFunctionRunnable method run.

@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException, InterruptedException {
    // FIXME workaround for missing caret update events (no selection update is performed)
    E4Utils.defineCaretBindings(bm);
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntity text = bm.wGet("focusEntity");
    boolean enableAnimation = AnimableRunnable.enableAnimation(false);
    ModelTextCommand mtc = new ModelTextCommand(text);
    try {
        mtc.setLabel(label);
        mtc.setViewer(viewer);
        mtc.begin();
        try {
            bm.wEnterScope();
            IEntity newText = BehaviorUtils.apply(functionUri, bm.wGet("self"), bm);
            mtc.setNewSelectedEntity(newText);
            mtc.setNewPosition(bm.wIntValue("caretPosition"));
        // FIXME add textual selection viariables updates
        // see E4Utils.defineCaretBindings()
        } catch (OperationCanceledException e) {
            throw e;
        } finally {
            bm.wExitScope();
        }
        mtc.commit();
        if (mtc.canUndo()) {
            CommandStack commandStack = viewer.getEditDomain().getCommandStack();
            commandStack.execute(mtc);
        }
    } catch (OperationCanceledException e) {
        mtc.rollbackIfNeeded();
    } catch (RuntimeException e) {
        mtc.rollbackIfNeeded();
        throw e;
    } finally {
        AnimableRunnable.enableAnimation(enableAnimation);
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IEntity(org.whole.lang.model.IEntity) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) ModelTextCommand(org.whole.lang.ui.commands.ModelTextCommand) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 45 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class E4SampleGraphicalPart method createSelectionLinkable.

@Override
protected ILinkableSelectionListener createSelectionLinkable(IEntityPartViewer viewer) {
    ILinkableSelectionListener listener = super.createSelectionLinkable(viewer);
    listener.addLinkViewerListener(new LinkViewerAdapter() {

        @Override
        public void contentsDerived(IEntityPartViewer viewer, IBindingManager selection, IEntity result) {
            boolean canExecute = EntityUtils.safeBooleanValue(result, false);
            if (canExecute) {
                IEntity primarySelectedEntity = selection.wGet("primarySelectedEntity");
                IEntity model = EntityUtils.getCompoundRoot(primarySelectedEntity);
                bm = selection.clone();
                bm.wDefValue("debug#reportModeEnabled", false);
                BehaviorUtils.evaluate(contextModel, 0, bm);
                ITransactionScope transactionScope = BindingManagerFactory.instance.createTransactionScope();
                bm.wEnterScope(transactionScope);
                try {
                    behaviorModel = EntityUtils.mapEntity(primarySelectedEntity, EntityUtils.clone(model));
                    behaviorLabel = BehaviorUtils.apply("whole:org.whole.lang.ui.views:SamplePerspectiveSemantics#SampleViewBehaviorLabel", behaviorModel, bm).wStringValue();
                } finally {
                    transactionScope.rollback();
                    bm.wExitScope();
                }
                execute();
            } else {
                bm = null;
                behaviorModel = null;
                behaviorLabel = null;
                getViewer().setContents(null, createDefaultContents());
            }
        }
    });
    return listener;
}
Also used : ILinkableSelectionListener(org.whole.lang.e4.ui.actions.ILinkableSelectionListener) ITransactionScope(org.whole.lang.bindings.ITransactionScope) LinkViewerAdapter(org.whole.lang.e4.ui.actions.LinkViewerAdapter) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Aggregations

IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)55 IEntity (org.whole.lang.model.IEntity)29 IBindingManager (org.whole.lang.bindings.IBindingManager)13 CommandStack (org.eclipse.gef.commands.CommandStack)12 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)11 OperationCanceledException (org.whole.lang.operations.OperationCanceledException)8 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)8 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)6 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)6 Execute (org.eclipse.e4.core.di.annotations.Execute)6 Shell (org.eclipse.swt.widgets.Shell)5 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)5 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IEventBroker (org.eclipse.e4.core.services.events.IEventBroker)2 UISynchronize (org.eclipse.e4.ui.di.UISynchronize)2 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)2 Command (org.eclipse.gef.commands.Command)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Control (org.eclipse.swt.widgets.Control)2