Search in sources :

Example 1 with ILinkableSelectionListener

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;
}
Also used : ILinkableSelectionListener(org.whole.lang.e4.ui.actions.ILinkableSelectionListener) LinkViewerAdapter(org.whole.lang.e4.ui.actions.LinkViewerAdapter) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 2 with ILinkableSelectionListener

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;
}
Also used : ILinkableSelectionListener(org.whole.lang.e4.ui.actions.ILinkableSelectionListener) ITransactionScope(org.whole.lang.bindings.ITransactionScope) LinkViewerAdapter(org.whole.lang.e4.ui.actions.LinkViewerAdapter) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)2 ILinkableSelectionListener (org.whole.lang.e4.ui.actions.ILinkableSelectionListener)2 LinkViewerAdapter (org.whole.lang.e4.ui.actions.LinkViewerAdapter)2 IEntity (org.whole.lang.model.IEntity)2 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)2 ITransactionScope (org.whole.lang.bindings.ITransactionScope)1