use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class ConnectionColumnAnchor method getReferencePoint.
@Override
public Point getReferencePoint() {
if (connectionPart == null) {
return getOwner().getBounds().getLeft();
}
MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
boolean loctionRight = false;
if (mapperTablePart instanceof InputTablePart) {
loctionRight = true;
}
Point ref = null;
if (mapperTablePart != null && entityManager.isTableMinimized()) {
if (loctionRight) {
ref = mapperTablePart.getFigure().getBounds().getRight();
} else {
ref = mapperTablePart.getFigure().getBounds().getLeft();
}
} else {
if (getOwner() == null) {
return null;
} else if (getOwner() instanceof TableTreeEntityFigure) {
TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
if (nodeFigure.getElement() != null) {
if (loctionRight) {
ref = nodeFigure.getElement().getBounds().getRight();
} else {
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();
if (loctionRight) {
int avialableX = treeFigure.getBounds().getRight().x;
if (ref.x > avialableX) {
ref.x = avialableX;
}
} else {
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 (forceDarshDot) {
connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
} else if (ref != null) {
if (ref.y < 0) {
if (!(baseConnectionPart instanceof LookupConnectionPart)) {
ref.y = 0;
}
if (loctionRight) {
baseConnectionPart.setSourceConcained(false);
} else {
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;
}
if (loctionRight) {
baseConnectionPart.setSourceConcained(false);
} else {
baseConnectionPart.setTargetContained(false);
}
if (baseConnectionPart.isDOTStyle()) {
connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
} else {
connFigure.setLineStyle(SWT.LINE_SOLID);
}
} else {
if (loctionRight) {
baseConnectionPart.setSourceConcained(true);
} 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 FilterColumnAnchor method getReferencePoint.
@Override
public Point getReferencePoint() {
if (connectionPart == null) {
return getOwner().getBounds().getLeft();
}
MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
boolean loctionRight = true;
if (connectionPart.getTarget() instanceof InputTablePart) {
loctionRight = false;
}
Point ref = null;
if (mapperTablePart != null && entityManager.isTableMinimized()) {
if (loctionRight) {
ref = mapperTablePart.getFigure().getBounds().getRight();
} else {
ref = mapperTablePart.getFigure().getBounds().getLeft();
}
} else {
if (getOwner() == null) {
return null;
} else if (getOwner() instanceof TableTreeEntityFigure) {
TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
if (nodeFigure.getElement() != null) {
if (loctionRight) {
ref = nodeFigure.getElement().getBounds().getRight();
} else {
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();
if (loctionRight) {
int avialableX = treeFigure.getBounds().getRight().x;
if (ref.x > avialableX) {
ref.x = avialableX;
}
} else {
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) {
ref.y = 0;
baseConnectionPart.setSourceConcained(false);
if (baseConnectionPart.isDOTStyle()) {
connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
} else {
connFigure.setLineStyle(SWT.LINE_SOLID);
}
} else if (ref.y > avilableSize.y) {
ref.y = avilableSize.y;
baseConnectionPart.setSourceConcained(false);
if (baseConnectionPart.isDOTStyle()) {
connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
} else {
connFigure.setLineStyle(SWT.LINE_SOLID);
}
} else {
baseConnectionPart.setSourceConcained(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 XmlDragSourceListener method getTemplate.
/**
*
* DOC talend Comment method "getTemplate".
*
* @param event
* @return the validate drag able node list
*/
@Override
protected Object getTemplate(DragSourceEvent event) {
final RootEditPart rootEditPart = getViewer().getRootEditPart();
if (rootEditPart instanceof AbstractGraphicalEditPart) {
AbstractGraphicalEditPart graphicPart = (AbstractGraphicalEditPart) rootEditPart;
final IFigure figure = graphicPart.getFigure();
final IFigure findFigureAt = figure.findFigureAt(new Point(event.x, event.y));
if (findFigureAt instanceof ISash) {
return findFigureAt;
}
}
List<EditPart> filtedSelection = new ArrayList<EditPart>();
for (Object part : getViewer().getSelectedEditParts()) {
if (part instanceof TreeNodeEditPart || part instanceof VarNodeEditPart) {
filtedSelection.add((EditPart) part);
}
}
if (filtedSelection == null || filtedSelection.isEmpty()) {
return null;
}
List toTransfer = new ArrayList();
TransferdType type = null;
List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
EditPart lastSelection = filtedSelection.get(filtedSelection.size() - 1);
if (lastSelection instanceof TreeNodeEditPart && !(lastSelection instanceof OutputTreeNodeEditPart)) {
type = TransferdType.INPUT;
} else if (lastSelection instanceof VarNodeEditPart) {
type = TransferdType.VAR;
}
if (type != null) {
if (filtedSelection.size() > 1) {
partList.addAll(lastSelection.getParent().getChildren());
Map<EditPart, Integer> partAndIndex = new HashMap<EditPart, Integer>();
if (type == TransferdType.INPUT) {
for (EditPart treePart : filtedSelection) {
if (!XmlMapUtil.isDragable((TreeNode) treePart.getModel())) {
return null;
}
}
MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
if (abstractInOutTreePart != null) {
partList = MapperUtils.getFlatChildrenPartList(abstractInOutTreePart);
}
} else {
partList.addAll(lastSelection.getParent().getChildren());
}
for (EditPart selected : filtedSelection) {
int indexOf = partList.indexOf(selected);
if (indexOf != -1) {
partAndIndex.put(selected, indexOf);
int index = 0;
for (int i = 0; i < toTransfer.size(); i++) {
if (indexOf > partAndIndex.get(toTransfer.get(i))) {
index = i + 1;
}
}
toTransfer.add(index, selected);
}
}
} else {
if (lastSelection.getModel() instanceof TreeNode && !XmlMapUtil.isDragable((TreeNode) lastSelection.getModel())) {
return null;
}
toTransfer.add(lastSelection);
}
return new TransferedObject(toTransfer, type);
}
return null;
}
use of org.talend.designer.gefabstractmap.part.MapperTablePart in project tdi-studio-se by Talend.
the class OutputTreeNodeEditPart method notifyChanged.
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
int type = notification.getEventType();
int featureId = notification.getFeatureID(XmlmapPackage.class);
switch(type) {
case Notification.SET:
switch(featureId) {
case XmlmapPackage.TREE_NODE__TYPE:
if (XmlMapUtil.DOCUMENT.equals(notification.getOldValue()) || !XmlMapUtil.DOCUMENT.equals(notification.getOldValue()) && XmlMapUtil.DOCUMENT.equals(notification.getNewValue())) {
MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(this);
if (mapperTablePart.getFigure() instanceof OutputXmlTreeFigure) {
((OutputXmlTreeFigure) mapperTablePart.getFigure()).update(XmlmapPackage.TREE_NODE__TYPE);
}
}
break;
case XmlmapPackage.TREE_NODE__LOOP:
((XmlmapTreeNodeFigure) getFigure()).getBranchContent().updateLoopButtonFigure();
AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree((OutputTreeNode) getModel());
if (abstractInOutTree != null) {
((XmlMapGraphicViewer) getViewer()).getMapperManager().getProblemsAnalyser().checkProblems(abstractInOutTree);
((XmlMapGraphicViewer) getViewer()).getMapperManager().getMapperUI().updateStatusBar();
}
}
break;
case Notification.REMOVE:
case Notification.REMOVE_MANY:
switch(featureId) {
}
// }
case Notification.ADD:
case Notification.ADD_MANY:
switch(featureId) {
case XmlmapPackage.INPUT_LOOP_NODES_TABLE__INPUTLOOPNODES:
case XmlmapPackage.OUTPUT_TREE_NODE__INPUT_LOOP_NODES_TABLE:
XmlmapTreeNodeFigure outputFigure = (XmlmapTreeNodeFigure) getFigure();
if (outputFigure.getElement() != null) {
outputFigure.getBranchContent().updateLoopButtonFigure();
}
break;
default:
break;
}
}
}
Aggregations