Search in sources :

Example 51 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(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 52 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
     */
public void selectNode(INode node) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof NodePart) {
                if (((NodePart) editPart).getModel().equals(node)) {
                    viewer.select(editPart);
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) 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) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 53 with NodePart

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

the class ActivateSubjobAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true / false
     */
private boolean canPerformAction() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return false;
        }
        NodePart part = (NodePart) o;
        if (!(part.getModel() instanceof Node)) {
            return false;
        }
        Node node = (Node) part.getModel();
        boolean isCamelNode = ComponentCategory.CATEGORY_4_CAMEL.getName().equals(node.getProcess().getComponentsType());
        if (node.getJobletNode() != null) {
            return false;
        }
        if (!node.isStart() && isCamelNode) {
            return false;
        }
        if (node.isReadOnly()) {
            return false;
        }
        if (node.getPropertyValue(EParameterName.ACTIVATE.getName()) == null) {
            return false;
        }
        if (node.isStart()) {
            if (node.isActivate()) {
                if (isCamelNode) {
                    setText(Messages.getString("ActivateSubjobAction.DeactivateCompleteRoute"));
                } else {
                    setText(TEXT_REM_ACTIVATE_COMPLETE);
                }
            } else {
                if (isCamelNode) {
                    setText(Messages.getString("ActivateSubjobAction.ActivateCompleteRoute"));
                } else {
                    setText(TEXT_SET_ACTIVATE_COMPLETE);
                }
            }
        } else {
            if (node.isActivate()) {
                setText(TEXT_REM_ACTIVATE_PART);
            } else {
                setText(TEXT_SET_ACTIVATE_PART);
            }
        }
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 54 with NodePart

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

the class ActivateSubjobAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
public void run() {
    List editparts = getSelectedObjects();
    if (editparts.size() == 1) {
        NodePart part = (NodePart) editparts.get(0);
        ChangeActivateStatusSubjobCommand changeActivateStatusCommand = new ChangeActivateStatusSubjobCommand((Node) part.getModel(), false);
        execute(changeActivateStatusCommand);
    }
}
Also used : ChangeActivateStatusSubjobCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusSubjobCommand) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 55 with NodePart

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

the class ConnectionCreateAction method getConnectors.

public List<INodeConnector> getConnectors() {
    List<INodeConnector> list = new ArrayList<INodeConnector>();
    if (getSelectedObjects().isEmpty()) {
        return list;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return list;
        }
        nodePart = (NodePart) o;
        if (!(nodePart.getModel() instanceof Node)) {
            return list;
        }
        Node node = (Node) nodePart.getModel();
        if (!node.isActivate()) {
            return list;
        }
        List<INodeConnector> nodeConnectorList = new ArrayList<INodeConnector>(node.getConnectorsFromType(connecType));
        List<INodeConnector> toRemove = new ArrayList<INodeConnector>();
        for (INodeConnector connector : nodeConnectorList) {
            if ((connector.getMaxLinkOutput() != -1) && (connector.getCurLinkNbOutput() >= connector.getMaxLinkOutput())) {
                toRemove.add(connector);
            } else {
                if (PluginChecker.isJobLetPluginLoaded()) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    if (service != null) {
                        if (service.isJobletComponent(node) && !service.isBuiltTriggerConnector(node, connector)) {
                            toRemove.add(connector);
                        }
                        // for bug 10973
                        List<? extends IConnection> outgoingConnections = node.getOutgoingConnections();
                        if (service.isTriggerInputNode(node) && outgoingConnections != null && outgoingConnections.size() >= 1) {
                            toRemove.add(connector);
                        }
                    }
                }
            }
        }
        nodeConnectorList.removeAll(toRemove);
        return nodeConnectorList;
    }
    return list;
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) INodeConnector(org.talend.core.model.process.INodeConnector)

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