use of org.whole.lang.ui.commands.ModelTextCommand 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);
}
}
Aggregations