Search in sources :

Example 1 with StringSeparatedCompositeRowFigure

use of org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure in project whole by wholeplatform.

the class PathPart method createFigure.

protected IFigure createFigure() {
    IFigure f = new StringSeparatedCompositeRowFigure("/", new RowLayout().withMarginLeft(8).withMarginRight(5).withSpacing(8)) {

        @Override
        public Color getLocalForegroundColor() {
            return ColorConstants.gray;
        }

        @Override
        protected Font getLocalFont() {
            return FigureConstants.symbolFontLarge;
        }

        @SuppressWarnings("unchecked")
        protected void paintDecorations(Graphics g) {
            // workaround for LabelFactory.createModule
            g.setFont(FigureConstants.symbolFontLarge);
            int spacing = Math.max(1, getLayoutManager().getSpacing() / 5);
            // getSeparatorAscent();
            int separatorAscent = FigureUtilities.getFontMetrics(g.getFont()).getHeight() / 2;
            List<IEntityFigure> children = (List<IEntityFigure>) getChildren();
            if (!children.isEmpty()) {
                for (int i = 0; i < children.size() - 1; i++) {
                    IEntityFigure childFigure = children.get(i);
                    Rectangle childBounds = childFigure.getBounds();
                    g.drawString(separator, childBounds.right() + spacing, childBounds.y + childFigure.getAscent() - separatorAscent);
                }
                IEntityFigure childFigure = children.get(0);
                Rectangle childBounds = childFigure.getBounds();
                g.setForegroundColor(ColorConstants.lightGray);
                g.drawString(separator, childBounds.x - getLayoutManager().getMarginLeft() + 1, childBounds.y + childFigure.getAscent() - separatorAscent);
            }
        }
    };
    return f;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) RowLayout(org.whole.lang.ui.layout.RowLayout) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) StringSeparatedCompositeRowFigure(org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with StringSeparatedCompositeRowFigure

use of org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure 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 3 with StringSeparatedCompositeRowFigure

use of org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure in project whole by wholeplatform.

the class InValueListPart method createFigure.

protected IFigure createFigure() {
    IFigure figure = new StringSeparatedCompositeRowFigure(",", 10);
    figure.setBorder(new RoundBracketsBorder());
    return figure;
}
Also used : StringSeparatedCompositeRowFigure(org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure) RoundBracketsBorder(org.whole.lang.ui.figures.RoundBracketsBorder) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with StringSeparatedCompositeRowFigure

use of org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure in project whole by wholeplatform.

the class TuplePart method createFigure.

protected IFigure createFigure() {
    StringSeparatedCompositeRowFigure f = new StringSeparatedCompositeRowFigure();
    f.setBorder(new RoundBracketsBorder());
    return f;
}
Also used : StringSeparatedCompositeRowFigure(org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure) RoundBracketsBorder(org.whole.lang.ui.figures.RoundBracketsBorder)

Aggregations

StringSeparatedCompositeRowFigure (org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure)4 IFigure (org.eclipse.draw2d.IFigure)2 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)2 RoundBracketsBorder (org.whole.lang.ui.figures.RoundBracketsBorder)2 List (java.util.List)1 Graphics (org.eclipse.draw2d.Graphics)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 IEntity (org.whole.lang.model.IEntity)1 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)1 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)1 StringSeparatedCompositeColumnFigure (org.whole.lang.ui.figures.StringSeparatedCompositeColumnFigure)1 TableFigure (org.whole.lang.ui.figures.TableFigure)1 RowLayout (org.whole.lang.ui.layout.RowLayout)1