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();
}
// }
}
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());
}
}
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);
}
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);
}
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();
}
Aggregations