Search in sources :

Example 56 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class JobletContainer method refreshJobletConnections.

private void refreshJobletConnections() {
    Iterator<IConnection> inIterator = inputs.iterator();
    while (inIterator.hasNext()) {
        IConnection conn = inIterator.next();
        if (isCollapsed()) {
            ((Connection) conn).reconnect(conn.getSource(), this.node, conn.getLineStyle());
        } else {
            out: for (NodeContainer nodeContainer : this.nodeContainers) {
                Node connNode = nodeContainer.getNode();
                IElementParameter elePa = this.node.getElementParameter(connNode.getJoblet_unique_name());
                if (elePa != null) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    IElementParameter elechild = null;
                    String uniqueName = null;
                    boolean isTri = service.isTriggerNode(connNode);
                    if (service != null && isTri) {
                        elechild = elePa.getChildParameters().get("COMPONENT_LIST");
                        uniqueName = conn.getMetaName();
                    } else {
                        elechild = elePa.getChildParameters().get("CONNECTION");
                        uniqueName = conn.getUniqueName();
                    }
                    if (elechild != null && elechild.getValue().equals(uniqueName)) {
                        List<? extends INodeConnector> connList = new JobletUtil().createConnectors(connNode, this.getProcess());
                        // modify///////////////////////////////////////////////////////////////////////////////////////////////////////
                        List<INodeConnector> inodeConnList = new ArrayList<INodeConnector>();
                        inodeConnList.addAll(connList);
                        inodeConnList.addAll(connNode.getListConnector());
                        connNode.setListConnector(inodeConnList);
                        // connNode.getListConnector().addAll(connList);
                        IMetadataTable iTable = this.node.getMetadataTable(connNode.getUniqueName());
                        if (iTable != null && !connNode.getMetadataList().contains(iTable)) {
                        // connNode.getMetadataList().add(iTable);
                        }
                        JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                        reConnectCommand.setNewTarget(connNode);
                        reConnectCommand.execute();
                        break;
                    } else if (getFlowInput(inputs).size() == 1 && !isTri && new JobletUtil().isJobletInput(connNode, this.getProcess())) {
                        for (IConnection flowConn : getFlowInput(inputs)) {
                            if (!flowConn.getUniqueName().equals(conn.getUniqueName())) {
                                continue out;
                            }
                        }
                        JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                        reConnectCommand.setNewTarget(connNode);
                        reConnectCommand.execute();
                        break;
                    }
                }
            }
        }
    }
    Iterator<IConnection> outIterator = outputs.iterator();
    while (outIterator.hasNext()) {
        IConnection conn = outIterator.next();
        if (isCollapsed()) {
            ((Connection) conn).reconnect(this.node, conn.getTarget(), conn.getLineStyle());
        } else {
            for (NodeContainer nodeContainer : this.nodeContainers) {
                Node connNode = nodeContainer.getNode();
                if (conn.getConnectorName().equals(connNode.getJoblet_unique_name())) {
                    List<? extends INodeConnector> connList = new JobletUtil().createConnectors(connNode, this.getProcess());
                    List<INodeConnector> inodeConnList = new ArrayList<INodeConnector>();
                    inodeConnList.addAll(connList);
                    inodeConnList.addAll(connNode.getListConnector());
                    connNode.setListConnector(inodeConnList);
                    // connNode.setListConnector(connList);
                    IMetadataTable iTable = this.node.getMetadataTable(connNode.getUniqueName());
                    if (iTable != null && !connNode.getMetadataList().contains(iTable)) {
                    // connNode.getMetadataList().add(iTable);
                    }
                    JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                    reConnectCommand.setNewSource(connNode);
                    reConnectCommand.execute();
                // return;
                }
            }
        }
    }
    if (!isCollapsed()) {
        for (NodeContainer nodeContainer : this.nodeContainers) {
            Node connNode = nodeContainer.getNode();
            IProcess jobletProcess = this.getNode().getComponent().getProcess();
            List<? extends INode> jobletNodes = jobletProcess.getGraphicalNodes();
            for (INode n : jobletNodes) {
                if (connNode.getJoblet_unique_name().equals(n.getUniqueName())) {
                    connNode.setDummy(n.isDummy());
                // connNode.setActivate(n.isActivate());
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) INodeConnector(org.talend.core.model.process.INodeConnector) JobletConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.JobletConnectionReconnectCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 57 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class SapSchemaTypeController method addButton.

private Control addButton(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int top) {
    Button btn;
    Button resetBtn = null;
    Control lastControlUsed = lastControl;
    Point btnSize;
    FormData data;
    //$NON-NLS-1$
    btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    btn.addSelectionListener(listenerSelection);
    btn.setData(NAME, SCHEMA);
    btn.setData(PARAMETER_NAME, param.getName());
    // btn.setEnabled(!param.isReadOnly());
    lastControlUsed = btn;
    if (elem instanceof Node) {
        Node node = (Node) elem;
        boolean flowMainInput = false;
        boolean multipleInput = false;
        boolean tableReadOnly = false;
        IMetadataTable table = node.getMetadataFromConnector(param.getContext());
        if (table != null) {
            tableReadOnly = table.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens());
            for (IConnection connec : node.getIncomingConnections()) {
                if (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE) || connec.getLineStyle().equals(EConnectionType.FLOW_MERGE)) {
                    flowMainInput = true;
                }
            }
            IMetadataTable inputTable = null;
            if (flowMainInput) {
                int nbMain = 0;
                for (IConnection connec : node.getIncomingConnections()) {
                    if (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
                        if (inputTable == null) {
                            inputTable = connec.getMetadataTable();
                        }
                        nbMain++;
                    }
                }
                INodeConnector nodeConnector = node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName());
                if (nodeConnector != null) {
                    int maxFlowInput = nodeConnector.getMaxLinkInput();
                    if (maxFlowInput > 1 && nbMain >= 1 && (nbMain <= maxFlowInput || maxFlowInput == -1)) {
                        multipleInput = true;
                    }
                }
            }
            if (flowMainInput && !multipleInput) {
                if (node.getComponent().isSchemaAutoPropagated() && !table.sameMetadataAs(inputTable, IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT | IMetadataColumn.OPTIONS_IGNORE_PATTERN | IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME | IMetadataColumn.OPTIONS_IGNORE_DBTYPE | IMetadataColumn.OPTIONS_IGNORE_DEFAULT | IMetadataColumn.OPTIONS_IGNORE_BIGGER_SIZE)) {
                    tableReadOnly = false;
                }
                resetBtn = createAdditionalButton(subComposite, btn, btnSize, param, //$NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("SchemaController.syncColumns"), //$NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("SchemaController.resetButton.tooltip"), top, !tableReadOnly);
                resetBtn.setData(NAME, RESET_COLUMNS);
                lastControlUsed = resetBtn;
            }
        }
        if (top == 0 && node.getComponent().getName().equals(TUNISERVBTGENERIC)) {
            Button newButton = null;
            if (resetBtn != null) {
                newButton = resetBtn;
            } else {
                newButton = btn;
            }
            Button retrieveSchemaButton = createAdditionalButton(subComposite, newButton, btnSize, param, RETRIEVE_SCHEMA, RETRIEVE_SCHEMA, top, !param.isReadOnly());
            retrieveSchemaButton.setData(NAME, RETRIEVE_SCHEMA);
            lastControlUsed = retrieveSchemaButton;
        }
        // 0004322: tRunJob can import the tBufferOutput schema from the son job
        if (node.getComponent().getName().equals("tRunJob")) {
            //$NON-NLS-1$
            // for bug 10489
            Button newButton = null;
            if (resetBtn != null) {
                newButton = resetBtn;
            } else {
                newButton = btn;
            }
            Button copySchemaButton = createAdditionalButton(subComposite, newButton, btnSize, param, Messages.getString("SchemaController.copyChildSchema"), //$NON-NLS-1$
            Messages.getString("SchemaController.copyChildSchema.tooltip"), top, //$NON-NLS-1$
            !param.isReadOnly());
            copySchemaButton.setData(NAME, COPY_CHILD_COLUMNS);
            lastControlUsed = copySchemaButton;
        }
    }
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, Messages.getString("SchemaController.editSchema"));
    data = new FormData();
    data.left = new FormAttachment(lastControl, 0);
    data.right = new FormAttachment(lastControl, labelLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + (ITabbedPropertyConstants.HSPACE * 2), SWT.RIGHT);
    if (resetBtn != null) {
        data.top = new FormAttachment(resetBtn, 0, SWT.CENTER);
    } else {
        data.top = new FormAttachment(0, top);
    }
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    data = new FormData();
    data.left = new FormAttachment(labelLabel, 0);
    data.right = new FormAttachment(labelLabel, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    if (resetBtn != null) {
        data.top = new FormAttachment(resetBtn, 0, SWT.CENTER);
    } else {
        data.top = new FormAttachment(0, top);
    }
    data.height = STANDARD_HEIGHT - 2;
    btn.setLayoutData(data);
    // curRowSize = btnSize.y + ITabbedPropertyConstants.VSPACE;
    dynamicProperty.setCurRowSize(btnSize.y + ITabbedPropertyConstants.VSPACE);
    return lastControlUsed;
}
Also used : FormData(org.eclipse.swt.layout.FormData) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) CLabel(org.eclipse.swt.custom.CLabel) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IConnection(org.talend.core.model.process.IConnection) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) INodeConnector(org.talend.core.model.process.INodeConnector) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 58 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class SelectionFeedbackEditPolicy method showSelection.

@Override
public void showSelection() {
    if (this.sourceFigure == null) {
        this.sourceFigure = getHostFigure();
        this.sourceFigure.addFigureListener(this.figureListener);
    }
    INodeConnector connector = new NodeConnectorTool(nodePart).getConnector();
    if (connector == null) {
        this.setHideHandle(true);
        return;
    } else {
        this.setHideHandle(false);
    }
    showFeedback(false, connector);
}
Also used : NodeConnectorTool(org.talend.designer.core.ui.editor.connections.NodeConnectorTool) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 59 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class GenericElementParameter method updateSchema.

private void updateSchema() {
    IElement element = this.getElement();
    if (element instanceof Node) {
        Node node = (Node) element;
        List<INodeConnector> connectors = node.getConnectorsFromType(EConnectionType.FLOW_MAIN);
        for (INodeConnector connector : connectors) {
            if (connector instanceof GenericNodeConnector) {
                Connector componentConnector = ((GenericNodeConnector) connector).getComponentConnector();
                Schema schema = null;
                schema = getRootProperties().getSchema(componentConnector, ((GenericNodeConnector) connector).isOutput());
                IMetadataTable mainTable = node.getMetadataFromConnector(connector.getName());
                if (schema != null && mainTable != null) {
                    MetadataTable metadataTable = MetadataToolAvroHelper.convertFromAvro(schema);
                    IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
                    if (!mainTable.sameMetadataAs(newTable) || !newTable.sameMetadataAs(mainTable)) {
                        mainTable.setListColumns(newTable.getListColumns());
                        List<IElementParameter> schemaParameters = node.getElementParametersFromField(EParameterFieldType.SCHEMA_REFERENCE);
                        updateSchemaParameters(schemaParameters, connector.getName(), schema);
                        if (this.askPropagate == null && node.getOutgoingConnections().size() != 0) {
                            boolean hasPropagation = false;
                            for (IConnection connection : node.getOutgoingConnections()) {
                                if (connector.getName().equals(connection.getConnectorName())) {
                                    if (isSchemaPropagated(connection.getTarget())) {
                                        hasPropagation = true;
                                        break;
                                    }
                                }
                            }
                            if (hasPropagation) {
                                Display.getDefault().syncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        askPropagate = ChangeMetadataCommand.askPropagate();
                                    }
                                });
                            }
                        }
                        if (this.askPropagate != null && this.askPropagate) {
                            for (IConnection connection : node.getOutgoingConnections()) {
                                if (connector.getName().equals(connection.getConnectorName())) {
                                    INode target = connection.getTarget();
                                    if (!isSchemaPropagated(target)) {
                                        continue;
                                    }
                                    ChangeMetadataCommand cmd = new ChangeMetadataCommand(target, null, null, newTable, null);
                                    cmd.setPropagate(true);
                                    IProcess process = node.getProcess();
                                    if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
                                        CommandStack commandStack = ((org.talend.designer.core.ui.editor.process.Process) process).getCommandStack();
                                        commandStack.execute(cmd);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        this.askPropagate = null;
    }
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector) Connector(org.talend.components.api.component.Connector) CommandStack(org.eclipse.gef.commands.CommandStack) IElement(org.talend.core.model.process.IElement) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Schema(org.apache.avro.Schema) IConnection(org.talend.core.model.process.IConnection) IProcess(org.talend.core.model.process.IProcess) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess)

Example 60 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class Component method createIterateConnectors.

/**
     * Create iterate connector for this {@link Component} There are 4 types of components (depending on what main
     * connections allowed): 1. StandAlone component (can't have main connections at all) 2. Input component (can have
     * outgoing main connection) 3. Output component (can have incoming main connection) 4. Intermediate component (can
     * have both incoming and outgoing main connections)
     *
     * Iterate connector is created by default for TCOMP component with following rules: Outgoing iterate: all types of
     * components can have infinite outgoing iterate connections Incoming iterate: StandAlone, Input components (also
     * called startable components) can have 1 incoming iterate flow; Output, Intermediate components can't have
     * incoming iterate flow (because they are not startable)
     *
     * Note: infinite value is defined by -1 int value
     *
     * @param topologies connection topologies supported by this {@link Component}. Component could support several
     * topologies. Such component is called hybrid
     * @param listConnector list of all {@link Component} connectors
     * @param parentNode parent node
     */
private void createIterateConnectors(Set<ConnectorTopology> topologies, List<INodeConnector> listConnector, INode parentNode) {
    boolean inputOrNone = topologies.contains(ConnectorTopology.NONE) || topologies.contains(ConnectorTopology.OUTGOING);
    INodeConnector iterateConnector = addStandardType(listConnector, EConnectionType.ITERATE, parentNode);
    iterateConnector.setMaxLinkOutput(-1);
    if (inputOrNone) {
        iterateConnector.setMaxLinkInput(1);
    } else {
        iterateConnector.setMaxLinkInput(0);
    }
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector)

Aggregations

INodeConnector (org.talend.core.model.process.INodeConnector)76 ArrayList (java.util.ArrayList)37 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)31 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 IConnection (org.talend.core.model.process.IConnection)27 IElementParameter (org.talend.core.model.process.IElementParameter)22 Process (org.talend.designer.core.ui.editor.process.Process)21 List (java.util.List)20 Connection (org.talend.designer.core.ui.editor.connections.Connection)17 IJobletProviderService (org.talend.core.ui.IJobletProviderService)14 HashMap (java.util.HashMap)11 NodeConnector (org.talend.designer.core.model.components.NodeConnector)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)9 EConnectionType (org.talend.core.model.process.EConnectionType)9 Map (java.util.Map)8 IExternalNode (org.talend.core.model.process.IExternalNode)7 IProcess (org.talend.core.model.process.IProcess)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 Point (org.eclipse.draw2d.geometry.Point)6