Search in sources :

Example 56 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)

Example 57 with NodePart

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

the class ComponentChooseDialog method setselecte.

private void setselecte(AbstractEditPart part, String lastUniqname) {
    List<NodePart> parts = getAllNodePart(part);
    for (NodePart nodePart : parts) {
        if (nodePart.getModel() instanceof Node) {
            Node node = (Node) nodePart.getModel();
            // for (String uniqname : uniquteNames) {
            if (node.getUniqueName().equals(lastUniqname)) {
                nodePart.setDrop(true);
                nodePart.setSelected(EditPart.SELECTED);
                nodePart.setDrop(false);
            } else {
                nodePart.setSelected(EditPart.SELECTED_NONE);
            }
        // }
        }
    }
}
Also used : 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) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 58 with NodePart

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

the class OpenTalendJobRefAction method run.

/* Will send a "open" request to the selected nodePart, so it will try to open the reference job.
     * If the "open" command success, then will try to switch the perspective to Integration.
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    //diable switch perspective suggestion dialog. just for defense.
    String notAskAutoSwitchToDIKey = "notAskAutoSwitchToDI";
    boolean oldValueNotSwitchToDiKey = PlatformUI.getPreferenceStore().getBoolean(notAskAutoSwitchToDIKey);
    PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, true);
    //need to be  restore at the end .
    // open in editor, type and count already checked in calculateEnabled()
    List<?> selectedObjects = getSelectedObjects();
    Object select = selectedObjects.get(0);
    NodePart nodePart = (NodePart) select;
    nodePart.performRequest(new org.eclipse.gef.Request(REQUEST_TYPE_OPEN_NODE_PART));
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage == null) {
        return;
    }
    IEditorPart activeEditor = activePage.getActiveEditor();
    if (activeEditor == null || activeEditor.getEditorSite() == null) {
        return;
    }
    Node node = (Node) nodePart.getModel();
    String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
    String openJobName = activeEditor.getEditorInput().getName();
    if (!selectedJobName.equals(openJobName)) {
        return;
    }
    // open/switch editor success and then  try to switch perspective.
    try {
        //if current perspective is ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, will do nothing in under layer.
        PlatformUI.getWorkbench().showPerspective(ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
    } catch (WorkbenchException e) {
        e.printStackTrace();
    } finally {
        //Restore config of switch perspective suggestion dialog. just for defense.
        PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, oldValueNotSwitchToDiKey);
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 59 with NodePart

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

the class OpenTalendJobRefAction method calculateEnabled.

/* Check if this action enable. Will ensure the cTalendJob was selected and has legal value.
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     * 
     */
@Override
protected boolean calculateEnabled() {
    List<?> selectedObjects = getSelectedObjects();
    if (selectedObjects.size() != 1) {
        //not select one object.
        return false;
    }
    Object select = selectedObjects.get(0);
    if (!(select instanceof NodePart)) {
        //not select a node.
        return false;
    }
    NodePart nodePart = (NodePart) select;
    Node node = (Node) nodePart.getModel();
    if (!(node.getComponent() instanceof EmfComponent)) {
        //not select a component.
        return false;
    }
    EmfComponent component = (EmfComponent) node.getComponent();
    if (!C_TALEND_JOB_COMPONENT_NAME.equals(component.getName())) {
        //not cTalendJob component.
        return false;
    }
    Boolean isRepositoryJob = (Boolean) node.getElementParameter(NODE_PARAM_FROM_REPOSITORY_JOB).getValue();
    if (isRepositoryJob == null || !isRepositoryJob) {
        //not from repository job.
        return false;
    }
    String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
    if (selectedJobName == null || selectedJobName.equals("")) {
        //no reference job been choice.
        return false;
    }
    return true;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) EmfComponent(org.talend.designer.core.model.components.EmfComponent) 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