Search in sources :

Example 1 with ScrollPane

use of org.eclipse.draw2d.ScrollPane 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 2 with ScrollPane

use of org.eclipse.draw2d.ScrollPane in project tdi-studio-se by Talend.

the class MapperRootEditPart method createFigure.

@Override
protected IFigure createFigure() {
    Figure mainFigure = new Figure();
    XmlMapDataLayout manager2 = new XmlMapDataLayout(getRootModelManager().getGraphicalViewer());
    mainFigure.setLayoutManager(manager2);
    // input
    Figure inputZone = new Figure();
    inputZone.setLayoutManager(new ZoneLayout());
    inputToolBar = createInputZoneToolBar();
    inputToolBar.setBorder(new LineBorder(ColorProviderMapper.getColor(ColorInfo.COLOR_TREE_BORDER)));
    inputZone.add(inputToolBar);
    inputScroll = new ScrollPane();
    inputScroll.setHorizontalScrollBarVisibility(ScrollPane.NEVER);
    leftFigure = new Figure();
    // ToolbarLayout subManager = new ToolbarLayout();
    ToolbarLayout subManager = createZoneContentLayout();
    subManager.setSpacing(20);
    subManager.setVertical(true);
    leftFigure.setLayoutManager(subManager);
    leftFigure.setBorder(new MarginBorder(20, 40, 20, 40));
    inputScroll.getViewport().setContents(leftFigure);
    inputScroll.getViewport().setContentsTracksWidth(true);
    inputZone.add(inputScroll);
    mainFigure.add(inputZone);
    // separator 1
    SashSeparator separatorLeft = new SashSeparator();
    separatorLeft.setImage(ImageProviderMapper.getImage(ImageInfo.ZONE_SASH));
    mainFigure.add(separatorLeft);
    // search , var
    searchToolBar = createSearchZoneToolBar();
    searchToolBar.setBorder(new LineBorder(ColorProviderMapper.getColor(ColorInfo.COLOR_TREE_BORDER)));
    varScroll = new ScrollPane();
    varScroll.setHorizontalScrollBarVisibility(ScrollPane.NEVER);
    centerFigure = new Figure();
    subManager = createZoneContentLayout();
    subManager.setSpacing(20);
    subManager.setVertical(true);
    centerFigure.setLayoutManager(subManager);
    centerFigure.setBorder(new MarginBorder(10, 40, 10, 40));
    varScroll.getViewport().setContents(centerFigure);
    varScroll.getViewport().setContentsTracksWidth(true);
    centerFigure.add(searchToolBar);
    mainFigure.add(varScroll);
    // separetor 2
    SashSeparator separatorRight = new SashSeparator();
    separatorRight.setImage(ImageProviderMapper.getImage(ImageInfo.ZONE_SASH));
    mainFigure.add(separatorRight);
    // output
    Figure outputZone = new Figure();
    outputZone.setLayoutManager(new ZoneLayout());
    outputToolBar = createOutputZoneToolBar();
    outputToolBar.setBorder(new LineBorder(ColorProviderMapper.getColor(ColorInfo.COLOR_TREE_BORDER)));
    outputZone.add(outputToolBar);
    outputScroll = new ScrollPane();
    outputScroll.setHorizontalScrollBarVisibility(ScrollPane.NEVER);
    rightFigure = new Figure();
    subManager = createZoneContentLayout();
    subManager.setSpacing(20);
    subManager.setVertical(true);
    rightFigure.setLayoutManager(subManager);
    rightFigure.setBorder(new MarginBorder(20, 40, 20, 40));
    outputScroll.getViewport().setContents(rightFigure);
    outputScroll.getViewport().setContentsTracksWidth(true);
    outputZone.add(outputScroll);
    mainFigure.add(outputZone);
    mainFigure.setOpaque(true);
    mainFigure.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_BACKGROUND_LINKS_ZONE));
    separatorLeft.setLeftFigure(inputZone);
    separatorLeft.setRightFigure(varScroll);
    separatorLeft.setParentFigure(mainFigure);
    separatorRight.setLeftFigure(varScroll);
    separatorRight.setRightFigure(outputZone);
    separatorRight.setParentFigure(mainFigure);
    return mainFigure;
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) XmlMapDataLayout(org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout) ScrollPane(org.eclipse.draw2d.ScrollPane) LineBorder(org.eclipse.draw2d.LineBorder) MarginBorder(org.eclipse.draw2d.MarginBorder) SashSeparator(org.talend.designer.gefabstractmap.figures.sash.SashSeparator) IFigure(org.eclipse.draw2d.IFigure) Figure(org.eclipse.draw2d.Figure)

Example 3 with ScrollPane

use of org.eclipse.draw2d.ScrollPane in project tdi-studio-se by Talend.

the class AbstractTableContainer method createContents.

protected void createContents() {
    setLayoutManager(new TableContainerLayout(tableModelManager));
    this.setBorder(new LineBorder(ColorProviderMapper.getColor(ColorInfo.COLOR_TREE_BORDER)));
    header = new Figure();
    header.setOpaque(true);
    header.setBackgroundColor(ColorConstants.tooltipBackground);
    header.setBorder(new RowBorder());
    header.setLayoutManager(new EqualWidthLayout());
    Label tableName = new Label();
    // tableName.setBorder(new LineBorder(ColorConstants.black));
    tableName.setText(getTreeDisplayName());
    tableName.setFont(FontProviderMapper.getFont(FontInfo.FONT_SYSTEM_BOLD));
    tableName.setLabelAlignment(PositionConstants.LEFT);
    tableName.setBorder(new MarginBorder(5, 10, 5, -1));
    header.add(tableName);
    toolBarContainer = createToolBarContainer();
    header.setOpaque(true);
    header.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.ZONE_BACKGROUND_COLOR));
    this.add(header);
    if (toolBarContainer != null) {
        header.add(toolBarContainer);
    }
    createTreeSettings(this);
    if (withScroll) {
        ScrollPane scroll = new ScrollPane();
        scroll.setVerticalScrollBarVisibility(ScrollPane.NEVER);
        scroll.getViewport().setContents(createTable());
        scroll.getViewport().setContentsTracksWidth(true);
        // ///
        scroll.setBackgroundColor(ColorConstants.white);
        scroll.setOpaque(true);
        this.add(scroll);
    } else {
        this.add(createTable());
    }
}
Also used : RowBorder(org.talend.designer.gefabstractmap.figures.borders.RowBorder) ScrollPane(org.eclipse.draw2d.ScrollPane) LineBorder(org.eclipse.draw2d.LineBorder) MarginBorder(org.eclipse.draw2d.MarginBorder) Label(org.eclipse.draw2d.Label) TableContainerLayout(org.talend.designer.gefabstractmap.figures.layout.TableContainerLayout) EqualWidthLayout(org.talend.designer.gefabstractmap.figures.layout.EqualWidthLayout) IFigure(org.eclipse.draw2d.IFigure) GenericFigure(org.talend.designer.gefabstractmap.figures.GenericFigure) Figure(org.eclipse.draw2d.Figure)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)3 ScrollPane (org.eclipse.draw2d.ScrollPane)3 Figure (org.eclipse.draw2d.Figure)2 LineBorder (org.eclipse.draw2d.LineBorder)2 MarginBorder (org.eclipse.draw2d.MarginBorder)2 List (java.util.List)1 Label (org.eclipse.draw2d.Label)1 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GenericFigure (org.talend.designer.gefabstractmap.figures.GenericFigure)1 RowBorder (org.talend.designer.gefabstractmap.figures.borders.RowBorder)1 EqualWidthLayout (org.talend.designer.gefabstractmap.figures.layout.EqualWidthLayout)1 TableContainerLayout (org.talend.designer.gefabstractmap.figures.layout.TableContainerLayout)1 XmlMapDataLayout (org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout)1 SashSeparator (org.talend.designer.gefabstractmap.figures.sash.SashSeparator)1 AbstractGlobalMapContainer (org.talend.designer.gefabstractmap.figures.table.AbstractGlobalMapContainer)1 AbstractTable (org.talend.designer.gefabstractmap.figures.table.AbstractTable)1 AbstractTreeSettingContainer (org.talend.designer.gefabstractmap.figures.treesettings.AbstractTreeSettingContainer)1 FilterContainer (org.talend.designer.gefabstractmap.figures.treesettings.FilterContainer)1