Search in sources :

Example 6 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractConnectedFreeformRootPart method createEditPolicies.

// public IFigure getContentPane() {
// return pane;
// }
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.CONTAINER_ROLE, new WholeContainerEditPolicy(getCommandFactory()));
    installEditPolicy(EditPolicy.COMPONENT_ROLE, new WholeComponentEditPolicy(getCommandFactory()));
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new WholeFreeformLayoutEditPolicy((XYLayout) getContentPane().getLayoutManager(), getCommandFactory()) {

        protected DnDOverCompositeRequest createDnDOverCompositeRequest(IEntity entity) {
            return new DnDOverCompositeRequest(PartRequest.MOVE_ADD_CHILD, (IEntityPart) getHost(), entity, null) {

                @Override
                public IEntity getModelEntity() {
                    // FIXME workaround to get nodes composite
                    IEntity modelEntity = super.getModelEntity().wGet(0);
                    return modelEntity;
                }
            };
        }
    });
    installEditPolicy("Snap Feedback", new SnapFeedbackPolicy());
}
Also used : WholeContainerEditPolicy(org.whole.lang.ui.editpolicies.WholeContainerEditPolicy) DnDOverCompositeRequest(org.whole.lang.ui.requests.DnDOverCompositeRequest) WholeComponentEditPolicy(org.whole.lang.ui.editpolicies.WholeComponentEditPolicy) WholeFreeformLayoutEditPolicy(org.whole.lang.ui.editpolicies.WholeFreeformLayoutEditPolicy) IEntity(org.whole.lang.model.IEntity) EntityXYLayout(org.whole.lang.ui.layout.EntityXYLayout) XYLayout(org.eclipse.draw2d.XYLayout) SnapFeedbackPolicy(org.eclipse.gef.editpolicies.SnapFeedbackPolicy)

Example 7 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractFreeformContentPanePart method refreshVisuals.

@Override
protected void refreshVisuals() {
    IEntity e = getPresentationEntity();
    FeatureDescriptorEnum fe = e.wGetEntityDescriptor().getFeatureDescriptorEnum();
    int x = e.wGet(fe.valueOf("x")).wIntValue();
    int y = e.wGet(fe.valueOf("y")).wIntValue();
    // int width = e.wGet(fe.valueOf("width")).wIntValue();
    // int height = e.wGet(fe.valueOf("height")).wIntValue();
    // width, height);
    Rectangle bounds = new Rectangle(x, y, -1, -1);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 8 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractNodePart method getSourceConnectionAnchor.

public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
    IEntity e = getModelEntity();
    IEntity c = (IEntity) connection.getModel();
    for (int i = 0; i < sourceFeatures.length; i++) {
        IEntity ec = e.wGet(sourceFeatures[i]);
        switch(ec.wGetEntityKind()) {
            case COMPOSITE:
                if (ec.wContains(c))
                    return getNodeFigure().getSourceAnchor(i);
                break;
            case SIMPLE:
                if (ec == c)
                    return getNodeFigure().getSourceAnchor(i);
                break;
            case DATA:
                throw new IllegalStateException("unsupported entity kind");
        }
    }
    return null;
}
Also used : IEntity(org.whole.lang.model.IEntity) Point(org.eclipse.draw2d.geometry.Point)

Example 9 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractNodePart method getModelConnections.

@SuppressWarnings({ "unchecked" })
protected List<IEntity> getModelConnections(FeatureDescriptor[] features) {
    IEntity e = getModelEntity();
    List<IEntity> result = new ArrayList<IEntity>(features.length);
    for (int i = 0; i < features.length; i++) {
        IEntity c = e.wGet(features[i]);
        if (EntityUtils.isResolver(c))
            continue;
        switch(c.wGetEntityKind()) {
            case COMPOSITE:
                result.addAll((Collection<? extends IEntity>) c);
                break;
            case SIMPLE:
                result.add(c);
                break;
            case DATA:
                throw new IllegalStateException("unsupported entity kind");
        }
    }
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point)

Example 10 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractPart method getParentModelEntity.

public IEntity getParentModelEntity() {
    IEntity modelEntity = getModelEntity();
    IEntity parentModelEntity = modelEntity.wGetParent();
    if (!EntityUtils.isNull(parentModelEntity))
        return parentModelEntity;
    else
        return getParentPartModelEntity();
}
Also used : IEntity(org.whole.lang.model.IEntity)

Aggregations

IEntity (org.whole.lang.model.IEntity)1407 ArrayList (java.util.ArrayList)604 Test (org.junit.Test)241 IBindingManager (org.whole.lang.bindings.IBindingManager)141 PathExpression (org.whole.lang.queries.model.PathExpression)68 ITemplateManager (org.whole.lang.templates.ITemplateManager)61 Grammar (org.whole.lang.grammars.model.Grammar)50 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)46 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)43 Model (org.whole.lang.models.model.Model)40 InternalIEntity (org.whole.lang.model.InternalIEntity)38 VisitException (org.whole.lang.visitors.VisitException)35 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)30 ModelsModel (org.whole.lang.models.codebase.ModelsModel)27 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)26 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)24 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)22 XmlModel (org.whole.lang.models.codebase.XmlModel)22 MissingVariableException (org.whole.lang.visitors.MissingVariableException)22 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)21