Search in sources :

Example 1 with FilterContainer

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

the class TableContainerLayout method calculateChildrenSize.

private Dimension calculateChildrenSize(List children, int wHint, int hHint, boolean preferred) {
    Dimension childSize;
    IFigure child;
    int height = 0, width = 0;
    for (int i = 0; i < children.size(); i++) {
        child = (IFigure) children.get(i);
        if (child instanceof AbstractTreeSettingContainer) {
            if (!tableMananger.isActivateCondensedTool()) {
                continue;
            }
        }
        if (child instanceof FilterContainer) {
            if (!tableMananger.isActivateExpressionFilter()) {
                continue;
            }
        }
        if (child instanceof AbstractGlobalMapContainer) {
            if (!tableMananger.isActivateGlobalMap()) {
                continue;
            }
        }
        childSize = transposer.t(preferred ? getChildPreferredSize(child, wHint, hHint) : getChildMinimumSize(child, wHint, hHint));
        height += childSize.height;
        width = Math.max(width, childSize.width);
        // header figure must be the first figure , or there will be problem here
        if (tableMananger.isMinimized()) {
            break;
        }
    }
    return new Dimension(width, height);
}
Also used : FilterContainer(org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer) AbstractGlobalMapContainer(org.talend.designer.gefabstractmap.figures.table.AbstractGlobalMapContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTreeSettingContainer(org.talend.designer.gefabstractmap.figures.treesettings.AbstractTreeSettingContainer) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with FilterContainer

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

the class TableContainerLayout method layout.

@Override
public void layout(IFigure parent) {
    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];
    int wHint = -1;
    int hHint = -1;
    if (isHorizontal()) {
        hHint = parent.getClientArea(Rectangle.SINGLETON).height;
    } else {
        wHint = parent.getClientArea(Rectangle.SINGLETON).width;
    }
    IFigure child;
    int totalHeight = 0;
    int totalMinHeight = 0;
    int prefMinSumHeight = 0;
    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;
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    prefMinSumHeight = totalHeight - totalMinHeight;
    int amntShrinkHeight = totalHeight - Math.max(availableHeight, totalMinHeight);
    if (amntShrinkHeight < 0) {
        amntShrinkHeight = 0;
    }
    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;
        Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
        child = (IFigure) children.get(i);
        if (child instanceof AbstractTreeSettingContainer) {
            if (!tableMananger.isActivateCondensedTool()) {
                child.setBounds(new Rectangle(x, y, 0, 0));
                continue;
            }
        }
        if (child instanceof FilterContainer) {
            if (!tableMananger.isActivateExpressionFilter()) {
                child.setBounds(new Rectangle(x, y, 0, 0));
                continue;
            }
        }
        if (child instanceof AbstractGlobalMapContainer) {
            if (!tableMananger.isActivateGlobalMap()) {
                child.setBounds(new Rectangle(x, y, 0, 0));
                continue;
            }
        }
        int width = Math.min(prefWidth, transposer.t(child.getMaximumSize()).width);
        if (matchWidth) {
            width = transposer.t(child.getMaximumSize()).width;
        }
        width = Math.max(minWidth, Math.min(clientArea.width, width));
        newBounds.width = width;
        child.setBounds(transposer.t(newBounds));
        amntShrinkHeight -= amntShrinkCurrentHeight;
        prefMinSumHeight -= (prefHeight - minHeight);
        y += newBounds.height + spacing;
        if (child instanceof ScrollPane) {
            IFigure contents = ((ScrollPane) child).getViewport().getContents();
            if (contents instanceof AbstractTable) {
            // ((AbstractTable) contents).setDefautTableWidth(newBounds.width);
            }
        }
    }
}
Also used : AbstractTable(org.talend.designer.gefabstractmap.figures.table.AbstractTable) ScrollPane(org.eclipse.draw2d.ScrollPane) FilterContainer(org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer) AbstractGlobalMapContainer(org.talend.designer.gefabstractmap.figures.table.AbstractGlobalMapContainer) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractTreeSettingContainer(org.talend.designer.gefabstractmap.figures.treesettings.AbstractTreeSettingContainer) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with FilterContainer

use of org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer 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)3 FilterContainer (org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 AbstractGlobalMapContainer (org.talend.designer.gefabstractmap.figures.table.AbstractGlobalMapContainer)2 AbstractTreeSettingContainer (org.talend.designer.gefabstractmap.figures.treesettings.AbstractTreeSettingContainer)2 List (java.util.List)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 ScrollPane (org.eclipse.draw2d.ScrollPane)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 AbstractTable (org.talend.designer.gefabstractmap.figures.table.AbstractTable)1 AbstractTableContainer (org.talend.designer.gefabstractmap.figures.table.AbstractTableContainer)1 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)1 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)1