Search in sources :

Example 1 with AbstractTableContainer

use of org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer in project tdi-studio-se by Talend.

the class ZoneContentLayout method layout.

@Override
public void layout(IFigure parent) {
    Rectangle vBounds = null;
    if (parent.getParent() instanceof Viewport) {
        vBounds = ((Viewport) parent.getParent()).getBounds();
    }
    int wHint = -1;
    int hHint = -1;
    if (isHorizontal()) {
        hHint = parent.getClientArea(Rectangle.SINGLETON).height;
    } else {
        wHint = parent.getClientArea(Rectangle.SINGLETON).width;
    }
    List children = parent.getChildren();
    int numChildren = children.size();
    Rectangle clientArea = transposer.t(parent.getClientArea());
    int x = clientArea.x;
    int y = clientArea.y;
    int availableHeight = clientArea.height;
    Dimension[] prefSizes = new Dimension[numChildren];
    Dimension[] minSizes = new Dimension[numChildren];
    IFigure child;
    int totalHeight = 0;
    int totalMinHeight = 0;
    int prefMinSumHeight = 0;
    int connSize = 0;
    // boolean isLookupConnMax = true;
    for (int i = 0; i < numChildren; i++) {
        child = (IFigure) children.get(i);
        prefSizes[i] = transposer.t(getChildPreferredSize(child, wHint, hHint));
        minSizes[i] = transposer.t(getChildMinimumSize(child, wHint, hHint));
        totalHeight += prefSizes[i].height;
        totalMinHeight += minSizes[i].height;
        if (child instanceof AbstractTableContainer) {
            connSize = getLookupConnectionSize((AbstractTableContainer) child);
        }
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    prefMinSumHeight = totalHeight - totalMinHeight;
    int defaultSize = DEFAULT_OFFSET;
    for (int i = 0; i < numChildren; i++) {
        int amntShrinkCurrentHeight = 0;
        int prefHeight = prefSizes[i].height;
        int minHeight = minSizes[i].height;
        int prefWidth = prefSizes[i].width;
        int minWidth = minSizes[i].width;
        child = (IFigure) children.get(i);
        Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
        if (connSize > 0) {
            newBounds = new Rectangle(x + (connSize - 1) * defaultSize, y, prefWidth, prefHeight);
        }
        Border border = parent.getBorder();
        Insets insets = border.getInsets(child);
        if (vBounds != null) {
            newBounds.width = vBounds.width - insets.left - insets.right;
            if (connSize > 0) {
                newBounds.width = newBounds.width - (connSize - 1) * defaultSize;
            }
        }
        newBounds.height -= amntShrinkCurrentHeight;
        child.setBounds(transposer.t(newBounds));
        prefMinSumHeight -= (prefHeight - minHeight);
        y += newBounds.height + spacing;
    }
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Viewport(org.eclipse.draw2d.Viewport) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTableContainer(org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer) Border(org.eclipse.draw2d.Border) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with AbstractTableContainer

use of org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer in project tdi-studio-se by Talend.

the class FilterTreeAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    Point ref = null;
    if (tableManager.isMinimized()) {
        ref = tableManager.getEditPart().getFigure().getBounds().getLeft();
    } else {
        if (getOwner() == null) {
            return null;
        } else if (getOwner() instanceof AbstractTableContainer) {
            AbstractTableContainer treeFigure = (AbstractTableContainer) getOwner();
            FilterContainer filterContainer = treeFigure.getFilterContainer();
            if (filterContainer != null) {
                ref = filterContainer.getBounds().getLeft();
            }
        }
    }
    if (ref != null) {
        IFigure treeFigure = tableManager.getEditPart().getFigure();
        int avialableX = treeFigure.getBounds().x;
        if (ref.x < avialableX) {
            ref.x = avialableX;
        }
    }
    if (connectionPart instanceof BaseConnectionEditPart && connectionPart.getFigure() instanceof PolylineConnection) {
        BaseConnectionEditPart baseConnectionPart = (BaseConnectionEditPart) connectionPart;
        PolylineConnection connFigure = (PolylineConnection) connectionPart.getFigure();
        org.eclipse.swt.graphics.Point avilableSize = tableManager.getGraphicalViewer().getControl().getSize();
        if (ref != null) {
            if (ref.y < 0) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = 0;
                }
                baseConnectionPart.setTargetContained(false);
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else if (ref.y > avilableSize.y) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = avilableSize.y;
                }
                baseConnectionPart.setTargetContained(false);
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else {
                baseConnectionPart.setTargetContained(true);
                if (!baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            }
        }
    }
    return ref;
}
Also used : FilterContainer(org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer) Point(org.eclipse.draw2d.geometry.Point) LookupConnectionPart(org.talend.designer.gefabstractmap.part.LookupConnectionPart) AbstractTableContainer(org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)2 AbstractTableContainer (org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer)2 List (java.util.List)1 Border (org.eclipse.draw2d.Border)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Viewport (org.eclipse.draw2d.Viewport)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Insets (org.eclipse.draw2d.geometry.Insets)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 FilterContainer (org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer)1 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)1 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)1