Search in sources :

Example 6 with NodePart

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

the class OpenJobHierarchyAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    if (o instanceof NodePart) {
        NodePart part = (NodePart) o;
        Node node = (Node) part.getModel();
        if (DesignerUtilities.isTRunJobComponent(node)) {
            return true;
        }
    } else if (o instanceof ProcessPart) {
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 7 with NodePart

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

the class OpenJobHierarchyAction method caculateProcess.

/**
     * retrieve the process from the NodePart or ProcessPart
     * 
     * @param input
     * @return
     */
private IProcess2 caculateProcess(Object input) {
    if (input instanceof NodePart) {
        NodePart part = (NodePart) input;
        Node node = (Node) part.getModel();
        if (DesignerUtilities.isTRunJobComponent(node)) {
            return DesignerUtilities.getCorrespondingProcessFromTRunjob(node);
        }
    } else if (input instanceof ProcessPart) {
        ProcessPart processPart = (ProcessPart) input;
        return (IProcess2) processPart.getModel();
    }
    return null;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 8 with NodePart

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

the class AbstractMultiPageTalendEditor method getSelectedGraphicNode.

/**
     * DOC amaumont Comment method "getSelectedNode".
     * 
     * @return
     */
public Node getSelectedGraphicNode() {
    Node node = null;
    List selections = designerEditor.getViewer().getSelectedEditParts();
    if (selections.size() == 1) {
        Object selection = selections.get(0);
        if (selection instanceof NodeTreeEditPart) {
            NodeTreeEditPart nTreePart = (NodeTreeEditPart) selection;
            node = (Node) nTreePart.getModel();
        } else {
            if (selection instanceof NodePart) {
                NodePart editPart = (NodePart) selection;
                node = (Node) editPart.getModel();
            } else if (selection instanceof NodeLabelEditPart) {
                NodeLabelEditPart editPart = (NodeLabelEditPart) selection;
                node = ((NodeLabel) editPart.getModel()).getNode();
            }
        }
    }
    return node;
}
Also used : NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 9 with NodePart

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

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
@SuppressWarnings("unchecked")
public void selectNode(Node node) {
    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 (((NodePart) nodePart).getModel().equals(node)) {
                                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 10 with NodePart

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

the class NodePartKeyHander method getNavigationSiblings.

@Override
protected List getNavigationSiblings() {
    EditPart focusPart = getFocusEditPart();
    boolean displayVa = true;
    if (focusPart.getParent() != null) {
        if (focusPart instanceof SubjobContainerPart) {
            // return getNodePart((SubjobContainerPart) focusPart);
            SubjobContainerPart subConPart = (SubjobContainerPart) focusPart;
            List subList = focusPart.getParent().getChildren();
            for (int j = 0; j < subList.size(); j++) {
                if (subList.get(j) instanceof SubjobContainerPart) {
                    subConPart = (SubjobContainerPart) subList.get(j);
                    SubjobContainer subContainer = (SubjobContainer) subConPart.getModel();
                    if (subContainer.isDisplayed() == false) {
                        displayVa = false;
                    }
                } else if (subList.get(j) instanceof NoteEditPart) {
                    NoteEditPart notePart = (NoteEditPart) subList.get(j);
                    return getNodePart((ProcessPart) notePart.getParent());
                } else if (subList.get(j) instanceof NodePart) {
                    NodePart node = (NodePart) subList.get(j);
                    return getNodePart((ProcessPart) node.getParent().getParent().getParent());
                }
            }
            if (displayVa == false) {
                return getNodePart((ProcessPart) focusPart.getParent());
            }
        } else if (focusPart instanceof NodePart) {
            // get all node part for a job.
            return getNodePart((ProcessPart) focusPart.getParent().getParent().getParent());
        // return getNodePart((SubjobContainerPart) focusPart.getParent().getParent());
        } else if (focusPart instanceof NoteEditPart) {
            return getNodePart((ProcessPart) focusPart.getParent());
        }
        return focusPart.getParent().getChildren();
    }
    List list = new ArrayList();
    list.add(focusPart);
    return list;
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) EditPart(org.eclipse.gef.EditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) ArrayList(java.util.ArrayList) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) List(java.util.List) ArrayList(java.util.ArrayList) 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)

Aggregations

NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)59 List (java.util.List)45 Node (org.talend.designer.core.ui.editor.nodes.Node)39 ArrayList (java.util.ArrayList)27 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)23 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)17 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)17 EditPart (org.eclipse.gef.EditPart)16 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)15 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)14 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)14 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)14 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 INode (org.talend.core.model.process.INode)10 Point (org.eclipse.draw2d.geometry.Point)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)9 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)9 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)7 GraphicalViewer (org.eclipse.gef.GraphicalViewer)6 IConnection (org.talend.core.model.process.IConnection)6