Search in sources :

Example 1 with TableFigure

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

the class EntityOutlineRightFigure method paintConnections.

@SuppressWarnings("unchecked")
protected void paintConnections(Graphics graphics) {
    graphics.setForegroundColor(FigureConstants.contentLighterColor);
    Point rootPoint = getFoldingToggle(0).getBounds().getBottom();
    Object childrenFigure = getContentPane(1).getChildren().get(0);
    Point[] childrenPoints = null;
    if (childrenFigure instanceof TableFigure) {
        TableFigure tableFigure = (TableFigure) childrenFigure;
        TableLayout layoutManager = tableFigure.getLayoutManager();
        int childrenSize = layoutManager.rows();
        childrenPoints = new Point[childrenSize];
        if (childrenSize == 0)
            return;
        for (int i = 0; i < childrenSize; i++) {
            IFigure row = layoutManager.getRow(i);
            List<IFigure> rowChildren = row.getChildren();
            if (row instanceof TableRowFigure && !rowChildren.isEmpty()) {
                childrenPoints[i] = row.getBounds().getLeft().translate(-8, 0);
                childrenPoints[i].y = ((TableRowLayout) row.getLayoutManager()).getBaseline(0);
            } else if (row instanceof IEntityFigure) {
                childrenPoints[i] = row.getBounds().getTopLeft().translate(-4, ((IEntityFigure) row).getAscent());
            } else
                childrenPoints[i] = row.getBounds().getLeft().translate(-4, 0);
        }
    } else {
        IFigure childFigure = (IFigure) childrenFigure;
        List<IFigure> children = childFigure.getChildren();
        int childrenSize = children.size();
        if (childrenSize == 0 || childFigure instanceof ITextFigure) {
            childrenPoints = new Point[1];
            if (childFigure instanceof IEntityFigure)
                childrenPoints[0] = childFigure.getBounds().getTopLeft().translate(-4, ((IEntityFigure) childFigure).getAscent());
            else
                childrenPoints[0] = childFigure.getBounds().getLeft().translate(-4, 0);
        } else {
            childrenPoints = new Point[childrenSize];
            for (int i = 0; i < childrenSize; i++) {
                childFigure = children.get(i);
                if (childFigure instanceof IEntityFigure)
                    childrenPoints[i] = childFigure.getBounds().getTopLeft().translate(-6, ((IEntityFigure) childFigure).getAscent());
                else
                    childrenPoints[i] = childFigure.getBounds().getLeft().translate(-6, 0);
            }
        }
    }
    graphics.setForegroundColor(ColorConstants.lightGray);
    graphics.setLineStyle(SWT.LINE_CUSTOM);
    graphics.setLineDash(new int[] { 1, 1 });
    DrawUtils.drawOutline(graphics, rootPoint, childrenPoints);
    graphics.setLineStyle(SWT.LINE_SOLID);
    graphics.setLineDash((int[]) null);
}
Also used : TableRowFigure(org.whole.lang.ui.figures.TableRowFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) ITextFigure(org.whole.lang.ui.figures.ITextFigure) TableFigure(org.whole.lang.ui.figures.TableFigure) Point(org.eclipse.draw2d.geometry.Point) TableLayout(org.whole.lang.ui.layout.TableLayout) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with TableFigure

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

the class SimpleEntityOutlineFigure method createTableFigure.

protected TableFigure createTableFigure(int columns) {
    return new TableFigure(new TableLayout(columns).withColumnSpacing(10).withRowSpacing(2).withMargin(0, 24, 0, 0)) {

        protected void paintFigure(Graphics g) {
            super.paintFigure(g);
            TableLayout l = getLayoutManager();
            if (l.rows() == 0)
                return;
            g.setBackgroundColor(ColorConstants.lightGray);
            drawAlternateColumnsBackground(g, 0);
            g.setForegroundColor(ColorConstants.lightGray);
            drawColumnSeparators(g);
        }
    };
}
Also used : Graphics(org.eclipse.draw2d.Graphics) TableFigure(org.whole.lang.ui.figures.TableFigure) TableLayout(org.whole.lang.ui.layout.TableLayout)

Example 3 with TableFigure

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

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

the class SimpleEntityTableFigure method createTableFigure.

protected TableFigure createTableFigure(int columns) {
    return new TableFigure(new TableLayout(columns).withColumnSpacing(10).withRowSpacing(2).withMargin(0, 16, 0, 0)) {

        protected void paintFigure(Graphics g) {
            super.paintFigure(g);
            TableLayout l = getLayoutManager();
            if (l.rows() == 0)
                return;
            g.setForegroundColor(ColorConstants.lightGray);
            drawColumnSeparators(g);
        // drawTableRowsBorder(g);
        }
    };
}
Also used : Graphics(org.eclipse.draw2d.Graphics) TableFigure(org.whole.lang.ui.figures.TableFigure) TableLayout(org.whole.lang.ui.layout.TableLayout)

Example 5 with TableFigure

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

the class SimpleEntityTreeTableFigure method createTableFigure.

protected TableFigure createTableFigure(int columns) {
    return new TableFigure(new TableLayout(columns).withColumnSpacing(10).withMarginTop(0).withMarginBottom(0)) {

        protected void paintFigure(Graphics g) {
            super.paintFigure(g);
            g.setBackgroundColor(ColorConstants.lightGray);
            drawAlternateColumnsBackground(g, 0);
            g.setForegroundColor(FigureConstants.blueColor);
            drawHeadersRowSeparator(g);
            g.setForegroundColor(ColorConstants.lightGray);
            drawColumnSeparators(g);
            int oldAlpha = g.getAlpha();
            g.setAlpha(80);
            drawRowSeparators(g);
            g.setAlpha(oldAlpha);
        }
    };
}
Also used : Graphics(org.eclipse.draw2d.Graphics) TableFigure(org.whole.lang.ui.figures.TableFigure) TableLayout(org.whole.lang.ui.layout.TableLayout) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

TableFigure (org.whole.lang.ui.figures.TableFigure)7 TableLayout (org.whole.lang.ui.layout.TableLayout)6 Graphics (org.eclipse.draw2d.Graphics)4 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)4 Point (org.eclipse.draw2d.geometry.Point)3 TableRowFigure (org.whole.lang.ui.figures.TableRowFigure)3 IFigure (org.eclipse.draw2d.IFigure)2 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)2 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 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1 ITextFigure (org.whole.lang.ui.figures.ITextFigure)1 StringSeparatedCompositeColumnFigure (org.whole.lang.ui.figures.StringSeparatedCompositeColumnFigure)1 StringSeparatedCompositeRowFigure (org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure)1 MonoLayout (org.whole.lang.ui.layout.MonoLayout)1 TableRowLayout (org.whole.lang.ui.layout.TableRowLayout)1 CompositeTableFigure (org.whole.lang.ui.notations.styledtree.figures.CompositeTableFigure)1 NodeWithCompositeBranchFigure (org.whole.lang.ui.notations.styledtree.figures.NodeWithCompositeBranchFigure)1