Search in sources :

Example 21 with NodeContainerPart

use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart 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 22 with NodeContainerPart

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

the class ComponentChooseDialog method createValidationRule.

/**
     * DOC ycbai Comment method "createValidationRule".
     *
     * @param dragModel
     * @param targetEditPart
     */
private void createValidationRule(Object dragModel, EditPart targetEditPart) {
    if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
        return;
    }
    RepositoryNode dragNode = (RepositoryNode) dragModel;
    NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
    if (dragNode.getObject().getProperty().getItem() instanceof ValidationRulesConnectionItem) {
        Node node = (Node) nodePart.getNodePart().getModel();
        List<IRepositoryViewObject> valRuleObjs = ValidationRulesUtil.getRelatedValidationRuleObjs(node);
        IRepositoryViewObject valRuleObj = dragNode.getObject();
        String schemaType = (String) node.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
        if (EmfComponent.BUILTIN.equals(schemaType) || !ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs, valRuleObj)) {
            MessageDialog.openWarning(editor.getSite().getShell(), //$NON-NLS-1$
            Messages.getString("SchemaTypeController.validationrule.title.warn"), //$NON-NLS-1$
            Messages.getString("SchemaTypeController.validationrule.cannotApplyValMsg"));
            return;
        }
        CompoundCommand cc = new CompoundCommand();
        cc.add(new PropertyChangeCommand(node, EParameterName.VALIDATION_RULES.getName(), true));
        cc.add(new //$NON-NLS-1$
        ChangeValuesFromRepository(//$NON-NLS-1$
        node, //$NON-NLS-1$
        null, //$NON-NLS-1$
        "VALIDATION_RULE_TYPE:VALIDATION_RULE_TYPE", EmfComponent.REPOSITORY));
        cc.add(new PropertyChangeCommand(node, EParameterName.REPOSITORY_VALIDATION_RULE_TYPE.getName(), valRuleObj.getProperty().getId()));
        execCommandStack(cc);
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) 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) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 23 with NodeContainerPart

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

the class SetParallelizationAction method run.

@Override
public void run() {
    List editparts = getSelectedObjects();
    if (editparts.size() == 1) {
        Object o = editparts.get(0);
        if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            getCommandStack().execute(new SetParallelizationCommand(node));
        } else if (o instanceof SubjobContainerPart) {
            boolean hasStartNode = false;
            List<NodeContainerPart> childNodes = ((SubjobContainerPart) o).getChildren();
            for (NodeContainerPart childNode : childNodes) {
                NodeContainerPart part = (NodeContainerPart) childNode;
                NodeContainer node = (NodeContainer) part.getModel();
                if (node.getNode().isStart()) {
                    hasStartNode = true;
                    getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
                }
            }
            if (!hasStartNode) {
                for (NodeContainerPart childNode : childNodes) {
                    NodeContainerPart part = (NodeContainerPart) childNode;
                    NodeContainer node = (NodeContainer) part.getModel();
                    if (node.getNode().isSubProcessStart()) {
                        getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) SetParallelizationCommand(org.talend.designer.core.ui.editor.cmd.SetParallelizationCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 24 with NodeContainerPart

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

the class JobletUtil method cloneNodeContainer.

public NodeContainer cloneNodeContainer(NodeContainer nodeContainer, Node cloneNode) {
    NodeContainerPart nodeConPart = new NodeContainerPart();
    // TDI-13132
    IComponent tempComponent = cloneNode.getComponent();
    if (tempComponent != null) {
        String tempComponentName = tempComponent.getName();
        if (tempComponentName != null) {
            IComponent component = ComponentsFactoryProvider.getInstance().get(tempComponentName, cloneNode.getProcess().getComponentsType());
            if (component != null) {
                cloneNode.setComponent(component);
            }
        }
    }
    NodeContainer cloneNodeContainer = new NodeContainer(cloneNode);
    nodeConPart.setModel(cloneNodeContainer);
    cloneNodeContainer.setNodeError(cloneNode.getNodeError());
    cloneNodeContainer.setNodeLabel(cloneNode.getNodeLabel());
    cloneNodeContainer.setNodeProgressBar(cloneNode.getNodeProgressBar());
    cloneNodeContainer.setReadOnly(nodeContainer.isReadOnly());
    return cloneNodeContainer;
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) IComponent(org.talend.core.model.components.IComponent) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 25 with NodeContainerPart

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

the class GEFDeleteAction method createDeleteCommand.

@Override
public Command createDeleteCommand(List objects) {
    objects = filterSameObject(objectsToDelete);
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    EditPart object = (EditPart) objects.get(0);
    // for TUP-1015
    boolean isConnAttachedJLTriggerComp = false;
    ConnectionPart connectionPart = null;
    if (object instanceof ConnectionPart) {
        connectionPart = (ConnectionPart) object;
    } else if (object instanceof ConnLabelEditPart) {
        connectionPart = (ConnectionPart) object.getParent();
    }
    if (connectionPart != null) {
        Node srcNode = null;
        Object srcModel = connectionPart.getSource().getModel();
        if (srcModel instanceof Node) {
            srcNode = (Node) srcModel;
        }
        Node tarNode = null;
        Object tarModel = connectionPart.getTarget().getModel();
        if (tarModel instanceof Node) {
            tarNode = (Node) tarModel;
        }
        if (srcNode == null || tarNode == null) {
            return null;
        }
        IProcess process = srcNode.getProcess();
        if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
            IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
            if (service != null && (service.isTriggerNode(srcNode) || service.isTriggerNode(tarNode))) {
                isConnAttachedJLTriggerComp = true;
            }
        }
    }
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    String preKey = TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT;
    if (isConnAttachedJLTriggerComp && !preferenceStore.getBoolean(preKey)) {
        MessageDialogWithToggle jlTriggerConfirmDialog = new MessageDialogWithToggle(null, //$NON-NLS-1$
        Messages.getString("GEFDeleteAction.deleteConnectionDialog.title"), // accept the default window icon
        null, Messages.getString("GEFDeleteAction.deleteConnectionDialog.msg"), MessageDialog.WARNING, new String[] { //$NON-NLS-1$
        IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, //$NON-NLS-1$
        Messages.getString("GEFDeleteAction.deleteConnectionDialog.toggleMsg"), preferenceStore.getDefaultBoolean(preKey));
        jlTriggerConfirmDialog.setPrefStore(preferenceStore);
        jlTriggerConfirmDialog.setPrefKey(preKey);
        if (jlTriggerConfirmDialog.open() != IDialogConstants.YES_ID) {
            return null;
        }
        preferenceStore.setValue(preKey, jlTriggerConfirmDialog.getToggleState());
    }
    List nodeParts = new ArrayList();
    List noteParts = new ArrayList();
    List others = new ArrayList(objects);
    for (Object o : objects) {
        if (o instanceof NodePart) {
            others.remove(o);
            Node model = (Node) ((NodePart) o).getModel();
            if (model.getJobletNode() != null) {
                continue;
            }
            if (model.getJunitNode() != null) {
                continue;
            }
            nodeParts.add(o);
        } else if (o instanceof NoteEditPart) {
            noteParts.add(o);
            others.remove(o);
        } else if (o instanceof SubjobContainerPart) {
            others.remove(o);
            SubjobContainerPart subjob = (SubjobContainerPart) o;
            for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
                NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
                if (nodeContainerPart instanceof JobletContainerPart) {
                    JobletContainer jobletCon = (JobletContainer) ((JobletContainerPart) nodeContainerPart).getModel();
                    JobletContainerFigure jobletFigure = (JobletContainerFigure) ((JobletContainerPart) nodeContainerPart).getFigure();
                    if (!jobletCon.isCollapsed()) {
                        jobletFigure.doCollapse();
                    }
                }
                NodePart nodePart = nodeContainerPart.getNodePart();
                if (nodePart != null) {
                    Node model = (Node) nodePart.getModel();
                    if (model.getJunitNode() != null) {
                        continue;
                    }
                    nodeParts.add(nodePart);
                }
            }
        }
    }
    if (others.size() == 0) {
        // so notes & nodes only
        CompoundCommand cpdCmd = new CompoundCommand();
        //$NON-NLS-1$
        cpdCmd.setLabel(Messages.getString("GEFDeleteAction.DeleteItems"));
        if (nodeParts.size() != 0) {
            GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
            deleteReq.setEditParts(nodeParts);
            cpdCmd.add(((NodePart) nodeParts.get(0)).getCommand(deleteReq));
        }
        if (noteParts.size() != 0) {
            GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
            deleteReq.setEditParts(noteParts);
            cpdCmd.add(((NoteEditPart) noteParts.get(0)).getCommand(deleteReq));
        }
        return cpdCmd;
    } else {
        GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
        deleteReq.setEditParts(objects);
        Command cmd = object.getCommand(deleteReq);
        return cmd;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) JobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ArrayList(java.util.ArrayList) 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) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) Iterator(java.util.Iterator) JobletContainerFigure(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerFigure) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IProcess(org.talend.core.model.process.IProcess)

Aggregations

NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)27 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)17 List (java.util.List)15 ArrayList (java.util.ArrayList)14 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)14 Node (org.talend.designer.core.ui.editor.nodes.Node)13 EditPart (org.eclipse.gef.EditPart)11 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)9 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)8 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)8 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)8 INode (org.talend.core.model.process.INode)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)7 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 Command (org.eclipse.gef.commands.Command)6 IExternalNode (org.talend.core.model.process.IExternalNode)6 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)6 Connection (org.talend.designer.core.ui.editor.connections.Connection)6