Search in sources :

Example 16 with Connection

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

the class AbstractTraceAction method run.

@Override
public void run() {
    List selection = getSelectedObjects();
    Object input = selection.get(0);
    if (input instanceof ConnectionPart) {
        ConnectionPart connPart = (ConnectionPart) input;
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) part;
                Connection conn = (Connection) connPart.getModel();
                execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
                tracePart.refresh();
                break;
            }
        }
    }
    if (input instanceof ConnLabelEditPart) {
        ConnLabelEditPart labelPart = (ConnLabelEditPart) input;
        ConnectionPart connPart = (ConnectionPart) labelPart.getParent();
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) part;
                Connection conn = (Connection) connPart.getModel();
                execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
                tracePart.refresh();
                break;
            }
        }
    }
    if (input instanceof ConnectionTraceEditPart) {
        ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) input;
        ConnectionPart connPart = (ConnectionPart) tracePart.getParent();
        Connection conn = (Connection) connPart.getModel();
        execute(new PropertyChangeCommand(conn, EParameterName.TRACES_CONNECTION_ENABLE.getName(), isEnableAction()));
        tracePart.refresh();
    }
}
Also used : ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 17 with Connection

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

the class ActivateElementAction 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);
        nodeList = new ArrayList<Node>();
        for (int i = 0; i < parts.size(); i++) {
            if (parts.get(i) instanceof NodePart) {
                Node node = ((Node) ((NodePart) parts.get(i)).getModel());
                if ((!node.isReadOnly()) && (node.getPropertyValue(EParameterName.ACTIVATE.getName()) != null)) {
                    nodeList.add(node);
                }
            }
        }
        connectionList = new ArrayList<Connection>();
        for (int i = 0; i < parts.size(); i++) {
            if (parts.get(i) instanceof ConnectionPart) {
                Connection connection = ((Connection) ((ConnectionPart) parts.get(i)).getModel());
                if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
                    connectionList.add(connection);
                }
            }
            if (parts.get(i) instanceof ConnLabelEditPart) {
                Connection connection = ((ConnectionLabel) ((ConnLabelEditPart) parts.get(i)).getModel()).getConnection();
                if (!connection.isReadOnly() && connection.getSource().isActivate() && connection.getTarget().isActivate()) {
                    connectionList.add(connection);
                }
            }
        }
        if ((nodeList.size() == 0) && (connectionList.size() == 0)) {
            return false;
        }
        for (Node node : nodeList) {
            if (node.getJobletNode() != null) {
                return false;
            }
        }
        for (Connection conn : connectionList) {
            if (conn.getTarget().getJobletNode() != null && conn.getSource().getJobletNode() != null) {
                return false;
            }
        }
        if (nodeList.size() != 0) {
            if (nodeList.get(0).isActivate()) {
                if (nodeList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_REM_ACTIVATE + " " + nodeList.get(0).getLabel());
                } else {
                    setText(TEXT_REM_ACTIVATE);
                }
            } else {
                if (nodeList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_SET_ACTIVATE + " " + nodeList.get(0).getLabel());
                } else {
                    setText(TEXT_SET_ACTIVATE);
                }
                activate = true;
            }
        } else {
            // connections only
            if (connectionList.get(0).isActivate()) {
                if (connectionList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_REM_ACTIVATE + " " + connectionList.get(0).getName());
                } else {
                    setText(TEXT_REM_ACTIVATE);
                }
            } else {
                if (connectionList.size() == 1) {
                    //$NON-NLS-1$
                    setText(TEXT_SET_ACTIVATE + " " + connectionList.get(0).getName());
                } else {
                    setText(TEXT_SET_ACTIVATE);
                }
                activate = true;
            }
        }
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 18 with Connection

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

the class PropertyChangeCommand method execute.

@Override
public void execute() {
    IElementParameter currentParam = elem.getElementParameter(propName);
    changeMetadataCommands.clear();
    oldElementValues.clear();
    if (currentParam == null) {
        return;
    }
    if (currentParam instanceof ElementParameter) {
        ((ElementParameter) currentParam).setTaggedValue(UpdatesConstants.CHANGED_BY_USER, true);
    }
    if (currentParam.isRepositoryValueUsed()) {
        if (currentParam.getFieldType() == EParameterFieldType.MEMO_SQL) {
            Object queryStoreValue = elem.getPropertyValue(EParameterName.QUERYSTORE_TYPE.getName());
            if (!EmfComponent.BUILTIN.equals(queryStoreValue) || !EmfComponent.TNS_FILE.equals(queryStoreValue)) {
                elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(), EmfComponent.BUILTIN);
            }
            currentParam.setRepositoryValueUsed(false);
        } else {
            toUpdate = true;
            Object value = elem.getPropertyValue(propName);
            if (value == null || (!value.toString().endsWith("xsd") && !value.toString().endsWith("xsd\""))) {
                elem.setPropertyValue(propertyTypeName, EmfComponent.BUILTIN);
            }
            for (IElementParameter param : elem.getElementParameters()) {
                if (param.getRepositoryProperty() == null || param.getRepositoryProperty().equals(currentParam.getName())) {
                    param.setRepositoryValueUsed(false);
                }
            }
        }
        repositoryValueWasUsed = true;
    } else {
        repositoryValueWasUsed = false;
    }
    oldValue = elem.getPropertyValue(propName);
    elem.setPropertyValue(propName, newValue);
    if (currentParam.getFieldType().equals(EParameterFieldType.CONNECTION_LIST) && currentParam.getContext() != null && (elem instanceof Node)) {
        String connParaname = currentParam.getContext() + ":" + currentParam.getName();
        if (connParaname.equals(propName)) {
            IConnection selectedConn = null;
            for (IConnection conn : ((Node) elem).getIncomingConnections()) {
                if (conn.getUniqueName().equals(newValue)) {
                    selectedConn = conn;
                    break;
                }
            }
            if (selectedConn != null && getTakeSchema()) {
                ((Node) selectedConn.getSource()).takeSchemaFrom((Node) elem, currentParam.getContext());
            }
        }
    }
    if ("ELT_TABLE_NAME".equals(propName) || "ELT_SCHEMA_NAME".equals(propName)) {
        //$NON-NLS-1$ //$NON-NLS-2$
        //$NON-NLS-1$
        String oldELTValue = "";
        //$NON-NLS-1$
        String newELTValue = "";
        String oldParamValue = TalendQuoteUtils.removeQuotes((String) oldValue);
        String newParamValue = TalendQuoteUtils.removeQuotes((String) newValue);
        if ("ELT_TABLE_NAME".equals(propName)) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            String schemaName = TalendQuoteUtils.removeQuotes((String) elem.getPropertyValue("ELT_SCHEMA_NAME"));
            if (schemaName == null || "".equals(schemaName.trim())) {
                //$NON-NLS-1$
                oldELTValue = oldParamValue;
                newELTValue = newParamValue;
            } else {
                //$NON-NLS-1$
                oldELTValue = schemaName + "." + oldParamValue;
                //$NON-NLS-1$
                newELTValue = schemaName + "." + newParamValue;
            }
        } else {
            //$NON-NLS-1$
            String tableName = TalendQuoteUtils.removeQuotes((String) elem.getPropertyValue("ELT_TABLE_NAME"));
            if (oldParamValue != null && !"".equals(oldParamValue.trim())) {
                //$NON-NLS-1$
                oldELTValue = oldParamValue + ".";
            }
            if (newParamValue != null && !"".equals(newParamValue.trim())) {
                //$NON-NLS-1$
                newELTValue = newParamValue + ".";
            }
            // $NON-NLS-1$
            oldELTValue = oldELTValue + tableName;
            // $NON-NLS-1$
            newELTValue = newELTValue + tableName;
        }
        List<? extends IConnection> connections = ((Node) elem).getOutgoingConnections();
        for (IConnection connection : connections) {
            INode targetNode = connection.getTarget();
            String componentName = targetNode.getComponent().getName();
            if (componentName.matches("tELT.+Map")) {
                //$NON-NLS-1$
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IDbMapDesignerService.class)) {
                    IDbMapDesignerService service = (IDbMapDesignerService) GlobalServiceRegister.getDefault().getService(IDbMapDesignerService.class);
                    updateELTMapComponentCommand = service.getUpdateELTMapComponentCommand(targetNode, connection, oldELTValue, newELTValue);
                    updateELTMapComponentCommand.execute();
                }
            }
        }
    }
    // add for bug TDI-26632 by fwang in 11 July, 2013. can't edit parameters if use repository connection.
    IElementParameter propertyTypeParam = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
    IElementParameter repositoryTypeParam = elem.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    if (("USE_EXISTING_CONNECTION").equals(propName) && elem instanceof Node && propertyTypeParam != null && "REPOSITORY".equals(propertyTypeParam.getValue()) && repositoryTypeParam != null && !("").equals(repositoryTypeParam.getValue())) {
        Node node = (Node) elem;
        for (IElementParameter param : node.getElementParameters()) {
            String repositoryValue = param.getRepositoryValue();
            if ((repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL && !("tMDMReceive".equals(node.getComponent().getName()) && "XPATH_PREFIX".equals(//$NON-NLS-1$ //$NON-NLS-2$
            param.getRepositoryValue())) && !("tSAPOutput".equals(node.getComponent().getName()) && param.getName().equals(UpdatesConstants.MAPPING)) && !("tFileInputEBCDIC".equals(node.getComponent().getName()) && "DATA_FILE".equals(repositoryValue))) {
                param.setRepositoryValueUsed(true);
                if (!(EParameterName.DB_VERSION.getName()).equals(param.getName())) {
                    param.setReadOnly(true);
                }
            }
        }
    }
    // feature 19312
    if (propName.contains(EParameterName.USE_DYNAMIC_JOB.getName()) && newValue.equals(false)) {
        IElementParameter processParam = elem.getElementParameter(EParameterName.PROCESS.getName());
        IElementParameter processTypeParameter = elem.getElementParameter(EParameterName.PROCESS_TYPE_PROCESS.getName());
        //$NON-NLS-1$
        final String parentName = processParam.getName() + ":";
        //$NON-NLS-1$
        elem.setPropertyValue(parentName + processTypeParameter.getName(), "");
        //$NON-NLS-1$
        elem.setPropertyValue(processParam.getName(), "");
    }
    if (propName.contains(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
        boolean isSelectUseDynamic = false;
        IElementParameter useDynamicJobParameter = elem.getElementParameter(EParameterName.USE_DYNAMIC_JOB.getName());
        if (useDynamicJobParameter != null && useDynamicJobParameter instanceof IElementParameter) {
            Object useDynamicJobValue = useDynamicJobParameter.getValue();
            if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
                isSelectUseDynamic = (Boolean) useDynamicJobValue;
            }
        }
        if (isSelectUseDynamic) {
            StringBuffer labels = new StringBuffer("");
            if (newValue != null) {
                String[] strValues = newValue.toString().split(";");
                for (int i = 0; i < strValues.length; i++) {
                    String strValue = strValues[i];
                    // newValue is the id of the job
                    ProcessItem processItem = ItemCacheManager.getProcessItem(strValue);
                    if (processItem != null) {
                        String label = processItem.getProperty().getLabel();
                        if (i > 0) {
                            labels.append(";");
                        }
                        labels.append(label);
                    }
                }
            }
            currentParam.getParentParameter().setValue(labels.toString());
        } else {
            // newValue is the id of the job
            ProcessItem processItem = ItemCacheManager.getProcessItem((String) newValue);
            if (processItem != null) {
                currentParam.getParentParameter().setValue(processItem.getProperty().getLabel());
            }
        }
    }
    if (propName.contains(EParameterName.PROCESS_TYPE_VERSION.getName())) {
        // newValue is the id of the job
        // hywang add for feature 6549
        // 1.to see current component if is a jobletComponent by "elem"
        boolean isJobletComponent = false;
        // Node jobletNode = null;
        IJobletProviderService service = null;
        if (PluginChecker.isJobLetPluginLoaded()) {
            service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        }
        if (elem instanceof Node) {
            // jobletNode = (Node) elem;
            if (service != null) {
                isJobletComponent = service.isJobletComponent((Node) elem);
            }
        }
        if (isJobletComponent) {
            // 2.if it is a jobletcomponent,reload the component by the version
            String id = service.getJobletComponentItem((Node) elem).getId();
            String version = (String) newValue;
            IComponent newComponent = service.setPropertyForJobletComponent(id, version);
            reloadNode((Node) elem, newComponent);
        } else {
            IElementParameter processIdParam = currentParam.getParentParameter().getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
            ProcessItem processItem = ItemCacheManager.getProcessItem((String) processIdParam.getValue(), (String) newValue);
            if (processItem != null) {
                currentParam.getParentParameter().setValue(processItem.getProperty().getLabel());
            }
        }
    }
    if (propName.contains(EParameterName.PROCESS_TYPE_CONTEXT.getName())) {
        if (elem instanceof Node) {
            Node node = (Node) elem;
            List<IContext> listContext = node.getProcess().getContextManager().getListContext();
            List<String> values = new ArrayList<String>();
            for (IContext context : listContext) {
                values.add(context.getName());
            }
            currentParam.setListItemsDisplayName(values.toArray(new String[0]));
            currentParam.setListItemsValue(values.toArray(new String[0]));
            currentParam.setValue(newValue);
        }
    }
    if (propName.equals(EParameterName.VALIDATION_RULES.getName())) {
        if (elem instanceof INode) {
            ValidationRulesUtil.createRejectConnector((INode) elem);
            ValidationRulesUtil.updateRejectMetatable((INode) elem, null);
            if (newValue != null && (!(Boolean) newValue)) {
                ValidationRulesUtil.removeRejectConnector((INode) elem);
                ValidationRulesUtil.removeRejectConnection((INode) elem);
            }
        }
    }
    String dbType = "";
    if (newValue instanceof String) {
        dbType = (String) newValue;
    }
    IElementParameter schemaParameter = null;
    if (propName.equals(EParameterName.DB_TYPE.getName())) {
        IElementParameter elementParameter = elem.getElementParameter(EParameterName.DB_VERSION.getName());
        schemaParameter = elem.getElementParameter(EParameterName.SCHEMA_DB.getName());
        JobSettingVersionUtil.setDbVersion(elementParameter, dbType, true);
        DesignerUtilities.setSchemaDB(schemaParameter, newValue);
    } else if (propName.equals(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName()))) {
        IElementParameter elementParameter = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName()));
        schemaParameter = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
        JobSettingVersionUtil.setDbVersion(elementParameter, dbType, true);
        DesignerUtilities.setSchemaDB(schemaParameter, newValue);
    }
    // Some DB not need fill the schema parameter for the JobSetting View "Extra" ,"Stats&Logs"
    if (schemaParameter != null && !schemaParameter.isShow(elem.getElementParameters()) && !schemaParameter.getValue().equals("")) {
        schemaParameter.setValue("");
    }
    if (!toUpdate && (currentParam.getFieldType().equals(EParameterFieldType.RADIO) || currentParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST) || currentParam.getFieldType().equals(EParameterFieldType.OPENED_LIST) || currentParam.getFieldType().equals(EParameterFieldType.CHECK) || currentParam.getFieldType().equals(EParameterFieldType.AS400_CHECK) || currentParam.getFieldType().equals(EParameterFieldType.COMPONENT_LIST))) {
        toUpdate = false;
        setDefaultValues(currentParam, elem);
    }
    if (currentParam.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
        toUpdate = true;
    }
    if (toUpdate) {
        elem.setPropertyValue(updataComponentParamName, Boolean.TRUE);
    }
    // see bug 9151:100% CPU when typing text.
    if (getNewValue() instanceof String && elem instanceof INode) {
        INode curNode = (INode) elem;
        String uniqueName = curNode.getUniqueName();
        IProcess process = curNode.getProcess();
        if (process != null && process instanceof IProcess2) {
            IProcess2 process2 = (IProcess2) process;
            List<? extends INode> generatingNodes = null;
            if (process2.isProcessModified()) {
                process2.setProcessModified(false);
                generatingNodes = process2.getGeneratingNodes();
                if (generatingNodes != null) {
                    for (INode genNode : new ArrayList<INode>(generatingNodes)) {
                        if (genNode.getUniqueName().equals(uniqueName)) {
                            IElementParameter genParam = genNode.getElementParameter(propName);
                            if (genParam != null) {
                                genParam.setValue(newValue);
                                break;
                            }
                        }
                    }
                }
                process2.setProcessModified(true);
                codeViewUpdater.startIfExecutable(elem);
            }
        }
    }
    updateRelativeNodesIfNeeded(currentParam);
    checkProcess.startIfExecutable(elem);
    // See feature 3902
    if (needUpdateMonitorConnection()) {
        ((Connection) elem).setMonitorConnection((Boolean) currentParam.getValue());
    }
    refreshMR(propName);
}
Also used : INode(org.talend.core.model.process.INode) IContext(org.talend.core.model.process.IContext) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IDbMapDesignerService(org.talend.designer.core.IDbMapDesignerService) IJobletProviderService(org.talend.core.ui.IJobletProviderService) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2)

Example 19 with Connection

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

the class GefEditorLabelProvider method getText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
public String getText(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        //$NON-NLS-1$
        return "No items selected";
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) /* || ((IStructuredSelection) objects).size() > 1 */
    {
        //$NON-NLS-1$
        return "No items selected";
    } else {
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nContainer = (NodeContainerPart) object;
            Process process = (Process) nContainer.getParent().getModel();
            return process.getName();
        } else if (object instanceof ProcessPart) {
            Process process = (Process) ((ProcessPart) object).getModel();
            return process.getLabel();
        } else if (object instanceof ProcessTreeEditPart) {
            Process process = (Process) ((ProcessTreeEditPart) object).getModel();
            return process.getName();
        }
        if (object instanceof ConnectionPart) {
            Connection conn = (Connection) ((ConnectionPart) object).getModel();
            return conn.getName();
        }
        if (object instanceof NoteEditPart) {
            return Note.class.getSimpleName();
        }
        if (object instanceof ConnLabelEditPart) {
            Connection conn = (Connection) ((ConnectionLabel) ((ConnLabelEditPart) object).getModel()).getConnection();
            return conn.getName();
        }
        if (object instanceof NodeTreeEditPart) {
            node = (Node) ((NodeTreeEditPart) object).getModel();
        } else {
            if (object instanceof NodeReturnsTreeEditPart) {
                node = lastNode;
            } else {
                if (object instanceof NodeLabelEditPart) {
                    node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
                }
                if (!(object instanceof NodePart)) {
                    return null;
                }
                if (node == null) {
                    node = (Node) ((NodePart) object).getModel();
                }
            }
        }
        if (lastNode != node) {
            lastNode = node;
        }
        String name = node.getUniqueName();
        // }
        return name;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessTreeEditPart(org.talend.designer.core.ui.editor.outline.ProcessTreeEditPart) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 20 with Connection

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

the class TableByRowController method updateColumnList.

private void updateColumnList(IElementParameter param) {
    if (elem instanceof Node) {
        ColumnListController.updateColumnList((Node) elem, null);
    } else if (elem instanceof Connection) {
        ColumnListController.updateColumnList(((Connection) elem).getSource(), null);
    }
    TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
    Object[] itemsValue = param.getListItemsValue();
    if (tableViewerCreator != null && itemsValue != null) {
        List colList = tableViewerCreator.getColumns();
        for (int j = 0; j < itemsValue.length; j++) {
            if (itemsValue[j] instanceof IElementParameter) {
                IElementParameter tmpParam = (IElementParameter) itemsValue[j];
                if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
                    if ((j + 1) >= colList.size()) {
                        break;
                    }
                    TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
                    CellEditor cellEditor = column.getCellEditor();
                    String[] oldItems = null;
                    if (cellEditor instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) cellEditor.getControl();
                        oldItems = combo.getItems();
                        combo.setItems(tmpParam.getListItemsDisplayName());
                    }
                    List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
                    String[] items = param.getListItemsDisplayCodeName();
                    for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
                        Map<String, Object> currentLine = paramValues.get(currentIndex);
                        Object o = currentLine.get(items[j]);
                        if (o instanceof Integer) {
                            Integer nb = (Integer) o;
                            if ((nb >= oldItems.length) || (nb == -1)) {
                                nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
                                currentLine.put(items[j], nb);
                            } else {
                                nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
                                currentLine.put(items[j], nb);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) CellEditor(org.eclipse.jface.viewers.CellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) Point(org.eclipse.swt.graphics.Point) CCombo(org.eclipse.swt.custom.CCombo) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Connection (org.talend.designer.core.ui.editor.connections.Connection)84 IConnection (org.talend.core.model.process.IConnection)52 ArrayList (java.util.ArrayList)47 List (java.util.List)46 Node (org.talend.designer.core.ui.editor.nodes.Node)44 INode (org.talend.core.model.process.INode)35 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)28 Process (org.talend.designer.core.ui.editor.process.Process)24 IElementParameter (org.talend.core.model.process.IElementParameter)20 INodeConnector (org.talend.core.model.process.INodeConnector)18 HashMap (java.util.HashMap)12 IComponent (org.talend.core.model.components.IComponent)12 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)12 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)10 Property (org.talend.core.model.properties.Property)10 Test (org.junit.Test)9 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 Map (java.util.Map)8