Search in sources :

Example 16 with NodeContainerPart

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

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

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

the class TalendSelectionManager method filterSelection.

private StructuredSelection filterSelection(StructuredSelection selection) {
    List newSelection = new ArrayList(selection.toList());
    for (Object element : selection.toArray()) {
        if (element instanceof SubjobContainerPart) {
            // childrens are NodeContainer part
            newSelection.remove(element);
            List<NodeContainerPart> nodeContainerParts = ((SubjobContainerPart) element).getChildren();
            for (NodeContainerPart nodeContainerPart : nodeContainerParts) {
                for (Object object : nodeContainerPart.getChildren()) {
                    if (object instanceof NodePart) {
                        if (!newSelection.contains(object)) {
                            newSelection.add(object);
                        }
                    }
                }
            }
        } else if (element instanceof NoteEditPart) {
            if (!newSelection.contains(element)) {
                newSelection.add(element);
            }
        } else if (!(element instanceof NodePart)) {
            newSelection.remove(element);
        }
    }
    StructuredSelection newList = new StructuredSelection(newSelection);
    return newList;
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) ArrayList(java.util.ArrayList) List(java.util.List) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 19 with NodeContainerPart

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

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
@SuppressWarnings("unchecked")
public void selectNode(String nodeName) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        // ProcessPart < SubjobContainerPart < NodeContainerPart < NodePart
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof SubjobContainerPart) {
                SubjobContainerPart subjobPart = (SubjobContainerPart) editPart;
                for (EditPart part : (List<EditPart>) subjobPart.getChildren()) {
                    if (part instanceof NodeContainerPart) {
                        EditPart nodePart = (EditPart) part.getChildren().get(0);
                        if (nodePart instanceof NodePart) {
                            if (((Node) ((NodePart) nodePart).getModel()).getLabel().equals(nodeName)) {
                                viewer.select(nodePart);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 20 with NodeContainerPart

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

the class ComponentChooseDialog method createProperty.

private void createProperty(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 ConnectionItem) {
        ConnectionItem connectionItem = (ConnectionItem) dragNode.getObject().getProperty().getItem();
        Command command = getChangePropertyCommand(dragNode, (Node) nodePart.getNodePart().getModel(), connectionItem);
        if (command != null) {
            execCommandStack(command);
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

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