Search in sources :

Example 21 with IEntityFigure

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

the class TableRowLayout method updateMyTabularLayoutServer.

public void updateMyTabularLayoutServer(IFigure container) {
    IFigure parent = container.getParent();
    ITabularLayoutServer tls = (parent instanceof IEntityFigure) ? ((IEntityFigure) parent).getTabularLayoutServer() : null;
    if (tls != null)
        myTabularLayoutServer = tls;
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 22 with IEntityFigure

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

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

the class EntityOutlineLeftFigure 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();
            childrenPoints[i] = row.getBounds().getRight().translate(+8, 0);
            if (row instanceof TableRowFigure && !rowChildren.isEmpty())
                childrenPoints[i].y = ((TableRowLayout) row.getLayoutManager()).getBaseline(1);
        }
    } else {
        List<IFigure> children = ((IFigure) childrenFigure).getChildren();
        int childrenSize = children.size();
        if (childrenSize == 0)
            return;
        childrenPoints = new Point[childrenSize];
        for (int i = 0; i < childrenSize; i++) {
            IFigure childFigure = children.get(i);
            if (childFigure instanceof IEntityFigure)
                childrenPoints[i] = childFigure.getBounds().getTopRight().translate(+6, ((IEntityFigure) childFigure).getAscent());
            else
                childrenPoints[i] = childFigure.getBounds().getRight().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) TableFigure(org.whole.lang.ui.figures.TableFigure) TableRowLayout(org.whole.lang.ui.layout.TableRowLayout) 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 24 with IEntityFigure

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

the class AbstractOutlineSimpleNodeFigure method addChildrenLocations.

protected void addChildrenLocations(Point reference, List<Point> childrenLocations, IFigure featureChild) {
    if (featureChild instanceof INodeFigure) {
        for (Point targetLocation : ((INodeFigure) featureChild).getTargetAnchorLocations(reference)) {
            translateToRelative(targetLocation);
            childrenLocations.add(targetLocation);
        }
    } else {
        Rectangle featureChildBounds = featureChild.getBounds();
        Point targetLocation = featureChildBounds.getLeft();
        if (featureChild instanceof IEntityFigure)
            targetLocation.y = featureChildBounds.y + ((IEntityFigure) featureChild).getAscent();
        featureChild.translateToAbsolute(targetLocation);
        translateToRelative(targetLocation);
        childrenLocations.add(targetLocation);
    }
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) INodeFigure(org.whole.lang.ui.figures.INodeFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 25 with IEntityFigure

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

the class AbstractContentPaneManagerPart method propertyChangeUI.

@Override
protected void propertyChangeUI(PropertyChangeEvent evt) {
    IEntity entity = getModelEntity();
    FeatureDescriptor fd = entity.wGetEntityDescriptor().getFeatureDescriptorEnum().valueOf(evt.getPropertyName());
    int index = entity.wGetEntityDescriptor().indexOf(fd);
    ((IEntityFigure) getFigure()).setContentPaneVisible(index, true);
    super.propertyChangeUI(evt);
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Aggregations

IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)25 IFigure (org.eclipse.draw2d.IFigure)10 Rectangle (org.eclipse.draw2d.geometry.Rectangle)6 IEntity (org.whole.lang.model.IEntity)5 EntityFigure (org.whole.lang.ui.figures.EntityFigure)5 Point (org.eclipse.draw2d.geometry.Point)4 TableFigure (org.whole.lang.ui.figures.TableFigure)4 List (java.util.List)3 Graphics (org.eclipse.draw2d.Graphics)3 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)3 TableRowFigure (org.whole.lang.ui.figures.TableRowFigure)3 RowLayout (org.whole.lang.ui.layout.RowLayout)3 TableLayout (org.whole.lang.ui.layout.TableLayout)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)2 IGraphicalEntityPart (org.whole.lang.ui.editparts.IGraphicalEntityPart)2 INodeFigure (org.whole.lang.ui.figures.INodeFigure)2 StringSeparatedCompositeRowFigure (org.whole.lang.ui.figures.StringSeparatedCompositeRowFigure)2 ICompositeEntityLayout (org.whole.lang.ui.layout.ICompositeEntityLayout)2 Label (org.eclipse.draw2d.Label)1