use of org.whole.lang.lifecycle.RollbackException in project whole by wholeplatform.
the class TypedModelTransactionHandler method execute.
@Execute
public void execute(@Named(ED_URI_PARAMETER_ID) String edUri, @Optional @Named(FD_URI_PARAMETER_ID) String fdUri, @Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm, IEntityPartViewer viewer) throws Exception {
EntityEditDomainJob.asyncExec("replacing entity...", viewer.getEditDomain(), (monitor) -> {
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
ModelTransactionCommand mtc = new ModelTransactionCommand(bm.wGet("focusEntity"));
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
try {
bm.wEnterScope(ts);
defineBindings(edUri, fdUri, bm);
mtc.setLabel(getLabel(bm));
mtc.begin();
TypedModelTransactionHandler.this.run(bm);
mtc.commit();
if (mtc.canUndo())
commandStack.execute(mtc);
} catch (RollbackException e) {
// rollback done
} catch (RuntimeException e) {
mtc.rollbackIfNeeded();
throw e;
} finally {
ts.rollback();
bm.wExitScope();
}
});
}
use of org.whole.lang.lifecycle.RollbackException in project whole by wholeplatform.
the class ModelTransactionHandler method execute.
@Execute
public void execute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) {
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
EntityEditDomainJob.asyncExec(getLabel(bm), viewer.getEditDomain(), (monitor) -> {
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
ModelTransactionCommand mtc = new ModelTransactionCommand(bm.wGet("focusEntity"));
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
try {
bm.wEnterScope(ts);
mtc.setLabel(getLabel(bm));
mtc.begin();
run(bm);
mtc.commit();
if (mtc.canUndo())
commandStack.execute(mtc);
} catch (RollbackException e) {
// rollback done
} catch (RuntimeException e) {
mtc.rollbackIfNeeded();
throw e;
} finally {
ts.rollback();
bm.wExitScope();
}
});
}
Aggregations