Search in sources :

Example 16 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class PartFactory method createEditPart.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
     */
@Override
public EditPart createEditPart(EditPart context, Object model) {
    EditPart part = null;
    if (model instanceof SubjobContainer) {
        part = new SubjobContainerPart();
    } else if (model instanceof Process) {
        part = new ProcessPart();
    } else if (model instanceof Node) {
        part = new NodePart();
    } else if (model instanceof Connection) {
        part = new ConnectionPart();
    } else if (model instanceof ConnectionLabel) {
        part = new ConnLabelEditPart();
    } else if (model instanceof MonitorConnectionLabel) {
        part = new MonitorConnectionLabelPart();
    } else if (model instanceof ConnectionPerformance) {
        part = new ConnectionPerformanceEditPart();
    } else if (model instanceof ConnectionTrace) {
        part = new ConnectionTraceEditPart();
    } else if (model instanceof ConnectionResuming) {
        part = new ConnectionResumingEditPart();
    } else if (model instanceof NodeLabel) {
        part = new NodeLabelEditPart();
    } else if (model instanceof NodeContainer) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
            ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
            if (testContainerService != null) {
                part = testContainerService.createEditorPart(model);
                if (part != null) {
                    part.setModel(model);
                    return part;
                }
            }
        }
        if (((NodeContainer) model).getNode().isSparkJoblet()) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
                ISparkJobletProviderService sparkService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
                if (sparkService != null) {
                    part = (EditPart) sparkService.createEditorPart(model);
                    if (part != null) {
                        part.setModel(model);
                        return part;
                    }
                }
            }
        } else if (((NodeContainer) model).getNode().isSparkStreamingJoblet()) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
                ISparkStreamingJobletProviderService sparkService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
                if (sparkService != null) {
                    part = (EditPart) sparkService.createEditorPart(model);
                    if (part != null) {
                        part.setModel(model);
                        return part;
                    }
                }
            }
        } else if (((NodeContainer) model).getNode().isStandardJoblet()) {
            part = new JobletContainerPart();
        } else if (((NodeContainer) model).getNode().isMapReduce()) {
            part = new JobletContainerPart();
        } else {
            part = new NodeContainerPart();
        }
    } else if (model instanceof Note) {
        part = new NoteEditPart();
    } else if (model instanceof NodeError) {
        part = new NodeErrorEditPart();
    } else if (model instanceof NodeProgressBar) {
        part = new NodeProgressBarPart();
    } else {
        return null;
    }
    // tell the newly created part about the model object
    part.setModel(model);
    return part;
}
Also used : NodeError(org.talend.designer.core.ui.editor.nodes.NodeError) NodeProgressBar(org.talend.designer.core.ui.editor.nodes.NodeProgressBar) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeProgressBarPart(org.talend.designer.core.ui.editor.nodes.NodeProgressBarPart) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) MonitorConnectionLabel(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabel) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ConnectionResuming(org.talend.designer.core.ui.editor.connections.ConnectionResuming) ConnectionResumingEditPart(org.talend.designer.core.ui.editor.connections.ConnectionResumingEditPart) NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) MonitorConnectionLabel(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabel) ITestContainerGEFService(org.talend.designer.core.ITestContainerGEFService) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ISparkJobletProviderService(org.talend.core.ui.ISparkJobletProviderService) NodeErrorEditPart(org.talend.designer.core.ui.editor.nodes.NodeErrorEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ConnectionResumingEditPart(org.talend.designer.core.ui.editor.connections.ConnectionResumingEditPart) NodeErrorEditPart(org.talend.designer.core.ui.editor.nodes.NodeErrorEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnectionPerformance(org.talend.designer.core.ui.editor.connections.ConnectionPerformance) ConnectionTrace(org.talend.designer.core.ui.editor.connections.ConnectionTrace) ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) ISparkStreamingJobletProviderService(org.talend.core.ui.ISparkStreamingJobletProviderService) Note(org.talend.designer.core.ui.editor.notes.Note) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) MonitorConnectionLabelPart(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabelPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 17 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class TalendSelectionManager method transferFocus.

/*
     * (non-Javadoc) for bug 10072
     * 
     * @when the selected element is ConnectionPerformanceEditPart,transfer Focus to nodepart
     */
private EditPart transferFocus(ConnectionPerformanceEditPart arg0) {
    ConnectionPart connPart = (ConnectionPart) arg0.getParent();
    EditPart targetPart = connPart.getTarget();
    if (targetPart instanceof NodePart) {
        NodeFigure targetFigure = (NodeFigure) ((NodePart) targetPart).getFigure();
        if (targetFigure.containsPoint(getSelectPoint())) {
            setSelectPoint(null);
            return targetPart;
        }
    }
    EditPart sourcePart = connPart.getSource();
    if (sourcePart instanceof NodePart) {
        NodeFigure sourceFigure = (NodeFigure) ((NodePart) sourcePart).getFigure();
        if (sourceFigure.containsPoint(getSelectPoint())) {
            setSelectPoint(null);
            return sourcePart;
        }
    }
    if (connPart.getParent() instanceof TalendScalableFreeformRootEditPart) {
        TalendScalableFreeformRootEditPart parentPart = (TalendScalableFreeformRootEditPart) connPart.getParent();
        if (parentPart.getContents() instanceof ProcessPart) {
            ProcessPart processPart = (ProcessPart) parentPart.getContents();
            List children = processPart.getChildren();
            for (int i = 0; i < children.size(); i++) {
                if (children.get(i) instanceof SubjobContainerPart) {
                    List nodeList = ((SubjobContainerPart) children.get(i)).getChildren();
                    nodeList.remove(sourcePart.getParent());
                    nodeList.remove(targetPart.getParent());
                    for (int j = 0; j < nodeList.size(); j++) {
                        if (nodeList.get(j) instanceof NodeContainerPart) {
                            NodePart nodePart = ((NodeContainerPart) nodeList.get(j)).getNodePart();
                            NodeFigure figure = (NodeFigure) nodePart.getFigure();
                            if (figure.containsPoint(getSelectPoint())) {
                                setSelectPoint(null);
                                return nodePart;
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeFigure(org.talend.designer.core.ui.editor.nodes.NodeFigure) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) Point(org.eclipse.draw2d.geometry.Point)

Example 18 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class ComponentChooseDialog method dragOver.

@Override
public void dragOver(DropTargetEvent event) {
    // multi-drag for job,context, sqlPattern.
    IStructuredSelection selection = getSelection();
    if (selection.size() > 1) {
        boolean allowed = true;
        Item temItem = null;
        Iterator iter = selection.iterator();
        while (iter.hasNext()) {
            Object next = iter.next();
            if (next instanceof RepositoryNode) {
                RepositoryNode sourceNode = (RepositoryNode) next;
                IRepositoryViewObject object = sourceNode.getObject();
                if (object != null) {
                    Item selectItem = object.getProperty().getItem();
                    if (temItem == null) {
                        temItem = selectItem;
                        continue;
                    }
                    if (selectItem instanceof ProcessItem && !(temItem instanceof ProcessItem)) {
                        allowed = false;
                    } else if (selectItem instanceof ContextItem && !(temItem instanceof ContextItem)) {
                        allowed = false;
                    } else if (selectItem instanceof SQLPatternItem && !(temItem instanceof SQLPatternItem)) {
                        allowed = false;
                    }
                }
            }
        }
        if (!allowed) {
            event.detail = DND.DROP_NONE;
        }
    } else {
        CreateRequest req = ((CreateRequest) getTargetRequest());
        Object o = null;
        try {
            o = req.getNewObject();
        } catch (Exception e) {
            return;
        }
        if (!(o instanceof Node)) {
            return;
        }
        RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
        Point viewOriginalPosition = new Point();
        if (rep instanceof ScalableFreeformRootEditPart) {
            ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
            Viewport viewport = (Viewport) root.getFigure();
            viewOriginalPosition = viewport.getViewLocation();
        }
        org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event.x + viewOriginalPosition.x, event.y + viewOriginalPosition.y);
        Canvas canvas = (Canvas) editor.getViewer().getControl();
        swtLocation = canvas.toControl(swtLocation);
        // System.out.println("topLeft:" + topLeftpoint + " / event:" + swtLocation);
        org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
        double zoom = 1.0;
        if (editor.getViewer().getRootEditPart() instanceof TalendScalableFreeformRootEditPart) {
            ZoomManager zoomManager = ((TalendScalableFreeformRootEditPart) editor.getViewer().getRootEditPart()).getZoomManager();
            zoom = zoomManager.getZoom();
        }
        List<ConnectionPart> connectionParts = CreateComponentOnLinkHelper.getConnectionParts(editor.getProcessPart(), draw2dPosition, (Node) o);
        double minDistance = 1000000000;
        for (ConnectionPart part : connectionParts) {
            if (part.getFigure() instanceof PolylineConnection) {
                PolylineConnection connection = (PolylineConnection) part.getFigure();
                double distance = CreateComponentOnLinkHelper.getDistanceOrthogonal(draw2dPosition.x, draw2dPosition.y, connection, zoom);
                if (distance < minDistance) {
                    selectedConnectionPart = part;
                    minDistance = Math.min(distance, minDistance);
                }
            }
        }
        if (selectedConnectionPart != null && minDistance < 15) {
            for (Object child : editor.getProcessPart().getChildren()) {
                if (child instanceof SubjobContainerPart) {
                    CreateComponentOnLinkHelper.unselectAllConnections((SubjobContainerPart) child);
                }
            }
            CreateComponentOnLinkHelper.selectConnection(selectedConnectionPart);
        } else {
            if (selectedConnectionPart != null) {
                CreateComponentOnLinkHelper.unselectConnection(selectedConnectionPart);
            }
            selectedConnectionPart = null;
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) CreateRequest(org.eclipse.gef.requests.CreateRequest) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) Iterator(java.util.Iterator) Point(org.eclipse.draw2d.geometry.Point) Canvas(org.eclipse.swt.widgets.Canvas) Viewport(org.eclipse.draw2d.Viewport) Point(org.eclipse.draw2d.geometry.Point) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PersistenceException(org.talend.commons.exception.PersistenceException) PolylineConnection(org.eclipse.draw2d.PolylineConnection) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) AnimatableZoomManager(org.talend.commons.ui.gmf.draw2d.AnimatableZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Example 19 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class CreateComponentOnLinkHelper method getConnection.

public static List<Connection> getConnection(SubjobContainerPart containerPart, Point point, Node node) {
    List<Connection> connectionList = new ArrayList<Connection>();
    List<Connection> connList = new ArrayList<Connection>();
    List children = containerPart.getChildren();
    for (int i = 0; i < children.size(); i++) {
        Object object = children.get(i);
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nodePart = (NodeContainerPart) object;
            Object o = nodePart.getChildren().get(0);
            if (o instanceof NodePart) {
                List connections = ((NodePart) o).getSourceConnections();
                for (int j = 0; j < connections.size(); j++) {
                    Object connection = connections.get(j);
                    if (connection instanceof ConnectionPart) {
                        ConnectionPart connPart = (ConnectionPart) connection;
                        Connection conn = (Connection) connPart.getModel();
                        if (canCreateNodeOnLink(conn, node)) {
                            Rectangle bounds = ((ConnectionPart) connection).getFigure().getBounds();
                            // System.out.println("location:" + point);
                            if (bounds.contains(point)) {
                                // System.out.println("bounds:" + bounds);
                                connectionList.add(conn);
                            }
                            if (containsPoint(bounds, point)) {
                                // System.out.println("contains");
                                connList.add(conn);
                            }
                        }
                    }
                }
            }
        }
    }
    if (!connectionList.isEmpty()) {
        return connectionList;
    } else {
        return connList;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) Point(org.eclipse.draw2d.geometry.Point)

Example 20 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class GEFDeleteAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    objectsToDelete = new ArrayList();
    List objects = getSelectedObjects();
    objectsToDelete.addAll(objects);
    if (objects.isEmpty() || (objects.size() == 1 && objects.get(0) instanceof ProcessPart)) {
        return false;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return false;
    }
    AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
    AbstractProcessProvider pProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
    if (pProvider != null) {
        Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
        boolean nodeInJoblet = false;
        boolean allJunitnode = true;
        boolean hasNode = false;
        int i = 0;
        for (Object o : objects) {
            if (o instanceof NodePart) {
                hasNode = true;
                NodePart nodePart = (NodePart) o;
                Node no = (Node) ((NodePart) o).getModel();
                if (no.getProcess().isReadOnly()) {
                    return false;
                }
                if (no.isReadOnly()) {
                    i++;
                }
                if (no.getJunitNode() == null) {
                    allJunitnode = false;
                }
                if (!pProvider.canDeleteNode(no)) {
                    return false;
                }
                boolean isCollapsedNode = false;
                if (editor.getProcess().getGraphicalNodes().contains(nodePart.getModel())) {
                    isCollapsedNode = true;
                }
                if (!isCollapsedNode && nodePart.getParent() instanceof JobletContainerPart) {
                    JobletContainerPart jobletContainer = (JobletContainerPart) nodePart.getParent();
                    List<NodePart> jobletNodeParts = jobletMap.get(jobletContainer);
                    if (jobletNodeParts == null) {
                        jobletNodeParts = new ArrayList<NodePart>();
                        jobletMap.put(jobletContainer, jobletNodeParts);
                    }
                    jobletNodeParts.add(nodePart);
                }
            } else if (o instanceof ConnectionPart) {
                Connection conn = (Connection) ((ConnectionPart) o).getModel();
                if (conn.getSource().getProcess().isReadOnly()) {
                    return false;
                }
                if (conn.isReadOnly()) {
                    i++;
                }
            } else if (o instanceof ConnLabelEditPart) {
                ConnectionLabel connLabel = (ConnectionLabel) ((ConnLabelEditPart) o).getModel();
                if (connLabel.getConnection().getSource().getProcess().isReadOnly()) {
                    return false;
                }
                if (connLabel.getConnection().isReadOnly()) {
                    i++;
                }
            } else if (o instanceof NoteEditPart) {
                allJunitnode = false;
                Note note = (Note) ((NoteEditPart) o).getModel();
                if (note.isReadOnly()) {
                    i++;
                }
            } else if (o instanceof SubjobContainerPart) {
                SubjobContainer subjob = (SubjobContainer) ((SubjobContainerPart) o).getModel();
                if (subjob.getProcess().isReadOnly()) {
                    return false;
                }
                if (subjob.isReadOnly()) {
                    i++;
                    continue;
                }
                boolean isAllReadonly = true;
                boolean subjobAllJunit = true;
                for (NodeContainer nc : subjob.getNodeContainers()) {
                    Node node = nc.getNode();
                    if (!node.isReadOnly()) {
                        isAllReadonly = false;
                    }
                    if (node.getJunitNode() == null) {
                        subjobAllJunit = false;
                    }
                }
                if (isAllReadonly || subjobAllJunit) {
                    i++;
                }
            }
        }
        for (JobletContainerPart jobletContainer : jobletMap.keySet()) {
            boolean copyJobletNode = true;
            List<NodePart> list = jobletMap.get(jobletContainer);
            for (Object obj : jobletContainer.getChildren()) {
                if (obj instanceof NodePart) {
                    if (!list.contains(obj)) {
                        copyJobletNode = false;
                        break;
                    }
                }
            }
            if (copyJobletNode) {
                objectsToDelete.removeAll(list);
                PartFactory factory = new PartFactory();
                NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
                createEditPart.setParent(jobletContainer);
                createEditPart.installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
                objectsToDelete.add(createEditPart);
            } else {
                nodeInJoblet = true;
            }
        }
        if (((nodeInJoblet || allJunitnode) && hasNode) || i == objects.size()) {
            return false;
        }
    }
    return true;
}
Also used : HashMap(java.util.HashMap) PartFactory(org.talend.designer.core.ui.editor.PartFactory) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) NodeEditPolicy(org.talend.designer.core.ui.editor.nodes.NodeEditPolicy) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) Note(org.talend.designer.core.ui.editor.notes.Note) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Aggregations

ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)22 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)17 List (java.util.List)15 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)14 Connection (org.talend.designer.core.ui.editor.connections.Connection)13 ArrayList (java.util.ArrayList)9 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)8 Node (org.talend.designer.core.ui.editor.nodes.Node)7 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)7 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)7 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)7 Point (org.eclipse.draw2d.geometry.Point)6 EditPart (org.eclipse.gef.EditPart)6 IConnection (org.talend.core.model.process.IConnection)6 PolylineConnection (org.eclipse.draw2d.PolylineConnection)5 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)5 INode (org.talend.core.model.process.INode)4 ConnectionTraceEditPart (org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart)4 PointList (org.eclipse.draw2d.geometry.PointList)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3