Search in sources :

Example 21 with IEntityPartViewer

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

the class RevertHandler method execute.

@Execute
public void execute(EPartService partService, IModelInput modelInput, @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) {
    if (E4Utils.isLegacyApplication()) {
        IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
        viewer.setContents((IModelInput) bm.wGetValue("modelInput"), null);
    } else {
        AbstractE4Part part = (AbstractE4Part) partService.getActivePart().getObject();
        part.getViewer().setContents(modelInput, null);
    }
}
Also used : AbstractE4Part(org.whole.lang.e4.ui.parts.AbstractE4Part) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 22 with IEntityPartViewer

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

the class AbstractRunnableWithProgress method asyncExec.

public void asyncExec(String message) {
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    EntityEditDomain editDomain = viewer.getEditDomain();
    if (isTransactional())
        editDomain.setDisabled(true);
    EntityEditDomainJob.asyncExec(message, editDomain, this);
}
Also used : EntityEditDomain(org.whole.lang.ui.viewers.EntityEditDomain) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 23 with IEntityPartViewer

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

the class AbstractRunnableWithProgress method run.

@Override
public void run(IProgressMonitor monitor) {
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    try {
        final IOperationProgressMonitor pm = new OperationProgressMonitorAdapter(monitor);
        bm.wDefValue("progressMonitor", pm);
        run(pm);
    } catch (Exception e) {
        E4Utils.suspendOrReportException(context, SuspensionKind.ERROR, "Model operation error", "Error while executing " + label + " operation", e, bm);
    } finally {
        monitor.done();
        if (isTransactional())
            context.get(UISynchronize.class).syncExec(() -> viewer.getEditDomain().setDisabled(false));
    }
    return;
}
Also used : OperationProgressMonitorAdapter(org.whole.lang.operations.OperationProgressMonitorAdapter) IOperationProgressMonitor(org.whole.lang.operations.IOperationProgressMonitor) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 24 with IEntityPartViewer

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

the class AbstractRunnableWithProgress method syncExec.

public synchronized IBindingScope syncExec(long timeout) {
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    EntityEditDomain editDomain = viewer.getEditDomain();
    UISynchronize uiSynchronize = context.get(UISynchronize.class);
    try {
        context.set(UISynchronize.class, NoUISynchronize.instance);
        EntityEditDomainJob.syncExec("boh", editDomain, this);
    } finally {
        context.set(UISynchronize.class, uiSynchronize);
    }
    return bm;
}
Also used : EntityEditDomain(org.whole.lang.ui.viewers.EntityEditDomain) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) UISynchronize(org.eclipse.e4.ui.di.UISynchronize)

Example 25 with IEntityPartViewer

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

the class FunctionRunnable 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");
    CommandStack commandStack = viewer.getEditDomain().getCommandStack();
    ModelTransactionCommand mtc = new ModelTransactionCommand(bm.wGet("self"), label);
    IEntity result = null;
    pm.beginTask("Executing function " + functionUri + "...", IOperationProgressMonitor.TOTAL_WORK);
    try {
        mtc.begin();
        result = BehaviorUtils.apply(functionUri, bm.wGet("self"), bm);
        mtc.commit();
        if (mtc.canUndo())
            commandStack.execute(mtc);
    } catch (OperationCanceledException e) {
        mtc.rollbackIfNeeded();
    } catch (RuntimeException e) {
        mtc.rollbackIfNeeded();
        throw e;
    } finally {
        bm.setResult(result);
        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)

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