Search in sources :

Example 21 with NodeContainer

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

the class SubjobContainerPart method performRequest.

@Override
public void performRequest(Request req) {
    if (req instanceof SelectionRequest) {
        Point location = ((SelectionRequest) req).getLocation();
        List<NodeContainer> list = this.getModelChildren();
        for (NodeContainer nodeCon : list) {
            if (nodeCon.getErrorMarkRectangle() != null && nodeCon.getErrorMarkRectangle().contains(location)) {
                Node node = nodeCon.getNode();
                if (node.isErrorFlag()) {
                    // getViewer().getControl().getShell();
                    Shell shell = Display.getCurrent().getActiveShell();
                    ErrorMessageDialog dialog = new ErrorMessageDialog(new Shell(shell), node);
                    dialog.open();
                    break;
                }
            } else if (nodeCon.getErrorRectangle() != null && nodeCon.getErrorRectangle().contains(location)) {
                Node node = nodeCon.getNode();
                showModules(node);
            }
        }
    }
    super.performRequest(req);
}
Also used : ErrorMessageDialog(org.talend.designer.core.ui.dialog.mergeorder.ErrorMessageDialog) Shell(org.eclipse.swt.widgets.Shell) SelectionRequest(org.eclipse.gef.requests.SelectionRequest) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point)

Example 22 with NodeContainer

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

the class SubjobContainerLayoutEditPolicy method getCreateCommand.

// ------------------------------------------------------------------------
// Abstract methods from LayoutEditPolicy
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
     */
protected Command getCreateCommand(final CreateRequest request) {
    if (((SubjobContainer) getHost().getModel()).isReadOnly()) {
        return null;
    }
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    Process linkedProcess = (Process) ((SubjobContainer) getHost().getModel()).getProcess();
    Command command = null;
    if (Note.class.equals(request.getNewObjectType())) {
        command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
    } else if (request.getNewObject() instanceof Node) {
        Node node = (Node) request.getNewObject();
        NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
        command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
    }
    return command;
}
Also used : CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) MoveNoteCommand(org.talend.designer.core.ui.editor.cmd.MoveNoteCommand) Command(org.eclipse.gef.commands.Command) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Process(org.talend.designer.core.ui.editor.process.Process) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 23 with NodeContainer

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

the class GEFPasteAction method canPasteJobletNode.

private boolean canPasteJobletNode(IProcess2 curNodeProcess, Node copiedNode) {
    Item temIten = curNodeProcess.getProperty().getItem();
    if (!(temIten instanceof JobletProcessItem)) {
        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null) {
            if (service.isJobletInOutComponent(copiedNode)) {
                MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Paste Error", "Can not paste joblet component in job!");
                return false;
            }
        }
    }
    Node jobletNode = (Node) copiedNode.getJobletNode();
    AbstractJobletContainer jnc = (AbstractJobletContainer) jobletNode.getNodeContainer();
    List<NodeContainer> ncs = jnc.getNodeContainers();
    if (ncs != null) {
        for (NodeContainer nc : ncs) {
            if (nc.getNode() == copiedNode) {
                return true;
            }
        }
    }
    return false;
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer)

Example 24 with NodeContainer

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

the class GEFPasteAction method run.

@Override
@SuppressWarnings("unchecked")
public void run() {
    Object clipBoardContent;
    try {
        clipBoardContent = Clipboard.getDefault().getContents();
    } catch (RuntimeException e) {
        return;
    }
    AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
    org.eclipse.swt.dnd.Clipboard systemClipboard = new org.eclipse.swt.dnd.Clipboard(Display.getCurrent());
    Object systemObject = systemClipboard.getContents(TextTransfer.getInstance());
    if (clipBoardContent instanceof List) {
        List<EditPart> partsList = (List<EditPart>) clipBoardContent;
        if (partsList == null || partsList.isEmpty()) {
            return;
        }
        List<NodePart> nodeParts = new ArrayList<NodePart>();
        List<NoteEditPart> noteParts = new ArrayList<NoteEditPart>();
        List<SubjobContainerPart> subjobParts = new ArrayList<SubjobContainerPart>();
        for (Object o : partsList) {
            if (o instanceof NodePart) {
                if (!nodeParts.contains(o)) {
                    nodeParts.add((NodePart) o);
                }
            } else if (o instanceof NoteEditPart) {
                noteParts.add((NoteEditPart) o);
            } else if (o instanceof SubjobContainerPart) {
                SubjobContainerPart subjob = (SubjobContainerPart) o;
                for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
                    NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
                    // add for bug TDI-20206
                    if (nodeContainerPart instanceof JobletContainerPart) {
                        for (Object obj : nodeContainerPart.getChildren()) {
                            if (obj instanceof NodePart && !nodeParts.contains(obj)) {
                                nodeParts.add((NodePart) obj);
                            }
                        }
                    }
                    NodePart nodePart = nodeContainerPart.getNodePart();
                    if (nodePart != null) {
                        if (!nodeParts.contains(nodePart)) {
                            nodeParts.add(nodePart);
                        }
                        subjobParts.add(subjob);
                    }
                }
            }
        }
        Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
        for (NodePart nodePart : nodeParts) {
            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);
            }
        }
        List<NodePart> expandedJobletNodes = new ArrayList<NodePart>();
        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) {
                nodeParts.removeAll(list);
                PartFactory factory = new PartFactory();
                NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
                createEditPart.setParent(jobletContainer);
                nodeParts.add(createEditPart);
                expandedJobletNodes.add(createEditPart);
            }
        }
        org.eclipse.draw2d.geometry.Point gefPoint = getCursorLocation();
        // qli comment
        // if the components instanceof JobletInputOutputComponent and current process instanceof not
        // JobletGEFProcess,just create a messageBox and return.
        AbstractProcessProvider findProcessProviderFromPID = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
        if (findProcessProviderFromPID != null) {
            for (NodePart copiedNodePart : nodeParts) {
                Node copiedNode = (Node) copiedNodePart.getModel();
                // add for bug TDI-20207.if copy joblet/job to itself,then return.
                EComponentType componentType = null;
                String copideNodeId = null;
                String editorProcessId = null;
                if (copiedNode.getComponent() != null) {
                    componentType = copiedNode.getComponent().getComponentType();
                    if (copiedNode.getComponent().getProcess() != null) {
                        copideNodeId = copiedNode.getComponent().getProcess().getId();
                    }
                }
                if (editor.getProcess() != null) {
                    editorProcessId = editor.getProcess().getId();
                }
                for (IElementParameter element : copiedNode.getElementParametersFromField(EParameterFieldType.PROCESS_TYPE)) {
                    for (Map.Entry<String, IElementParameter> entry : element.getChildParameters().entrySet()) {
                        if (("PROCESS_TYPE_PROCESS").equals(entry.getKey())) {
                            if (editorProcessId != null && editorProcessId.equals(entry.getValue().getValue())) {
                                return;
                            }
                        }
                    }
                }
                if ((EComponentType.JOBLET).equals(componentType)) {
                    if (editorProcessId != null && editorProcessId.equals(copideNodeId)) {
                        return;
                    }
                }
                if (findProcessProviderFromPID.isJobletInputOrOutputComponent(copiedNode)) {
                    if (!findProcessProviderFromPID.isExtensionProcess(editor.getProcess())) {
                        MessageBox messagebox = new MessageBox(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.ICON_WARNING);
                        //$NON-NLS-1$
                        messagebox.setText(Messages.getString("GEFPasteAction.textWarning"));
                        //$NON-NLS-1$
                        messagebox.setMessage(Messages.getString("GEFPasteAction.warningMessages"));
                        messagebox.open();
                        return;
                    }
                }
                if (copiedNode.getJobletNode() != null) {
                    boolean canP = canPasteJobletNode(editor.getProcess(), copiedNode);
                    if (!canP) {
                        return;
                    }
                }
            }
        }
        if (nodeParts.size() != 0 && noteParts.size() != 0) {
            MultiplePasteCommand mpc = new MultiplePasteCommand(nodeParts, noteParts, (org.talend.designer.core.ui.editor.process.Process) editor.getProcess(), gefPoint);
            mpc.setSelectedSubjobs(subjobParts);
            mpc.setSelectedExpandedJoblet(expandedJobletNodes);
            execute(mpc);
        } else if (nodeParts.size() != 0) {
            NodesPasteCommand cmd = new NodesPasteCommand(nodeParts, editor.getProcess(), gefPoint);
            cmd.setSelectedSubjobs(subjobParts);
            cmd.setSelectedExpandedJoblet(expandedJobletNodes);
            execute(cmd);
        } else if (noteParts.size() != 0) {
            NotesPasteCommand cmd = new NotesPasteCommand(noteParts, (org.talend.designer.core.ui.editor.process.Process) editor.getProcess(), gefPoint, false, null);
            execute(cmd);
        }
        setCursorLocation(null);
    } else if (clipBoardContent instanceof String) {
        List objects = getSelectedObjects();
        if (objects.size() == 1) {
            String content = (String) clipBoardContent;
            if (objects.get(0) instanceof NoteEditPart && ((NoteEditPart) objects.get(0)).getDirectEditManager() != null) {
                Text text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
                if (text != null) {
                    text.insert(content);
                }
            } else if (objects.get(0) instanceof ConnLabelEditPart && ((ConnLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
                Text text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
                if (text != null) {
                    text.insert(content);
                }
            } else if (objects.get(0) instanceof NodeLabelEditPart && ((NodeLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
                {
                    Text text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
                    if (text != null) {
                        text.insert(content);
                    }
                }
            }
        }
    } else if (systemObject != null && systemObject instanceof String) {
        List objects = getSelectedObjects();
        if (objects.size() == 1) {
            String content = (String) systemObject;
            if (objects.get(0) instanceof NoteEditPart && ((NoteEditPart) objects.get(0)).getDirectEditManager() != null) {
                Text text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
                if (text != null) {
                    text.insert(content);
                }
            } else if (objects.get(0) instanceof ConnLabelEditPart && ((ConnLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
                Text text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
                if (text != null) {
                    text.insert(content);
                }
            } else if (objects.get(0) instanceof NodeLabelEditPart && ((NodeLabelEditPart) objects.get(0)).getDirectEditManager() != null) {
                {
                    Text text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
                    if (text != null) {
                        text.insert(content);
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) 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) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) MultiplePasteCommand(org.talend.designer.core.ui.editor.cmd.MultiplePasteCommand) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) EComponentType(org.talend.core.model.components.EComponentType) NotesPasteCommand(org.talend.designer.core.ui.editor.cmd.NotesPasteCommand) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) Iterator(java.util.Iterator) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) NodesPasteCommand(org.talend.designer.core.ui.editor.cmd.NodesPasteCommand) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) Text(org.eclipse.swt.widgets.Text) MessageBox(org.eclipse.swt.widgets.MessageBox) Clipboard(org.eclipse.gef.ui.actions.Clipboard) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) HashMap(java.util.HashMap) Map(java.util.Map) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 25 with NodeContainer

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

the class DisableParallelizationAction 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 DisableParallelizationCommand(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 DisableParallelizationCommand(node.getNode()));
                }
            }
            if (!hasStartNode) {
                for (NodeContainerPart childNode : childNodes) {
                    NodeContainerPart part = (NodeContainerPart) childNode;
                    NodeContainer node = (NodeContainer) part.getModel();
                    if (node.getNode().isSubProcessStart()) {
                        getCommandStack().execute(new DisableParallelizationCommand(node.getNode()));
                    }
                }
            }
        }
    }
}
Also used : DisableParallelizationCommand(org.talend.designer.core.ui.editor.cmd.DisableParallelizationCommand) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) 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)

Aggregations

NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)60 Node (org.talend.designer.core.ui.editor.nodes.Node)43 ArrayList (java.util.ArrayList)23 INode (org.talend.core.model.process.INode)23 List (java.util.List)20 Process (org.talend.designer.core.ui.editor.process.Process)20 Point (org.eclipse.draw2d.geometry.Point)17 IComponent (org.talend.core.model.components.IComponent)13 IConnection (org.talend.core.model.process.IConnection)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)11 IProcess (org.talend.core.model.process.IProcess)11 Connection (org.talend.designer.core.ui.editor.connections.Connection)11 IElementParameter (org.talend.core.model.process.IElementParameter)10 EditPart (org.eclipse.gef.EditPart)9 IExternalNode (org.talend.core.model.process.IExternalNode)9 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)9 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)9 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)9 HashMap (java.util.HashMap)8