Search in sources :

Example 1 with XmlMapDataLayout

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

the class MapperDropTargetListener method handleSashDrag.

protected void handleSashDrag(DropTargetEvent event, ISash s) {
    if (s instanceof SashSeparator) {
        SashSeparator separator = (SashSeparator) s;
        final Point dropLocation = getDropLocation();
        Rectangle leftBounds = separator.getLeftFigure().getBounds().getCopy();
        Rectangle rightBounds = separator.getRightFigure().getBounds().getCopy();
        if (dropLocation.x < (leftBounds.x + separator.getZoneMinSize() + separator.getSashWidth()) || dropLocation.x > (rightBounds.x + rightBounds.width - separator.getZoneMinSize() - separator.getSashWidth())) {
            event.detail = DND.DROP_NONE;
            return;
        }
        final LayoutManager layoutManager = separator.getParentFigure().getLayoutManager();
        if (layoutManager instanceof XmlMapDataLayout) {
            XmlMapDataLayout layout = (XmlMapDataLayout) layoutManager;
            int X = getDropLocation().x;
            final Rectangle separatorBounds = separator.getBounds().getCopy();
            separatorBounds.x = X;
            layout.setConstraint(separator, separatorBounds);
            // left figure width
            int wL = X - leftBounds.x;
            // right figure width
            int wR = rightBounds.getTopRight().x - X - separator.getSashWidth();
            int xR = X + separator.getSashWidth();
            if (wL < separator.getZoneMinSize()) {
                wL = separator.getZoneMinSize();
                wR = rightBounds.getTopRight().x - leftBounds.x - separator.getZoneMinSize() - separator.getSashWidth();
                xR = leftBounds.x + separator.getZoneMinSize() + separator.getSashWidth();
            }
            if (wR < separator.getZoneMinSize()) {
                wL = rightBounds.getTopRight().x - separator.getZoneMinSize() - separator.getSashWidth() - leftBounds.x;
                wR = separator.getZoneMinSize();
                xR = rightBounds.getTopRight().x - separator.getZoneMinSize();
            }
            leftBounds.width = wL;
            layout.setConstraint(separator.getLeftFigure(), leftBounds.getCopy());
            separator.getLeftFigure().invalidateTree();
            rightBounds.x = xR;
            rightBounds.width = wR;
            layout.setConstraint(separator.getRightFigure(), rightBounds.getCopy());
            separator.getRightFigure().invalidateTree();
            separator.getParentFigure().revalidate();
        }
    } else if (s instanceof ColumnSash) {
        ColumnSash columnSash = (ColumnSash) s;
        ITable t = columnSash.getTable();
        // if (t instanceof AbstractTable) {
        // AbstractTable table = (AbstractTable) t;
        // Rectangle tableBounds = table.getBounds();
        // int X = getDropLocation().x;
        // if (X < tableBounds.x + columnSash.getSashWidth()
        // || X > tableBounds.x + tableBounds.width - columnSash.getSashWidth()) {
        // event.detail = DND.DROP_NONE;
        // return;
        // }
        //
        // double newExpressionWidth = X - tableBounds.x;
        //
        // double defaultExpressionWidth = table.getDefaultExpressionWidth();
        // double pecnetage = newExpressionWidth / defaultExpressionWidth;
        // table.setExpressWidthPecentage(pecnetage);
        // } else if (t instanceof Table) {
        AbstractTable table = (AbstractTable) t;
        Rectangle tableBounds = table.getBounds();
        int X = getDropLocation().x;
        if (X < tableBounds.x + 10 || X > tableBounds.x + tableBounds.width - 10) {
            event.detail = DND.DROP_NONE;
            return;
        }
        TableColumn leftColumn = columnSash.getLeftColumn();
        TableColumn rightColumn = columnSash.getRightColumn();
        Rectangle leftBounds = leftColumn.getBounds();
        Rectangle rightBounds = rightColumn.getBounds();
        int LW = X - leftBounds.x;
        int RW = rightBounds.x + rightBounds.width - X;
        if (LW < 10) {
            LW = 10;
        }
        if (RW < 10) {
            RW = 10;
        }
        double LP = (double) LW / (double) tableBounds.width;
        double RP = (double) RW / (double) tableBounds.width;
        table.getLayoutManager().setColumnPercentage(leftColumn.getColumnKey(), LP);
        table.getLayoutManager().setColumnPercentage(rightColumn.getColumnKey(), RP);
        table.invalidateTree();
        table.revalidate();
    }
// }
}
Also used : AbstractTable(org.talend.designer.gefabstractmap.figures.table.AbstractTable) XmlMapDataLayout(org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout) LayoutManager(org.eclipse.draw2d.LayoutManager) Rectangle(org.eclipse.draw2d.geometry.Rectangle) SashSeparator(org.talend.designer.gefabstractmap.figures.sash.SashSeparator) ITable(org.talend.designer.gefabstractmap.figures.table.ITable) Point(org.eclipse.draw2d.geometry.Point) ColumnSash(org.talend.designer.gefabstractmap.figures.table.ColumnSash) TableColumn(org.talend.designer.gefabstractmap.figures.table.TableColumn) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with XmlMapDataLayout

use of org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout 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)

Aggregations

XmlMapDataLayout (org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout)2 SashSeparator (org.talend.designer.gefabstractmap.figures.sash.SashSeparator)2 Figure (org.eclipse.draw2d.Figure)1 IFigure (org.eclipse.draw2d.IFigure)1 LayoutManager (org.eclipse.draw2d.LayoutManager)1 LineBorder (org.eclipse.draw2d.LineBorder)1 MarginBorder (org.eclipse.draw2d.MarginBorder)1 ScrollPane (org.eclipse.draw2d.ScrollPane)1 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 AbstractTable (org.talend.designer.gefabstractmap.figures.table.AbstractTable)1 ColumnSash (org.talend.designer.gefabstractmap.figures.table.ColumnSash)1 ITable (org.talend.designer.gefabstractmap.figures.table.ITable)1 TableColumn (org.talend.designer.gefabstractmap.figures.table.TableColumn)1