Search in sources :

Example 31 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class E4Utils method defineSelectionBindings.

public static void defineSelectionBindings(IBindingManager bm, List<IEntityPart> selectedEntityParts, IEntityPartViewer viewer) {
    IEntity selectedEntities = BindingManagerFactory.instance.createTuple();
    for (IEntityPart selectedEntityPart : selectedEntityParts) selectedEntities.wAdd(selectedEntityPart.getModelEntity());
    if (viewer != null) {
        bm.wDef("self", EntityUtils.getCompoundRoot(viewer.getEntityContents()));
        bm.wDefValue("viewer", viewer);
        IEntityPart focusEntityPart = viewer.getFocusEntityPart();
        bm.wDef("focusEntity", focusEntityPart.getModelEntity());
    }
    bm.wDef("selectedEntities", selectedEntities);
    IEntityIterator<IEntity> iterator = IteratorFactory.childIterator();
    iterator.reset(selectedEntities);
    if (iterator.hasNext()) {
        IEntity focusEntity = iterator.next();
        bm.wDef("primarySelectedEntity", focusEntity);
        if (!bm.wIsSet("focusEntity"))
            bm.wDef("focusEntity", focusEntity);
        IEntityPart primarySelectedEntityPart = selectedEntityParts.get(0);
        if (primarySelectedEntityPart instanceof IHilightable) {
            final IHilightable hilightable = (IHilightable) primarySelectedEntityPart;
            bm.wDefValue("hilightPosition", -1);
            bm.wGet("hilightPosition").wAddRequestEventHandler(new IdentityRequestEventHandler() {

                public int notifyRequested(IEntity source, FeatureDescriptor feature, int value) {
                    return hilightable.getHilightPosition();
                }
            });
        }
        if (primarySelectedEntityPart instanceof ITextualEntityPart) {
            final ITextualEntityPart textualEntityPart = (ITextualEntityPart) primarySelectedEntityPart;
            bm.wDefValue("selectedText", "");
            bm.wGet("selectedText").wAddRequestEventHandler(new IdentityRequestEventHandler() {

                public String notifyRequested(IEntity source, FeatureDescriptor feature, String value) {
                    return textualEntityPart.hasSelectionRange() ? DataTypeUtils.getAsPresentationString(textualEntityPart.getModelEntity()).substring(textualEntityPart.getSelectionStart(), textualEntityPart.getSelectionEnd()) : "";
                }
            });
        }
    }
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IHilightable(org.whole.lang.ui.editpolicies.IHilightable) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) IdentityRequestEventHandler(org.whole.lang.events.IdentityRequestEventHandler)

Example 32 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class WholeNodeEditPolicy method getReconnectTargetCommand.

protected Command getReconnectTargetCommand(ReconnectRequest request) {
    FeatureDescriptor fd = getNodeEditPart().getTargetConnectionFeature(request);
    if (fd == null)
        return UnexecutableCommand.INSTANCE;
    ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(false);
    cmd.setConnection((IEntity) request.getConnectionEditPart().getModel());
    cmd.setNode(getNode());
    cmd.setNodeFeature(fd);
    return cmd;
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ConnectionReconnectCommand(org.whole.lang.ui.commands.ConnectionReconnectCommand)

Example 33 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class WholeNodeEditPolicy method getReconnectSourceCommand.

protected Command getReconnectSourceCommand(ReconnectRequest request) {
    FeatureDescriptor fd = getNodeEditPart().getSourceConnectionFeature(request);
    if (fd == null)
        return UnexecutableCommand.INSTANCE;
    ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(true);
    cmd.setConnection((IEntity) request.getConnectionEditPart().getModel());
    cmd.setNode(getNode());
    cmd.setNodeFeature(fd);
    return cmd;
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ConnectionReconnectCommand(org.whole.lang.ui.commands.ConnectionReconnectCommand)

Example 34 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class WholeNodeEditPolicy method getConnectionCreateCommand.

protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    FeatureDescriptor fd = getNodeEditPart().getSourceConnectionFeature(request);
    if (fd == null)
        return UnexecutableCommand.INSTANCE;
    ConnectionCreateCommand cmd = new ConnectionCreateCommand();
    cmd.setSource(getNode());
    cmd.setSourceFeature(fd);
    request.setStartCommand(cmd);
    return cmd;
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ConnectionCreateCommand(org.whole.lang.ui.commands.ConnectionCreateCommand)

Example 35 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractEntity method notifyRequested.

protected final float notifyRequested(float value) {
    if (requestNotificationDisabled)
        return value;
    FeatureDescriptor fd = CommonsFeatureDescriptorEnum.data_value;
    float result = wGetEntityRequestEventHandler().notifyRequested(this, fd, value);
    return wGetCompoundRequestEventHandler().notifyRequested(this, fd, result);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Aggregations

FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)100 IEntity (org.whole.lang.model.IEntity)43 InternalIEntity (org.whole.lang.model.InternalIEntity)6 ILanguageKit (org.whole.lang.reflect.ILanguageKit)6 HashSet (java.util.HashSet)5 IContributionItem (org.eclipse.jface.action.IContributionItem)5 ActionsVisibleWhen (org.whole.lang.e4.ui.expressions.ActionsVisibleWhen)5 VisibilityExpression (org.whole.lang.e4.ui.expressions.VisibilityExpression)5 ActionsCompositeContributionItem (org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 HashMap (java.util.HashMap)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IdentityRequestEventHandler (org.whole.lang.events.IdentityRequestEventHandler)3 IMappingStrategy (org.whole.lang.xsd.codebase.IMappingStrategy)3 IEntityFactory (org.whole.lang.factories.IEntityFactory)2 ArrayType (org.whole.lang.pojo.model.ArrayType)2 CollectionType (org.whole.lang.pojo.model.CollectionType)2 MapType (org.whole.lang.pojo.model.MapType)2