use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class LookupColumnAnchor method getReferencePoint.
@Override
public Point getReferencePoint() {
if (connectionPart == null) {
return getOwner().getBounds().getLeft();
}
MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
Point ref = null;
if (mapperTablePart != null && entityManager.isTableMinimized()) {
ref = mapperTablePart.getFigure().getBounds().getLeft();
} else {
if (getOwner() == null) {
return null;
} else if (getOwner() instanceof TableEntityFigure) {
TableEntityFigure nodeFigure = (TableEntityFigure) getOwner();
if (nodeFigure.getElement() != null) {
ref = nodeFigure.getElement().getBounds().getLeft();
getOwner().translateToAbsolute(ref);
}
} else {
ref = getOwner().getBounds().getCenter();
getOwner().translateToAbsolute(ref);
}
}
if (mapperTablePart != null && ref != null) {
IFigure treeFigure = mapperTablePart.getFigure();
int avialableX = treeFigure.getBounds().x;
if (ref.x < avialableX) {
ref.x = avialableX;
}
}
if (connectionPart instanceof BaseConnectionEditPart && connectionPart.getFigure() instanceof PolylineConnection) {
BaseConnectionEditPart baseConnectionPart = (BaseConnectionEditPart) connectionPart;
PolylineConnection connFigure = (PolylineConnection) connectionPart.getFigure();
org.eclipse.swt.graphics.Point avilableSize = entityManager.getGraphicalViewer().getControl().getSize();
if (ref != null) {
if (ref.y < 0) {
if (!(baseConnectionPart instanceof LookupConnectionPart)) {
ref.y = 0;
}
baseConnectionPart.setTargetContained(false);
if (baseConnectionPart.isDOTStyle()) {
connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
} else {
connFigure.setLineStyle(SWT.LINE_SOLID);
}
} else if (ref.y > avilableSize.y) {
if (!(baseConnectionPart instanceof LookupConnectionPart)) {
ref.y = avilableSize.y;
}
baseConnectionPart.setTargetContained(false);
if (baseConnectionPart.isDOTStyle()) {
connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
} else {
connFigure.setLineStyle(SWT.LINE_SOLID);
}
} else {
baseConnectionPart.setTargetContained(true);
if (!baseConnectionPart.isDOTStyle()) {
connFigure.setLineStyle(SWT.LINE_SOLID);
}
}
}
}
return ref;
}
use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class MapperSelectEditPartTracker method getShiftAffactedEditPart.
private void getShiftAffactedEditPart(List toSelect, List deSelect) {
if (lastSelectedShiftPart == null || lastSelectedShiftPart == getSourceEditPart()) {
toSelect.add(getSourceEditPart());
return;
}
List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
if (lastSelectedShiftPart instanceof TableEntityPart) {
MapperTablePart treePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelectedShiftPart);
if (treePart != null) {
partList = MapperUtils.getFlatChildrenPartList(treePart);
}
}
int index = partList.indexOf(lastSelectedShiftPart);
int index2 = partList.indexOf(getSourceEditPart());
if (index2 != -1) {
for (int i = Math.min(index, index2); i < Math.max(index, index2) + 1; i++) {
if (!toSelect.contains(partList.get(i))) {
toSelect.add(partList.get(i));
}
}
List selectedEditParts = getCurrentViewer().getSelectedEditParts();
for (int i = 0; i < selectedEditParts.size(); i++) {
if (partList.contains(selectedEditParts.get(i)) && !toSelect.contains(selectedEditParts.get(i))) {
deSelect.add(selectedEditParts.get(i));
}
}
}
}
use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method getCommand.
@Override
public Command getCommand(Request request) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
EditPart targetEditPart = rq.getTargetEditPart();
Command command = null;
if (targetEditPart != null && TemplateTransfer.getInstance().getObject() instanceof TransferedObject) {
TransferedObject toDrop = (TransferedObject) TemplateTransfer.getInstance().getObject();
MapperManager manager = ((XmlMapGraphicViewer) targetEditPart.getViewer()).getMapperManager();
if (manager != null && manager.getExternalData() != null) {
DropType dropType = rq.getNewObjectType();
if (dropType != null) {
switch(dropType) {
case DROP_FILTER:
if (targetEditPart instanceof MapperTablePart) {
command = new UpdateFilterExpressionCommand(toDrop, (MapperTablePart) targetEditPart, manager.getExternalData());
}
break;
case DROP_EXPRESSION:
if (targetEditPart instanceof TableEntityPart) {
command = new UpdateExpressionCommand(toDrop, (TableEntityPart) targetEditPart, manager);
}
break;
case DROP_OUTPUT_DOC_CHILD:
if (targetEditPart instanceof OutputTreeNodeEditPart && rq.getNewObject() instanceof OutputTreeNode) {
command = new CreateDocChildrenCommand(toDrop, (OutputTreeNodeEditPart) targetEditPart, rq, manager);
}
break;
case DROP_INSERT_OUTPUT:
case DROP_INSERT_VAR:
case DROP_INSERT_INPUT:
command = new InsertNewColumnCommand(toDrop, targetEditPart, rq, manager, dropType);
default:
break;
}
}
}
}
if (command != null) {
return command;
}
// drop expression
// boolean update = rq.getDropType() == CreateNodeConnectionRequest.DROP_EXPRESSION ? true : false;
// return new CreateNodeAndConnectionCommand(rq.getNewObject(), rq.getTargetEditPart(), update);
}
return super.getCommand(request);
}
use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class FiguresManager method onTreeSelected.
protected void onTreeSelected(List nodes, MapperTablePart selectedTreePart) {
// selectedTreePart.setTreeOrChildSelected(true);
/*
* clean colors for other trees in the same zone must be executed before highlight the selected tree ,or the
* color for LookupConnection won't be changed
*/
List children = mapDataEditPart.getChildren();
for (Object obj : children) {
MapperTablePart abstractPart = null;
if (selectedTreePart instanceof InputTablePart && obj instanceof InputTablePart) {
abstractPart = (InputTablePart) obj;
} else if (selectedTreePart instanceof OutputTablePart && obj instanceof OutputTablePart) {
abstractPart = (OutputTablePart) obj;
}
if (abstractPart != null) {
if (abstractPart != selectedTreePart) {
abstractPart.highLightHeader(false);
}
abstractPart.updateChildrenConnections(abstractPart.getChildren(), false);
}
}
selectedTreePart.highLightHeader(true);
selectedTreePart.updateChildrenConnections(nodes, true);
}
use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class RowSelectionEditPolicy method getLocatorFigure.
private IFigure getLocatorFigure(GraphicalEditPart owner) {
IFigure figure = owner.getFigure();
if (owner instanceof TableEntityPart) {
TableEntityFigure treeNodeFigure = (TableEntityFigure) figure;
// table figure to restrict the width
MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) owner);
IFigure parentFigure = ((GraphicalEditPart) abstractInOutTreePart).getFigure();
Rectangle treeBounds = parentFigure.getBounds();
Rectangle rowBounds = treeNodeFigure.getElement().getBounds();
Rectangle treeNodeBounds = figure.getBounds();
figure = new Figure();
if (treeBounds.x + 1 != treeNodeBounds.x || treeNodeBounds.width > treeBounds.width) {
figure.setBounds(new Rectangle(treeBounds.x + 1, treeNodeBounds.y, treeBounds.width - 2, rowBounds.height));
return figure;
} else {
figure.setBounds(owner.getFigure().getBounds().getCopy());
figure.getBounds().height = rowBounds.height;
return figure;
}
} else if (figure instanceof VarEntityFigure) {
Rectangle copy = figure.getBounds().getCopy();
figure = new Figure();
figure.setBounds(copy);
return figure;
}
return owner.getFigure();
}
Aggregations