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));
}
}
}
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();
}
}
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;
}
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);
}
}
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;
}
Aggregations