Search in sources :

Example 1 with TreeAnimatingLayer

use of org.talend.commons.ui.swt.geftree.layout.TreeAnimatingLayer in project tdi-studio-se by Talend.

the class TableTreeEntityFigure method getContents.

@Override
public TreeAnimatingLayer getContents() {
    if (this.contentPane == null) {
        contentPane = new TreeAnimatingLayer() {

            public void setBounds(Rectangle rect) {
                int x = bounds.x, y = bounds.y;
                boolean resize = (rect.width != bounds.width) || (rect.height != bounds.height), translate = (rect.x != x) || (rect.y != y);
                if (isVisible() && (resize || translate))
                    erase();
                if (translate) {
                    int dx = rect.x - x;
                    int dy = rect.y - y;
                    primTranslate(dx, dy);
                }
                bounds.width = rect.width;
                bounds.height = rect.height;
                if (resize)
                    invalidate();
                if (resize || translate) {
                    fireFigureMoved();
                    fireCoordinateSystemChanged();
                    repaint();
                }
            }
        };
        ToolbarLayout layout = new ToolbarLayout() {

            @Override
            public void layout(IFigure parent) {
                TreeAnimation.recordInitialState(parent);
                if (TreeAnimation.playbackState(parent)) {
                    return;
                }
                super.layout(parent);
            }

            @Override
            protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
                return super.calculatePreferredSize(container, wHint, hHint);
            }
        };
        layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT);
        contentPane.setLayoutManager(layout);
        this.add(contentPane);
    // ///////test
    // contentPane.setOpaque(true);
    // contentPane.setBackgroundColor(ColorConstants.yellow);
    }
    return contentPane;
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) TreeAnimatingLayer(org.talend.commons.ui.swt.geftree.layout.TreeAnimatingLayer) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with TreeAnimatingLayer

use of org.talend.commons.ui.swt.geftree.layout.TreeAnimatingLayer in project tdi-studio-se by Talend.

the class TableEntityLayout method layout.

@Override
public void layout(IFigure parent) {
    Rectangle clientArea = transposer.t(parent.getClientArea());
    int x = clientArea.x;
    int y = clientArea.y;
    final TreeAnimatingLayer contents = treeNode.getContents();
    final TableEntityElement element = treeNode.getElement();
    final Dimension elementSize = element.getPreferredSize(clientArea.width, -1);
    int maxWidth = Math.max(elementSize.width, clientArea.width);
    Dimension contentsSize = null;
    if (contents != null) {
        contentsSize = contents.getPreferredSize(clientArea.width, -1);
        maxWidth = Math.max(contentsSize.width, elementSize.width);
        // ajust to parent
        if (parent.getParent() instanceof TreeAnimatingLayer) {
            maxWidth = Math.max(maxWidth, parent.getParent().getBounds().width);
        } else {
            maxWidth = Math.max(maxWidth, clientArea.width);
        }
        contentsSize.width = maxWidth;
    }
    elementSize.width = maxWidth;
    Rectangle rectangle = new Rectangle();
    rectangle.setLocation(x, y);
    rectangle.setSize(elementSize);
    element.setBounds(rectangle);
    y = y + rectangle.height;
    if (contents != null) {
        rectangle = new Rectangle();
        rectangle.setLocation(x, y);
        rectangle.setSize(contentsSize);
        contents.setBounds(rectangle);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) TreeAnimatingLayer(org.talend.commons.ui.swt.geftree.layout.TreeAnimatingLayer) Dimension(org.eclipse.draw2d.geometry.Dimension) TableEntityElement(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityElement)

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 TreeAnimatingLayer (org.talend.commons.ui.swt.geftree.layout.TreeAnimatingLayer)2 IFigure (org.eclipse.draw2d.IFigure)1 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 TableEntityElement (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityElement)1