Search in sources :

Example 46 with IEntityPartViewer

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

the class E4VariablesGraphicalPart 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 47 with IEntityPartViewer

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

the class E4OutlineTreePart method createEntityViewer.

protected IEntityPartViewer createEntityViewer(Composite parent) {
    IEntityPartViewer viewer = super.createEntityViewer(parent);
    setSelectionLinkable(createSelectionLinkable(viewer));
    return viewer;
}
Also used : IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 48 with IEntityPartViewer

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

the class RedirectableModelTransactionHandler method getActionRedirection.

protected IActionRedirection getActionRedirection(IBindingManager bm) {
    if (!bm.wIsSet("focusEntity"))
        return NullActionRedirection.instance();
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntityPart entityPart = viewer.getEditPartRegistry().get(bm.wGet("focusEntity"));
    IActionRedirection actionRedirection = (IActionRedirection) entityPart.getAdapter(IActionRedirection.class);
    return actionRedirection != null ? actionRedirection : NullActionRedirection.instance();
}
Also used : IActionRedirection(org.whole.lang.ui.actions.IActionRedirection) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 49 with IEntityPartViewer

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

the class ActionCallRunnable method run.

@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException {
    IEntity model = bm.wGet("self");
    boolean analyzing = bm.wBooleanValue("analyzing");
    if (analyzing) {
        // clone model if is analyzing
        model = EntityUtils.clone(model);
        CommonsEntityFactory.instance.createRootFragment(model.wGetAdapter(CommonsEntityDescriptorEnum.Any));
        ReflectionFactory.getHistoryManager(model).setHistoryEnabled(true);
        // map selected entities if analyzing
        IEntity tuple = bm.wGet("selectedEntities");
        int size = tuple.wSize();
        for (int i = 0; i < size; i++) tuple.wSet(i, EntityUtils.mapEntity(tuple.wGet(i), model));
        bm.wSet("primarySelectedEntity", EntityUtils.mapEntity(bm.wGet("primarySelectedEntity"), model));
        bm.wSet("focusEntity", EntityUtils.mapEntity(bm.wGet("focusEntity"), model));
    }
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    final CommandStack commandStack = viewer.getEditDomain().getCommandStack();
    final ModelTransactionCommand mtc = new ModelTransactionCommand(model, label);
    pm.beginTask("executing action", 90, IOperationProgressMonitor.TOTAL_WORK);
    try {
        mtc.begin();
        HandlersBehavior.actionCall(bm);
        mtc.commit();
        if (analyzing) {
            E4Utils.revealPart(context, RESULTS_PART_ID);
            IEventBroker eventBroker = context.get(IEventBroker.class);
            eventBroker.post(IE4UIConstants.TOPIC_UPDATE_RESULTS, bm.getResult());
        } else if (mtc.canUndo()) {
            context.get(UISynchronize.class).syncExec(new Runnable() {

                public void run() {
                    commandStack.execute(mtc);
                }
            });
        }
    } catch (OperationCanceledException e) {
        mtc.rollbackIfNeeded();
    } catch (RuntimeException e) {
        mtc.rollbackIfNeeded();
        throw e;
    } finally {
        pm.endTask();
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ModelTransactionCommand(org.whole.lang.ui.commands.ModelTransactionCommand) IEntity(org.whole.lang.model.IEntity) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEventBroker(org.eclipse.e4.core.services.events.IEventBroker)

Example 50 with IEntityPartViewer

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

the class InterpretModelRunnable method run.

@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException, InterruptedException {
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    CommandStack commandStack = viewer.getEditDomain().getCommandStack();
    ModelTransactionCommand mtc = new ModelTransactionCommand(bm.wGet("self"), label);
    pm.beginTask("Interpreting...", IOperationProgressMonitor.TOTAL_WORK);
    try {
        mtc.begin();
        HandlersBehavior.interpretModel(bm);
        mtc.commit();
        if (mtc.canUndo())
            commandStack.execute(mtc);
    } catch (OperationCanceledException e) {
        mtc.rollbackIfNeeded();
    } catch (RuntimeException e) {
        mtc.rollbackIfNeeded();
        throw e;
    } finally {
        pm.endTask();
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ModelTransactionCommand(org.whole.lang.ui.commands.ModelTransactionCommand) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) 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