Search in sources :

Example 11 with MapperTablePart

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;
}
Also used : TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) Point(org.eclipse.draw2d.geometry.Point) PolylineConnection(org.eclipse.draw2d.PolylineConnection) LookupConnectionPart(org.talend.designer.gefabstractmap.part.LookupConnectionPart) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)

Example 12 with MapperTablePart

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;
}
Also used : TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 13 with MapperTablePart

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;
}
Also used : VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) HashMap(java.util.HashMap) ISash(org.talend.designer.gefabstractmap.figures.sash.ISash) ArrayList(java.util.ArrayList) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) Point(org.eclipse.draw2d.geometry.Point) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) ArrayList(java.util.ArrayList) List(java.util.List) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) RootEditPart(org.eclipse.gef.RootEditPart) IFigure(org.eclipse.draw2d.IFigure) TransferdType(org.talend.designer.gefabstractmap.dnd.TransferdType)

Example 14 with MapperTablePart

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;
            }
    }
}
Also used : AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Aggregations

MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)14 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)7 List (java.util.List)6 ArrayList (java.util.ArrayList)5 IFigure (org.eclipse.draw2d.IFigure)5 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)5 Point (org.eclipse.draw2d.geometry.Point)4 EditPart (org.eclipse.gef.EditPart)4 PolylineConnection (org.eclipse.draw2d.PolylineConnection)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)3 OutputTablePart (org.talend.designer.gefabstractmap.part.OutputTablePart)3 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 Composite (org.eclipse.swt.widgets.Composite)2 Control (org.eclipse.swt.widgets.Control)2 Text (org.eclipse.swt.widgets.Text)2 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)2 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)2