Search in sources :

Example 1 with ICompositeEntityLayout

use of org.whole.lang.ui.layout.ICompositeEntityLayout in project whole by wholeplatform.

the class CompositeEntityOutlineFigure method paintConnections.

@SuppressWarnings("unchecked")
protected void paintConnections(Graphics graphics) {
    graphics.setForegroundColor(FigureConstants.contentLighterColor);
    Point rootPoint = getFoldingToggle(0).getBounds().getBottom();
    List<IFigure> children = compositeFigure.getChildren();
    int childrenSize = children.size();
    if (childrenSize == 0)
        return;
    ICompositeEntityLayout layoutManager = compositeFigure.getLayoutManager();
    Point[] childrenPoints = new Point[childrenSize];
    for (int i = 0; i < childrenSize; i++) {
        childrenPoints[i] = children.get(i).getBounds().getLeft().translate(-6, 0);
        childrenPoints[i].y = layoutManager.getBaseline(i);
    }
    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 : ICompositeEntityLayout(org.whole.lang.ui.layout.ICompositeEntityLayout) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ICompositeEntityLayout

use of org.whole.lang.ui.layout.ICompositeEntityLayout in project whole by wholeplatform.

the class CompositeEntityReferenceOutlineFigure method paintConnections.

@SuppressWarnings("unchecked")
protected void paintConnections(Graphics graphics) {
    graphics.setForegroundColor(FigureConstants.contentLighterColor);
    Point rootPoint = getFoldingToggle(0).getBounds().getBottom();
    List<IFigure> children = compositeFigure.getChildren();
    int childrenSize = children.size();
    if (childrenSize == 0)
        return;
    ICompositeEntityLayout layoutManager = compositeFigure.getLayoutManager();
    Point[] childrenPoints = new Point[childrenSize];
    for (int i = 0; i < childrenSize; i++) {
        childrenPoints[i] = children.get(i).getBounds().getLeft();
        childrenPoints[i].y = layoutManager.getBaseline(i);
    }
    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 : ICompositeEntityLayout(org.whole.lang.ui.layout.ICompositeEntityLayout) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with ICompositeEntityLayout

use of org.whole.lang.ui.layout.ICompositeEntityLayout in project whole by wholeplatform.

the class ConcatenateFigure method paintFigure.

@SuppressWarnings("unchecked")
protected void paintFigure(Graphics g) {
    super.paintFigure(g);
    ICompositeEntityLayout lm = getLayoutManager();
    int baseline = getBounds().y + getAscent();
    int x = getBounds().x;
    int y = baseline;
    g.drawLine(x - 1, baseline, x + lm.getMarginLeft() + 1, baseline);
    List<IFigure> children = (List<IFigure>) getChildren();
    int size = children.size();
    int interline = 0;
    int py = 0;
    IEntityFigure childFigure;
    Rectangle childBounds = null;
    Rectangle prevBounds = null;
    if (size > 1) {
        childFigure = (IEntityFigure) children.get(0);
        childBounds = childFigure.getBounds();
        y = childBounds.y + childFigure.getAscent();
        for (int i = 1; i < size; i++) {
            interline = Math.max(interline, childBounds.bottom() + 4);
            prevBounds = childBounds;
            py = y;
            childFigure = (IEntityFigure) children.get(i);
            childBounds = childFigure.getBounds();
            x = childBounds.x - 1;
            y = childBounds.y + childFigure.getAscent();
            if (y > py) {
                int px = prevBounds.right() + 1;
                g.drawLine(px - 2, py, px, py);
                g.drawLine(px, py, px, interline);
                g.drawLine(x - lm.getSpacingBefore(i) / 2, interline, px, interline);
                g.drawLine(x - lm.getSpacingBefore(i) / 2, interline, x - lm.getSpacingBefore(i) / 2, y);
                interline = 0;
            }
            g.drawLine(x - lm.getSpacingBefore(i), y, x + 1, y);
        }
    }
    int right = getBounds().right() - 1;
    int lastX = childBounds != null ? childBounds.right() - 1 : right - lm.getMarginRight();
    g.drawLine(lastX, y, right, y);
    g.drawLine(right, y, right, baseline);
}
Also used : ICompositeEntityLayout(org.whole.lang.ui.layout.ICompositeEntityLayout) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with ICompositeEntityLayout

use of org.whole.lang.ui.layout.ICompositeEntityLayout 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 5 with ICompositeEntityLayout

use of org.whole.lang.ui.layout.ICompositeEntityLayout in project whole by wholeplatform.

the class SimpleEntityTreeFigure method toggleVisibility.

@Override
protected void toggleVisibility(int paneIndex) {
    if (paneIndex == getVisibilityTag()) {
        int visibleSize = contentPanes.length;
        if (getFoldingToggle(1).isSelected())
            for (int i = 0, size = contentPanes.length; i < size; i++) {
                boolean childVisible = visibilityManager.isChildVisible(i);
                if (!childVisible)
                    visibleSize--;
                setContentPaneVisible(i, childVisible);
            }
        else
            for (int i = 0, size = contentPanes.length; i < size; i++) setContentPaneVisible(i, true);
        ((ICompositeEntityLayout) getLayoutManager()).withSpacing(DrawUtils.SPACING + DrawUtils.EDGE_SPACING * visibleSize);
    } else if (paneIndex == getContentPanesSize()) {
        boolean visible = getFeaturesFigure().isVisible();
        getContentsFigure().setVisible(!visible);
        getFeaturesFigure().setVisible(!visible);
    } else
        super.toggleVisibility(paneIndex);
}
Also used : ICompositeEntityLayout(org.whole.lang.ui.layout.ICompositeEntityLayout) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

ICompositeEntityLayout (org.whole.lang.ui.layout.ICompositeEntityLayout)5 IFigure (org.eclipse.draw2d.IFigure)3 Point (org.eclipse.draw2d.geometry.Point)3 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)2 List (java.util.List)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 IEntity (org.whole.lang.model.IEntity)1 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1 ColumnLayout (org.whole.lang.ui.layout.ColumnLayout)1 RowLayout (org.whole.lang.ui.layout.RowLayout)1