Search in sources :

Example 1 with EParameterFieldType

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

the class AbstractXMLConfigPage method loadAttrsInfo.

protected void loadAttrsInfo() {
    attrsAvailableValuesMap = new HashMap<String, String[]>();
    String[] valuesArray = null;
    // CTYPE
    EConnectionType[] eConnectionTypes = EConnectionType.values();
    valuesArray = new String[eConnectionTypes.length];
    for (int i = 0; i < eConnectionTypes.length; i++) {
        valuesArray[i] = eConnectionTypes[i].getName();
    }
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("CTYPE", valuesArray);
    // FIELD
    EParameterFieldType[] eParameterFieldType = EParameterFieldType.values();
    valuesArray = new String[eParameterFieldType.length];
    for (int i = 0; i < eParameterFieldType.length; i++) {
        valuesArray[i] = eParameterFieldType[i].getName();
    }
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("FIELD", valuesArray);
    // PLATFORM
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    attrsAvailableValuesMap.put("PLATEFORM", new String[] { "ALL", "WINDOWS", "LINUX" });
    // COMPATIBILITY
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    attrsAvailableValuesMap.put("COMPATIBILITY", new String[] { "ALL", "WINDOWS", "LINUX" });
    // STATUS
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    attrsAvailableValuesMap.put("STATUS", new String[] { "ALPHA", "BETA", "RELEASE" });
    // LINE_STYLE
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    attrsAvailableValuesMap.put("LINE_STYLE", new String[] { "1", "2", "3", "4" });
    // NB_LINES
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    attrsAvailableValuesMap.put("NB_LINES", new String[] { "1", "2", "3", "4", "5" });
    // MAX_INPUT MIN_INPUT MAX_OUTPUT MIN_OUTPUT
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    valuesArray = new String[] { "0", "1", "2", "3", "4", "5" };
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("MAX_INPUT", valuesArray);
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("MIN_INPUT", valuesArray);
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("MAX_OUTPUT", valuesArray);
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("MIN_OUTPUT", valuesArray);
    // PROPERTY_TYPE
    List<String> valuesList = new ArrayList<String>();
    //$NON-NLS-1$
    valuesList.add("DELIMITED");
    //$NON-NLS-1$
    valuesList.add("POSITIONAL");
    //$NON-NLS-1$
    valuesList.add("REGEX");
    //$NON-NLS-1$
    valuesList.add("XML");
    //$NON-NLS-1$
    valuesList.add("LDAP");
    //$NON-NLS-1$
    valuesList.add("WSDL");
    //$NON-NLS-1$
    valuesList.add("GENERIC");
    //$NON-NLS-1$
    valuesList.add("DATABASE");
    for (EDatabaseTypeName eDatabaseTypeName : EDatabaseTypeName.values()) {
        //$NON-NLS-1$
        valuesList.add("DATABASE:" + eDatabaseTypeName.getProduct());
    }
    //$NON-NLS-1$
    attrsAvailableValuesMap.put("REPOSITORY_VALUE", valuesList.toArray(new String[0]));
    // attributes with boolean value
    String[] booleanAttrNameArray = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "SHOW", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "REQUIRED", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "READONLY", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "BASED_ON_SCHEMA", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "KEY", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "NULLABLE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    "CUSTOM", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "BUILTIN", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "STARTABLE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "SCHEMA_AUTO_PROPAGATE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "DATA_AUTO_PROPAGATE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "HAS_CONDITIONAL_OUTPUTS", "IS_MULTIPLYING_OUTPUTS", "VISIBLE", "TSTATCATCHER_STATS", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "USE_MERGE" };
    //$NON-NLS-1$ //$NON-NLS-2$
    String[] booleanArray = { "true", "false" };
    for (String attrName : booleanAttrNameArray) {
        attrsAvailableValuesMap.put(attrName, booleanArray);
    }
    // init maps for TooTipsText
    attrsToolTipsMap = new HashMap<String, String>();
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("MAX_INPUT", Messages.getString("AbstractXMLConfigPage.MAXINPUTTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("MIN_INPUT", Messages.getString("AbstractXMLConfigPage.MININPUTTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("MAX_OUTPUT", Messages.getString("AbstractXMLConfigPage.MAXOUTPUTTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("MIN_OUTPUT", Messages.getString("AbstractXMLConfigPage.MINOUTPUTTip"));
    //$NON-NLS-1$
    attrsToolTipsMap.put(//$NON-NLS-1$
    "LINE_STYLE", //$NON-NLS-1$
    Messages.getString("AbstractXMLConfigPage.LINESTYLETip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("LENGTH", Messages.getString("AbstractXMLConfigPage.IntValue"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("PRECISION", Messages.getString("AbstractXMLConfigPage.IntValue"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("NB_LINES", Messages.getString("AbstractXMLConfigPage.NBLINESTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("NUM_ROW", Messages.getString("AbstractXMLConfigPage.NUMROWTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("VERSION", Messages.getString("AbstractXMLConfigPage.VERSIONTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("REPOSITORY_VALUE", Messages.getString("AbstractXMLConfigPage.REPOSITORYVALUETip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("EXTENSION", Messages.getString("AbstractXMLConfigPage.EXTENSIONTip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("CTYPE", Messages.getString("AbstractXMLConfigPage.CTYPETip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("TYPE", Messages.getString("AbstractXMLConfigPage.TYPETip"));
    //$NON-NLS-1$ //$NON-NLS-2$
    attrsToolTipsMap.put("COLOR", Messages.getString("AbstractXMLConfigPage.COLORTip"));
    for (String attrName : booleanAttrNameArray) {
        //$NON-NLS-1$
        attrsToolTipsMap.put(attrName, Messages.getString("AbstractXMLConfigPage.BooleanTip"));
    }
}
Also used : EParameterFieldType(org.talend.core.model.process.EParameterFieldType) ArrayList(java.util.ArrayList) EDatabaseTypeName(org.talend.core.database.EDatabaseTypeName) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 2 with EParameterFieldType

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

the class DynamicPropertyGenerator method initController.

/**
     * DOC yzhang Comment method "initController".
     */
public void initController(IDynamicProperty dp) {
    if (!initialized) {
        for (IConfigurationElement element : extensionElements) {
            try {
                //$NON-NLS-1$
                String controllerName = element.getAttribute("mapping");
                EParameterFieldType key = EParameterFieldType.getFieldTypeByName(controllerName);
                if (!dtpControls.containsKey(key)) {
                    if (!controllerName.equals(key.toString())) {
                        throw new RuntimeException(//$NON-NLS-1$
                        "Mapping attribute " + controllerName + //$NON-NLS-1$
                        " not included in eumn EParameterFieldType");
                    }
                    //$NON-NLS-1$
                    IControllerGenerator generator = (IControllerGenerator) element.createExecutableExtension("class");
                    generator.setDynamicProperty(dp);
                    AbstractElementPropertySectionController controller = generator.generate();
                    dtpControls.put(key, controller);
                    if (controller instanceof AbstractRepositoryController) {
                        ControllerRepositoryValueHander repositoryValueHander = ((AbstractRepositoryController) controller).getRepositoryValueHander();
                        ControllerRepositoryValueHander.getRepositoryValueHandlerMap().put(key, repositoryValueHander);
                    }
                }
            } catch (CoreException e) {
                ExceptionHandler.process(e);
            }
        }
        initialized = true;
    }
}
Also used : EParameterFieldType(org.talend.core.model.process.EParameterFieldType) CoreException(org.eclipse.core.runtime.CoreException) IControllerGenerator(org.talend.designer.core.ui.editor.properties.controllers.generator.IControllerGenerator) AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) AbstractRepositoryController(org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController) ControllerRepositoryValueHander(org.talend.designer.core.ui.editor.properties.controllers.ControllerRepositoryValueHander) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 3 with EParameterFieldType

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

the class ComponentsUtils method getParametersFromForm.

/**
     * DOC ycbai Comment method "loadParametersFromForm".
     * <p>
     * Get element parameters of <code>element</code> from <code>form</code>.
     *
     * @param node optional, used if there is a component setting up the properties
     * @param element
     * @param category
     * @param form
     * @return parameters list
     */
private static List<ElementParameter> getParametersFromForm(IElement element, boolean isInitializing, EComponentCategory category, ComponentProperties rootProperty, Properties compProperties, String parentPropertiesPath, Form form, Widget parentWidget, AtomicInteger lastRowNum) {
    List<ElementParameter> elementParameters = new ArrayList<>();
    List<String> parameterNames = new ArrayList<>();
    EComponentCategory compCategory = category;
    if (compCategory == null) {
        compCategory = EComponentCategory.BASIC;
    }
    AtomicInteger lastRN = lastRowNum;
    if (lastRN == null) {
        lastRN = new AtomicInteger();
    }
    if (form == null) {
        return elementParameters;
    }
    Properties componentProperties = compProperties;
    if (componentProperties == null) {
        componentProperties = form.getProperties();
    }
    if (element instanceof INode) {
        INode node = (INode) element;
        // Set the properties only one time to get the top-level properties object
        if (node.getComponentProperties() == null) {
            node.setComponentProperties(rootProperty);
        }
    }
    // Have to initialize for the messages
    Collection<Widget> formWidgets = form.getWidgets();
    for (Widget widget : formWidgets) {
        NamedThing widgetProperty = widget.getContent();
        String propertiesPath = getPropertiesPath(parentPropertiesPath, null);
        if (widgetProperty instanceof Form) {
            Form subForm = (Form) widgetProperty;
            Properties subProperties = subForm.getProperties();
            // Reset properties path
            if (!isSameComponentProperties(componentProperties, widgetProperty)) {
                propertiesPath = getPropertiesPath(parentPropertiesPath, subProperties.getName());
            }
            elementParameters.addAll(getParametersFromForm(element, isInitializing, compCategory, rootProperty, subProperties, propertiesPath, subForm, widget, lastRN));
            continue;
        }
        GenericElementParameter param = new GenericElementParameter(element, rootProperty, form, widget, getComponentService());
        String parameterName = propertiesPath.concat(param.getName());
        param.setName(parameterName);
        param.setCategory(compCategory);
        param.setShow(parentWidget == null ? !widget.isHidden() : !parentWidget.isHidden() && !widget.isHidden());
        int rowNum = 0;
        if (widget.getOrder() != 1) {
            rowNum = lastRN.get();
        } else {
            rowNum = widget.getRow();
            if (parentWidget != null) {
                rowNum += parentWidget.getRow();
            }
            rowNum = rowNum + lastRN.get();
        }
        param.setNumRow(rowNum);
        lastRN.set(rowNum);
        // handle form...
        EParameterFieldType fieldType = getFieldType(widget, widgetProperty);
        param.setFieldType(fieldType != null ? fieldType : EParameterFieldType.TEXT);
        if (widgetProperty instanceof SchemaProperty) {
            boolean found = false;
            // set a default connector
            param.setContext(EConnectionType.FLOW_MAIN.getName());
            for (Connector connector : rootProperty.getPossibleConnectors(true)) {
                if (!(((SchemaProperty) widgetProperty).getValue() instanceof Schema)) {
                    continue;
                }
                if (connector instanceof PropertyPathConnector) {
                    //$NON-NLS-1$
                    String linkedSchema = ((PropertyPathConnector) connector).getPropertyPath() + ".schema";
                    if (parameterName.equals(linkedSchema)) {
                        found = true;
                        param.setContext(connector.getName());
                        IElementParameterDefaultValue defaultValue = new ElementParameterDefaultValue();
                        Schema schema = ((SchemaProperty) widgetProperty).getValue();
                        defaultValue.setDefaultValue(new Schema.Parser().parse(schema.toString()));
                        param.getDefaultValues().add(defaultValue);
                    }
                }
            }
            if (!found) {
                // compatibility.
                for (Connector connector : rootProperty.getPossibleConnectors(false)) {
                    if (!(((SchemaProperty) widgetProperty).getValue() instanceof Schema)) {
                        continue;
                    }
                    if (connector instanceof PropertyPathConnector) {
                        //$NON-NLS-1$
                        String linkedSchema = ((PropertyPathConnector) connector).getPropertyPath() + ".schema";
                        if (parameterName.equals(linkedSchema)) {
                            if (GenericNodeConnector.INPUT_CONNECTOR.equals(connector.getName())) {
                                param.setContext(EConnectionType.FLOW_MAIN.getName());
                            } else {
                                param.setContext(connector.getName());
                            }
                            IElementParameterDefaultValue defaultValue = new ElementParameterDefaultValue();
                            Schema schema = ((SchemaProperty) widgetProperty).getValue();
                            defaultValue.setDefaultValue(new Schema.Parser().parse(schema.toString()));
                            param.getDefaultValues().add(defaultValue);
                        }
                    }
                }
            }
        }
        if (widgetProperty instanceof PresentationItem) {
            param.setValue(widgetProperty.getDisplayName());
        } else if (widgetProperty instanceof Property) {
            Property property = (Property) widgetProperty;
            param.setRequired(property.isRequired());
            param.setValue(getParameterValue(element, property, fieldType));
            boolean isNameProperty = IGenericConstants.NAME_PROPERTY.equals(param.getParameterName());
            if (EParameterFieldType.NAME_SELECTION_AREA.equals(fieldType) || EParameterFieldType.JSON_TABLE.equals(fieldType) || EParameterFieldType.CLOSED_LIST.equals(fieldType) || EParameterFieldType.CHECK.equals(fieldType) || isNameProperty) {
                // Disable context support for those filed types and name parameter.
                param.setSupportContext(false);
            } else {
                param.setSupportContext(isSupportContext(property));
            }
            property.setTaggedValue(IComponentConstants.SUPPORT_CONTEXT, param.isSupportContext());
            Object cmTV = property.getTaggedValue(IGenericConstants.IS_CONTEXT_MODE);
            param.setReadOnly(Boolean.valueOf(String.valueOf(cmTV)));
            boolean isDynamic = Boolean.valueOf(String.valueOf(property.getTaggedValue(IGenericConstants.IS_DYNAMIC)));
            param.setContextMode(isDynamic);
            List<?> values = property.getPossibleValues();
            if (values != null || EParameterFieldType.CLOSED_LIST.equals(fieldType)) {
                if (values == null) {
                    values = Collections.emptyList();
                }
                param.setPossibleValues(values);
                List<String> possVals = new ArrayList<>();
                List<String> possValsDisplay = new ArrayList<>();
                for (Object obj : values) {
                    String value = null;
                    String valueDisplay = null;
                    if (obj instanceof NamedThing) {
                        NamedThing nal = (NamedThing) obj;
                        value = nal.getName();
                        valueDisplay = nal.getDisplayName();
                    } else {
                        value = String.valueOf(obj);
                        valueDisplay = String.valueOf(obj);
                    }
                    String pvDisplayName = property.getPossibleValuesDisplayName(obj);
                    if (StringUtils.isNotBlank(pvDisplayName) && !"null".equals(pvDisplayName)) {
                        //$NON-NLS-1$
                        valueDisplay = pvDisplayName;
                    }
                    possVals.add(value);
                    possValsDisplay.add(valueDisplay);
                }
                param.setListItemsDisplayName(possValsDisplay.toArray(new String[0]));
                param.setListItemsDisplayCodeName(possValsDisplay.toArray(new String[0]));
                param.setListItemsValue(possVals.toArray(new String[0]));
            }
        } else if (fieldType != null && fieldType.equals(EParameterFieldType.TABLE) && widgetProperty instanceof Properties) {
            Properties table = (Properties) widgetProperty;
            Form mainForm = table.getForm(Form.MAIN);
            param.setDisplayName(mainForm.getTitle());
            //$NON-NLS-1$
            List<ElementParameter> parameters = getParametersFromForm(new FakeElement("table"), mainForm);
            // table is always empty by default
            param.setSupportContext(false);
            List<String> codeNames = new ArrayList<>();
            List<String> possValsDisplay = new ArrayList<>();
            for (ElementParameter curParam : parameters) {
                curParam.setFilter(null);
                curParam.setContext(null);
                curParam.setShowIf(null);
                curParam.setNotShowIf(null);
                curParam.setReadOnlyIf(null);
                curParam.setNotReadOnlyIf(null);
                curParam.setNoContextAssist(false);
                curParam.setRaw(false);
                curParam.setReadOnly(false);
                fillDefaultValsForListType(curParam);
                codeNames.add(curParam.getName());
                possValsDisplay.add(curParam.getDisplayName());
            }
            param.setListItemsDisplayName(possValsDisplay.toArray(new String[0]));
            param.setListItemsDisplayCodeName(codeNames.toArray(new String[0]));
            param.setListItemsValue(parameters.toArray(new ElementParameter[0]));
            String[] listItemsShowIf = new String[parameters.size()];
            String[] listItemsNotShowIf = new String[parameters.size()];
            param.setListItemsShowIf(listItemsShowIf);
            param.setListItemsNotShowIf(listItemsNotShowIf);
            param.setValue(GenericTableUtils.getTableValues(table, param));
            param.setBasedOnSchema(Boolean.valueOf(String.valueOf(widget.getConfigurationValue(Widget.HIDE_TOOLBAR_WIDGET_CONF))));
        }
        if (!param.isReadOnly()) {
            param.setReadOnly(widget.isReadonly() || element.isReadOnly());
        }
        // For issue TUP-16139
        if (EParameterFieldType.COMPONENT_REFERENCE.equals(fieldType) && param.getNumRow() == 2 && EComponentCategory.BASIC.equals(compCategory)) {
            param.setNumRow(1);
        }
        param.setSerialized(true);
        param.setDynamicSettings(true);
        // Avoid adding duplicate prameter.
        if (!parameterNames.contains(parameterName)) {
            elementParameters.add(param);
            parameterNames.add(parameterName);
        }
    }
    return elementParameters;
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) INodeConnector(org.talend.core.model.process.INodeConnector) GenericNodeConnector(org.talend.designer.core.generic.model.GenericNodeConnector) Connector(org.talend.components.api.component.Connector) INode(org.talend.core.model.process.INode) PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) Form(org.talend.daikon.properties.presentation.Form) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) Widget(org.talend.daikon.properties.presentation.Widget) ComponentProperties(org.talend.components.api.properties.ComponentProperties) Properties(org.talend.daikon.properties.Properties) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameterDefaultValue(org.talend.core.model.process.IElementParameterDefaultValue) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) Property(org.talend.daikon.properties.property.Property) SchemaProperty(org.talend.daikon.properties.property.SchemaProperty) EComponentCategory(org.talend.core.model.process.EComponentCategory) SchemaProperty(org.talend.daikon.properties.property.SchemaProperty) PresentationItem(org.talend.daikon.properties.PresentationItem) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) FakeElement(org.talend.designer.core.model.FakeElement) EParameterFieldType(org.talend.core.model.process.EParameterFieldType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IElementParameterDefaultValue(org.talend.core.model.process.IElementParameterDefaultValue) ElementParameterDefaultValue(org.talend.designer.core.model.components.ElementParameterDefaultValue)

Example 4 with EParameterFieldType

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

the class GenericTableUtils method getTableValues.

public static List<Map<String, Object>> getTableValues(Properties tableProperties, IElementParameter param) {
    List<Map<String, Object>> table = new ArrayList<Map<String, Object>>();
    if (param.getListItemsDisplayCodeName().length == 0) {
        return table;
    }
    Property property = tableProperties.getValuedProperty(param.getListItemsDisplayCodeName()[0]);
    Object value = property.getValue();
    if (value instanceof List) {
        for (int i = 0; i < ((List) value).size(); i++) {
            Map<String, Object> line = new HashMap<String, Object>();
            for (String columnName : param.getListItemsDisplayCodeName()) {
                Property columnProperty = tableProperties.getValuedProperty(columnName);
                EParameterFieldType type = getTypeFromColumnName(param, columnName);
                Object columnValue = columnProperty.getValue();
                if (columnValue instanceof List) {
                    List values = (List) columnValue;
                    if (type.equals(EParameterFieldType.CHECK)) {
                        if (values.size() > i) {
                            Object o = values.get(i);
                            if (o == null) {
                                line.put(columnName, Boolean.FALSE);
                            } else {
                                line.put(columnName, new Boolean(o.toString()));
                            }
                        } else {
                            line.put(columnName, Boolean.FALSE);
                        }
                    } else {
                        line.put(columnName, values.get(i));
                    }
                } else {
                    if (type.equals(EParameterFieldType.CHECK)) {
                        for (int j = 0; j < ((List) value).size(); j++) {
                            line.put(columnName, Boolean.FALSE);
                        }
                    }
                }
            }
            table.add(line);
        }
    }
    return table;
}
Also used : EParameterFieldType(org.talend.core.model.process.EParameterFieldType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.talend.daikon.properties.property.Property)

Example 5 with EParameterFieldType

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

the class PromptDefaultValueDialog method okPressed.

@Override
protected void okPressed() {
    for (TableEditor editor : editors) {
        Control control = editor.getEditor();
        TableItem item = editor.getItem();
        ColumnInfo row = (ColumnInfo) item.getData();
        EParameterFieldType field = row.parameter.getFieldType();
        if (field == EParameterFieldType.CHECK) {
            Button button = (Button) control;
            row.defaultValue = button.getSelection();
        } else if (field == EParameterFieldType.TEXT) {
            Text text = (Text) control;
            row.defaultValue = text.getText();
        } else if (field == EParameterFieldType.CLOSED_LIST || field == EParameterFieldType.PREV_COLUMN_LIST) {
            CCombo combo = (CCombo) control;
            int index = combo.getSelectionIndex();
            Object[] values = row.parameter.getListItemsValue();
            if (values.length > index && index != -1) {
                row.defaultValue = values[index];
            }
        }
    }
    super.okPressed();
}
Also used : Control(org.eclipse.swt.widgets.Control) EParameterFieldType(org.talend.core.model.process.EParameterFieldType) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor)

Aggregations

EParameterFieldType (org.talend.core.model.process.EParameterFieldType)6 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Property (org.talend.daikon.properties.property.Property)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Schema (org.apache.avro.Schema)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 CCombo (org.eclipse.swt.custom.CCombo)1 TableEditor (org.eclipse.swt.custom.TableEditor)1 Button (org.eclipse.swt.widgets.Button)1 Control (org.eclipse.swt.widgets.Control)1 TableItem (org.eclipse.swt.widgets.TableItem)1 Text (org.eclipse.swt.widgets.Text)1 Connector (org.talend.components.api.component.Connector)1 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)1 ComponentProperties (org.talend.components.api.properties.ComponentProperties)1 EDatabaseTypeName (org.talend.core.database.EDatabaseTypeName)1