use of org.whole.lang.e4.ui.actions.ILinkableSelectionListener in project whole by wholeplatform.
the class E4ContextGraphicalPart 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) {
if (selection.wIsSet("primarySelectedEntity")) {
IEntity primarySelectedEntity = selection.wGet("primarySelectedEntity");
IEntity model = EntityUtils.getCompoundRoot(primarySelectedEntity);
IEntity selfModel = EntityUtils.mapEntity(primarySelectedEntity, EntityUtils.clone(model));
IEntity selfBindings = BindingManagerFactory.instance.createValue(selection.clone());
IEntity sampleContext = BindingManagerFactory.instance.createTuple(result, selfModel, selfBindings);
// TODO test
// if (Matcher.matchImpl(EnvironmentEntityDescriptorEnum.Bindings, result))
// result.wAdd(BindingManagerFactory.instance.createBinding("self", selfModel));
eventBroker.post(IE4UIConstants.TOPIC_UPDATE_SAMPLE_CONTEXT, sampleContext);
} else
getViewer().setContents(null, createDefaultContents());
}
});
return listener;
}
use of org.whole.lang.e4.ui.actions.ILinkableSelectionListener 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