Search in sources :

Example 1 with EntityFigure

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

the class CompositeEntityReferenceTextFigure method setAdjacentSize.

public void setAdjacentSize(int size) {
    for (int i = compositeFigure.getChildren().size(); i < size; i++) {
        EntityFigure featureRow = new EntityFigure(new TableRowLayout().withMinorAlignment(Alignment.LEADING));
        featureRow.add(new EntityButton(linkListener, i));
        compositeFigure.add(featureRow);
    }
    while (compositeFigure.getChildren().size() > size) compositeFigure.remove((IFigure) compositeFigure.getChildren().get(size));
    revalidate();
    repaint();
}
Also used : EntityFigure(org.whole.lang.ui.figures.EntityFigure) TableRowLayout(org.whole.lang.ui.layout.TableRowLayout) EntityButton(org.whole.lang.ui.figures.EntityButton) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with EntityFigure

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

the class AbstractConnectedFreeformRootPart method createFigure.

protected IFigure createFigure() {
    // Figure figure = new FreeformLayer();
    IEntityFigure figure = new EntityFigure() {

        {
            setLayoutManager(new EntityXYLayout());
            setOpaque(false);
        }

        // FIXME workaround
        public int getIndent() {
            return getInsets().left;
        }

        public int getAscent() {
            return getPreferredSize().height / 2;
        }

        public static final int MINIMUM_SIZE = 50;

        public Dimension getPreferredSize(int wHint, int hHint) {
            Dimension size = super.getPreferredSize(wHint, hHint);
            size.width = Math.max(size.width, MINIMUM_SIZE);
            size.height = Math.max(size.height, MINIMUM_SIZE);
            return size;
        }
    };
    // figure.setLayoutManager(new EntityXYLayout());
    // figure.setOpaque(false);
    setConnectionRouter(createConnectionRouter(figure));
    return figure;
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) Dimension(org.eclipse.draw2d.geometry.Dimension) EntityXYLayout(org.whole.lang.ui.layout.EntityXYLayout)

Example 3 with EntityFigure

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

the class SimpleEntityTreeFigure method createFeaturesOutline.

protected IFigure createFeaturesOutline(EntityDescriptor<?> ed, ActionListener linkListener) {
    int featureNum = ed.childFeatureSize();
    IFigure featuresOutline = new EntityFigure(new ColumnLayout().withAutoresizeWeight(1.0f).withMarginBottom(2).withMinorAlignment(isRightToLeft() ? Alignment.LEADING : Alignment.TRAILING));
    featureToggles = new Toggle[featureNum];
    for (int i = 0; i < featureNum; i++) {
        FeatureDescriptor fd = ed.getEntityFeatureDescriptor(i);
        EntityFigure feature = new EntityFigure(new RowLayout().withSpacing(3).withMajorAlignment(isRightToLeft() ? Alignment.LEADING : Alignment.TRAILING).withReversedChildren(isRightToLeft()));
        feature.addLabel(fd.getName());
        featureToggles[i] = createFoldingToggle(new EntityToggle(WholeImages.ROUND_EXPAND, WholeImages.ROUND_COLLAPSE), i);
        feature.add(featureToggles[i]);
        featuresOutline.add(feature);
    }
    for (int i = featureNum, size = ed.featureSize(); i < size; i++) {
        FeatureDescriptor fd = ed.getEntityFeatureDescriptor(i);
        EntityFigure feature = new EntityFigure(new RowLayout().withMarginLeft(3).withMarginRight(3).withMajorAlignment(isRightToLeft() ? Alignment.LEADING : Alignment.TRAILING).withReversedChildren(isRightToLeft()));
        EntityLabel createLabel = feature.addLabel(fd.getName(), WholeImages.LINK);
        createLabel.setTextPlacement(isRightToLeft() ? PositionConstants.EAST : PositionConstants.WEST);
        createLabel.setBorder(new MarginBorder(3));
        feature.add(new EntityButton(createLabel, linkListener, i));
        featuresOutline.add(feature);
    }
    return featuresOutline;
}
Also used : EntityFigure(org.whole.lang.ui.figures.EntityFigure) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) EntityButton(org.whole.lang.ui.figures.EntityButton) ColumnLayout(org.whole.lang.ui.layout.ColumnLayout) RowLayout(org.whole.lang.ui.layout.RowLayout) MarginBorder(org.eclipse.draw2d.MarginBorder) EntityToggle(org.whole.lang.ui.figures.EntityToggle) EntityLabel(org.whole.lang.ui.figures.EntityLabel) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with EntityFigure

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

the class RootFragmentPart method createFigure.

protected IFigure createFigure() {
    // Figure f = new FreeformLayer() {
    IEntityFigure f = new EntityFigure() {

        {
            setOpaque(false);
        }

        @Override
        public void paint(Graphics graphics) {
            graphics.setAdvanced(true);
            graphics.setAntialias(SWT.ON);
            super.paint(graphics);
        }

        protected void paintFigure(Graphics graphics) {
            super.paintFigure(graphics);
            Rectangle r2 = ((IFigure) getChildren().get(0)).getBounds();
            translateToParent(r2 = r2.getCopy());
            Rectangle clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
            graphics.fillRectangle(clipArea);
            graphics.setBackgroundColor(FigureConstants.hostLanguageColor);
            graphics.fillRectangle(clipArea.intersect(r2));
            graphics.setLineWidth(1);
            graphics.setLineStyle(Graphics.LINE_SOLID);
            graphics.setXORMode(false);
            IEntity rootEntity = ((RootFragment) getModelEntity()).getRootEntity().wGetAdaptee(false);
            if (rootEntity.wGetParent() instanceof RootFragment) {
                clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
                int oldAlpha = graphics.getAlpha();
                graphics.setAlpha(60);
                graphics.setForegroundColor(ColorConstants.darkGray);
                graphics.setLineWidth(1);
                graphics.drawRectangle(r2.getTranslated(-1, -1).resize(1, 1));
                graphics.setForegroundColor(ColorConstants.lightGray);
                graphics.setLineWidth(5);
                graphics.drawRoundRectangle(r2.getTranslated(-4, -4).resize(7, 7), 10, 10);
                graphics.setAlpha(oldAlpha);
            } else {
                graphics.setForegroundColor(ColorConstants.lightGray);
                graphics.drawRectangle(r2.x - 1, r2.y - 1, r2.width + 1, r2.height + 1);
            }
        }

        public void validate() {
            super.validate();
            repaint();
        }
    };
    f.setLayoutManager(new StackLayout().withMargin(5).withMinorAlignment(Alignment.CENTER));
    f.setBackgroundColor(FigureUtilities.lighter(ColorConstants.gray));
    f.setOpaque(false);
    f.addLayoutListener(LayoutAnimator.getDefault());
    return f;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) EntityFigure(org.whole.lang.ui.figures.EntityFigure) IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IEntity(org.whole.lang.model.IEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) StackLayout(org.whole.lang.ui.layout.StackLayout) RootFragment(org.whole.lang.commons.model.RootFragment) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with EntityFigure

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

the class SplitPart method createFigure.

protected IFigure createFigure() {
    IFigure f = new EntityFigure(new OverColumnLayout().withSpacing(4).withMinorAlignment(// CENTER).withAutoresizeWeight(1f));
    Alignment.FILL));
    f.setBorder(new PipeBracketsBorder(0, 1, 0, 1));
    return f;
}
Also used : PipeBracketsBorder(org.whole.lang.ui.figures.PipeBracketsBorder) EntityFigure(org.whole.lang.ui.figures.EntityFigure) OverColumnLayout(org.whole.lang.ui.layout.OverColumnLayout) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

EntityFigure (org.whole.lang.ui.figures.EntityFigure)20 RowLayout (org.whole.lang.ui.layout.RowLayout)13 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)6 IFigure (org.eclipse.draw2d.IFigure)5 EntityButton (org.whole.lang.ui.figures.EntityButton)4 Graphics (org.eclipse.draw2d.Graphics)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 IEntity (org.whole.lang.model.IEntity)2 EntityLabel (org.whole.lang.ui.figures.EntityLabel)2 ColumnLayout (org.whole.lang.ui.layout.ColumnLayout)2 EntityXYLayout (org.whole.lang.ui.layout.EntityXYLayout)2 TableRowLayout (org.whole.lang.ui.layout.TableRowLayout)2 MarginBorder (org.eclipse.draw2d.MarginBorder)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 RootFragment (org.whole.lang.commons.model.RootFragment)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)1 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)1 EntityToggle (org.whole.lang.ui.figures.EntityToggle)1