Search in sources :

Example 6 with FeatureDescriptorEnum

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

the class GrammarBasedUIUtils method createCompositeFigure.

public static IEntityFigure createCompositeFigure(IEntity entity) {
    ILanguageKit lk = entity.wGetLanguageKit();
    EntityDescriptorEnum edEnum = lk.getEntityDescriptorEnum();
    FeatureDescriptorEnum fdEnum = lk.getFeatureDescriptorEnum();
    IEntity configuration = Matcher.findAncestor(edEnum.valueOf("CompositePart"), entity);
    IEntity multiline = configuration.wGet(fdEnum.valueOf("multiline"));
    boolean isMultiline = EntityUtils.safeBooleanValue(multiline, false);
    IEntity columns = configuration.wGet(fdEnum.valueOf("columns"));
    int columnsNum = EntityUtils.safeIntValue(columns, 0);
    IEntity separator = configuration.wGet(fdEnum.valueOf("separator"));
    IEntityFigure entityFigure;
    if (EntityUtils.isNotResolver(separator)) {
        String separatorText = GrammarBasedUIUtils.calculateSeparator(separator);
        CompositeFigure compositeFigure = isMultiline ? new StringSeparatedCompositeColumnFigure(separatorText, 10) : new StringSeparatedCompositeRowFigure(separatorText, 10);
        if (isMultiline)
            compositeFigure.getLayoutManager().withMinorAlignment(Alignment.LEADING);
        entityFigure = compositeFigure;
    } else if (columnsNum > 0) {
        TableFigure tableFigure = new TableFigure(columnsNum);
        tableFigure.setBorder(CompositePlaceHolderBorder.OPTIONAL_VERTICAL);
        entityFigure = tableFigure;
    } else
        entityFigure = new CompositeFigure(!isMultiline, true);
    return entityFigure;
}
Also used : CompositeFigure(org.whole.lang.ui.figures.CompositeFigure) StringSeparatedCompositeColumnFigure(org.whole.lang.ui.figures.StringSeparatedCompositeColumnFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) TableFigure(org.whole.lang.ui.figures.TableFigure) EntityDescriptorEnum(org.whole.lang.reflect.EntityDescriptorEnum) FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) StringSeparatedCompositeRowFigure(org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 7 with FeatureDescriptorEnum

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

the class GrammarBasedUIUtils method createSequenceFigure.

public static IEntityFigure createSequenceFigure(IEntity entity, ContentPaneFigure contentPaneFigure, boolean embed) {
    FeatureDescriptorEnum fdEnum = entity.wGetLanguageKit().getFeatureDescriptorEnum();
    IEntity multiline = entity.wGet(fdEnum.valueOf("multiline"));
    ICompositeEntityLayout layout = EntityUtils.safeBooleanValue(multiline, false) ? new ColumnLayout() : new RowLayout();
    // TODO complete optional behavior
    IEntity optional = entity.wGet(fdEnum.valueOf("optional"));
    IEntityFigure figure;
    if (embed) {
        contentPaneFigure.setLayoutManager(layout.withSpacing(5));
        figure = contentPaneFigure;
    } else
        figure = new EntityFigure(layout.withSpacing(5));
    IEntity childFigures = entity.wGet(fdEnum.valueOf("figures"));
    for (int i = 0, size = childFigures.wSize(); i < size; i++) addChildFigure(childFigures.wGet(i), contentPaneFigure, figure);
    return figure;
}
Also used : ICompositeEntityLayout(org.whole.lang.ui.layout.ICompositeEntityLayout) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IEntity(org.whole.lang.model.IEntity) ColumnLayout(org.whole.lang.ui.layout.ColumnLayout) RowLayout(org.whole.lang.ui.layout.RowLayout)

Example 8 with FeatureDescriptorEnum

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

the class GrammarBasedUIUtils method createTerminalFigure.

public static IEntityFigure createTerminalFigure(IEntity entity) {
    FeatureDescriptorEnum fdEnum = entity.wGetLanguageKit().getFeatureDescriptorEnum();
    IEntity category = entity.wGet(fdEnum.valueOf("category"));
    IEntity literal = entity.wGet(fdEnum.valueOf("literal"));
    EntityLabel label = createEntityLabel(category);
    label.setText(StringUtils.unescapeString(DataTypeUtils.getAsPresentationString(literal)));
    return label;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) EntityLabel(org.whole.lang.ui.figures.EntityLabel)

Example 9 with FeatureDescriptorEnum

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

the class E4Utils method createErrorStatusContents.

public static IEntity createErrorStatusContents(String error, String cause) {
    ILanguageKit languageKit = ReflectionFactory.getLanguageKit(CoreMetaModelsDeployer.STATUS_URI, false, null);
    FeatureDescriptorEnum fdEnum = languageKit.getFeatureDescriptorEnum();
    IEntity statusModel = createErrorStatusContents();
    statusModel.wGet(fdEnum.valueOf("error")).wSetValue(error);
    statusModel.wGet(fdEnum.valueOf("cause")).wSetValue(cause);
    return statusModel;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 10 with FeatureDescriptorEnum

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

the class AbstractFreeformNodePart method refreshVisuals.

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

Aggregations

IEntity (org.whole.lang.model.IEntity)10 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)10 ILanguageKit (org.whole.lang.reflect.ILanguageKit)3 ArrayList (java.util.ArrayList)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)2 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)2 HashMap (java.util.HashMap)1 Actions (org.whole.lang.actions.model.Actions)1 GroupAction (org.whole.lang.actions.model.GroupAction)1 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)1 CommonsFeatureDescriptorEnum (org.whole.lang.commons.reflect.CommonsFeatureDescriptorEnum)1 IEntityFactory (org.whole.lang.factories.IEntityFactory)1 Pair (org.whole.lang.json.model.Pair)1 Value (org.whole.lang.json.model.Value)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)1 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1