use of org.talend.designer.gefabstractmap.figures.table.ITable 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();
}
// }
}
Aggregations