Search in sources :

Example 1 with TableEntityElement

use of org.talend.designer.gefabstractmap.figures.table.entity.TableEntityElement 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

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