Search in sources :

Example 1 with LayoutManager

use of org.eclipse.draw2d.LayoutManager 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 LayoutManager

use of org.eclipse.draw2d.LayoutManager in project liferay-ide by liferay.

the class PortletColumnEditPart method refreshVisuals.

protected void refreshVisuals() {
    super.refreshVisuals();
    IFigure parentFigure = ((GraphicalEditPart) getParent()).getFigure();
    LayoutManager layoutManager = parentFigure.getLayoutManager();
    Object constraint = layoutManager.getConstraint(getFigure());
    GridData gd = null;
    if (constraint instanceof GridData) {
        gd = (GridData) constraint;
        if (gd.heightHint == SWT.DEFAULT) {
            gd.heightHint = getCastedParent().getDefaultColumnHeight();
        }
    } else {
        gd = createGridData();
    }
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), gd);
    if (getFigure() instanceof ColumnFigure) {
        Value<Integer> weight = getCastedModel().getWeight();
        Integer weightValue = weight.content();
        ((ColumnFigure) getFigure()).setText(weightValue.toString());
    }
}
Also used : LayoutManager(org.eclipse.draw2d.LayoutManager) GridData(org.eclipse.draw2d.GridData) ColumnFigure(com.liferay.ide.layouttpl.ui.draw2d.ColumnFigure) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with LayoutManager

use of org.eclipse.draw2d.LayoutManager in project whole by wholeplatform.

the class AbstractContentPanePart method reorderChild.

@SuppressWarnings("unchecked")
protected void reorderChild(EditPart child, int index) {
    IFigure childFigure = ((GraphicalEditPart) child).getFigure();
    LayoutManager layout = getContentPane(child).getLayoutManager();
    Object constraint = null;
    if (layout != null)
        constraint = layout.getConstraint(childFigure);
    removeChildVisual(child);
    List<EditPart> children = getChildren();
    children.remove(child);
    children.add(index, child);
    addChildVisual(child, index);
    setLayoutConstraint(child, childFigure, constraint);
}
Also used : LayoutManager(org.eclipse.draw2d.LayoutManager) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with LayoutManager

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

the class TalendDrawerFigure method setLayoutMode.

@Override
public void setLayoutMode(int layoutMode) {
    if (this.talendLayoutMode == layoutMode) {
        return;
    }
    this.talendLayoutMode = layoutMode;
    LayoutManager manager;
    if (layoutMode == PaletteViewerPreferences.LAYOUT_COLUMNS) {
        manager = new ColumnsLayout();
        getContentPane().setBorder(customizedCSSStyleSetting.getScrollPaneBorder());
    } else if (layoutMode == PaletteViewerPreferences.LAYOUT_ICONS) {
        PaletteContainerFlowLayout fl = new PaletteContainerFlowLayout();
        fl.setMinorSpacing(0);
        fl.setMajorSpacing(0);
        manager = fl;
        getContentPane().setBorder(customizedCSSStyleSetting.getScrollPaneBorder());
    } else {
        manager = new ToolbarLayout();
        getContentPane().setBorder(customizedCSSStyleSetting.getScrollPaneListBorder());
    }
    getContentPane().setLayoutManager(manager);
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) LayoutManager(org.eclipse.draw2d.LayoutManager) ColumnsLayout(org.eclipse.gef.internal.ui.palette.editparts.ColumnsLayout) PaletteContainerFlowLayout(org.eclipse.gef.internal.ui.palette.editparts.PaletteContainerFlowLayout)

Example 5 with LayoutManager

use of org.eclipse.draw2d.LayoutManager in project knime-core by knime.

the class AbstractWorkflowPortBarEditPart method relayoutPorts.

private void relayoutPorts() {
    IFigure nodeFig = getFigure();
    LayoutManager layoutManager = nodeFig.getLayoutManager();
    if (layoutManager != null) {
        layoutManager.invalidate();
        layoutManager.layout(figure);
    }
    nodeFig.repaint();
}
Also used : LayoutManager(org.eclipse.draw2d.LayoutManager) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

LayoutManager (org.eclipse.draw2d.LayoutManager)7 IFigure (org.eclipse.draw2d.IFigure)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 ColumnFigure (com.liferay.ide.layouttpl.ui.draw2d.ColumnFigure)1 GridData (org.eclipse.draw2d.GridData)1 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 EditPart (org.eclipse.gef.EditPart)1 ColumnsLayout (org.eclipse.gef.internal.ui.palette.editparts.ColumnsLayout)1 PaletteContainerFlowLayout (org.eclipse.gef.internal.ui.palette.editparts.PaletteContainerFlowLayout)1 WorkflowFigure (org.knime.workbench.editor2.figures.WorkflowFigure)1 WorkflowLayout (org.knime.workbench.editor2.figures.WorkflowLayout)1 XmlMapDataLayout (org.talend.designer.gefabstractmap.figures.layout.XmlMapDataLayout)1 SashSeparator (org.talend.designer.gefabstractmap.figures.sash.SashSeparator)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