Search in sources :

Example 16 with CompositeFigure

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

the class CompositeEntityStyledTreePart method createFigure.

protected IFigure createFigure() {
    if (entityStyling.getLayoutStyle().equals(LayoutStyle.COMPOSITE_TABLE)) {
        return new CompositeTableFigure(entityStyling) {

            protected int getChildrenPaneIndex() {
                return 0;
            }

            protected IEntityFigure createTypeLabelFigure() {
                IEntityFigure typeFigure = new EntityFigure(new MonoLayout().withMargin(2, 4, 2, 8).withAutoresizeWeight(1.0f)).withViewportTracking(ViewportTracking.HORIZONTAL);
                typeFigure.add(LabelFactory.createDeclaration(entityStyling.getTypeLabel()));
                return typeFigure;
            }

            protected IEntityFigure createChildrenFigure() {
                TableFigure tableFigure = new TableFigure(Math.max(1, featuresStyling.length)) {

                    protected void paintFigure(Graphics g) {
                        super.paintFigure(g);
                        g.setBackgroundColor(ColorConstants.lightGray);
                        g.setForegroundColor(ColorConstants.lightGray);
                        if (getLayoutManager().hasHeaderRow()) {
                            drawHeadersRowBackground(g);
                            drawHeadersRowSeparator(g);
                        }
                        drawColumnSeparators(g);
                        int oldAlpha = g.getAlpha();
                        g.setAlpha(80);
                        drawRowSeparators(g);
                        drawTableColumnsBorder(g);
                        drawTableRowsBorder(g);
                        g.setAlpha(oldAlpha);
                    }
                };
                if (featuresStyling.length > 0) {
                    TableRowFigure tableHeaderFigure = new TableRowFigure();
                    TableLayout tableLayout = tableFigure.getLayoutManager();
                    int i = 0;
                    for (IFeatureStyling fs : featuresStyling) {
                        tableHeaderFigure.addLabel(fs.getName());
                        tableLayout.withColumnAlignment(i++, fs.getAlignment());
                    }
                    tableFigure.add(tableHeaderFigure, TableLayout.Placement.HEADER);
                }
                return createContentPane(getChildrenPaneIndex(), tableFigure);
            }
        };
    } else
        return new NodeWithCompositeBranchFigure(entityStyling) {

            @Override
            protected int getChildrenPaneIndex() {
                return 0;
            }

            @Override
            protected IEntityFigure createTypeLabelFigure() {
                String name = entityStyling.getTypeLabel();
                return LabelFactory.createDeclaration(name);
            }

            @Override
            protected IEntityFigure createChildrenFigure() {
                CompositeFigure compositeFigure = new CompositeFigure(false);
                compositeFigure.setBorder(CompositePlaceHolderBorder.OPTIONAL_VERTICAL);
                compositeFigure.getLayoutManager().withSpacing(4).withMarginLeft(0).withMarginRight(10).withMinorAlignment(Alignment.LEADING);
                return createContentPane(getChildrenPaneIndex(), compositeFigure);
            }
        };
}
Also used : CompositeTableFigure(org.whole.lang.ui.notations.styledtree.figures.CompositeTableFigure) TableFigure(org.whole.lang.ui.figures.TableFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IFeatureStyling(org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling) Graphics(org.eclipse.draw2d.Graphics) TableRowFigure(org.whole.lang.ui.figures.TableRowFigure) NodeWithCompositeBranchFigure(org.whole.lang.ui.notations.styledtree.figures.NodeWithCompositeBranchFigure) CompositeFigure(org.whole.lang.ui.figures.CompositeFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) MonoLayout(org.whole.lang.ui.layout.MonoLayout) CompositeTableFigure(org.whole.lang.ui.notations.styledtree.figures.CompositeTableFigure) TableLayout(org.whole.lang.ui.layout.TableLayout)

Example 17 with CompositeFigure

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

the class AbstractOutlineSimpleNodeFigure method paintConnections.

@SuppressWarnings("unchecked")
protected void paintConnections(Graphics graphics) {
    if (isContentVisible()) {
        List<IFigure> contents = getContents();
        int featureNumber = contents.size();
        if (featureNumber == 0)
            return;
        Point start = getSourceAnchor(0).getLocation(null);
        List<Point> childrenLocations = new ArrayList<Point>(featureNumber);
        for (int i = 0; i < featureNumber; i++) {
            IFigure childfigure = contents.get(i);
            List<IFigure> children = childfigure.getChildren();
            if (!childfigure.isVisible() || children.isEmpty())
                continue;
            IFigure featureChild = (IFigure) children.get(0);
            // calculate target point position
            if (featureChild instanceof PlaceHolderFigure)
                addChildrenLocations(start, childrenLocations, featureChild);
            else if (featureChild instanceof CompositeFigure) {
                for (Object child : ((IFigure) featureChild).getChildren()) addChildrenLocations(start, childrenLocations, (IFigure) child);
            } else
                addChildrenLocations(start, childrenLocations, featureChild);
        }
        if (childrenLocations.isEmpty())
            return;
        translateToRelative(start);
        graphics.setForegroundColor(ColorConstants.lightGray);
        graphics.setLineDash(new int[] { 1, 1 });
        DrawUtils.drawOutline(graphics, start, childrenLocations.toArray(new Point[0]));
    }
}
Also used : CompositeFigure(org.whole.lang.ui.figures.CompositeFigure) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure) PlaceHolderFigure(org.whole.lang.ui.figures.PlaceHolderFigure)

Example 18 with CompositeFigure

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

the class PremisesPart method createFigure.

protected IFigure createFigure() {
    CompositeFigure compositeFigure = new CompositeFigure(true);
    compositeFigure.getLayoutManager().withSpacing(32);
    return compositeFigure;
}
Also used : CompositeFigure(org.whole.lang.ui.figures.CompositeFigure)

Aggregations

CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)18 Graphics (org.eclipse.draw2d.Graphics)5 IFigure (org.eclipse.draw2d.IFigure)5 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)3 RoundBracketsBorder (org.whole.lang.ui.figures.RoundBracketsBorder)3 Point (org.eclipse.draw2d.geometry.Point)2 TableFigure (org.whole.lang.ui.figures.TableFigure)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompoundBorder (org.eclipse.draw2d.CompoundBorder)1 LineBorder (org.eclipse.draw2d.LineBorder)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 IEntity (org.whole.lang.model.IEntity)1 BlockBracketsBorder (org.whole.lang.queries.ui.figures.BlockBracketsBorder)1 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)1 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1 AbstractCompositePart (org.whole.lang.ui.editparts.AbstractCompositePart)1 CurlyBracketsBorder (org.whole.lang.ui.figures.CurlyBracketsBorder)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1