Search in sources :

Example 1 with ComponentProperties

use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.

the class GenericConnWizard method addPages.

@Override
public void addPages() {
    ERepositoryObjectType repObjType = (ERepositoryObjectType) repNode.getProperties(EProperties.CONTENT_TYPE);
    String typeName = repObjType.getType();
    setWindowTitle(typeName);
    Image wiardImage = wizardService.getWiardImage(typeName);
    setDefaultPageImageDescriptor(ImageDescriptor.createFromImage(wiardImage));
    ((GenericConnectionItem) connectionItem).setTypeName(typeName);
    IGenericWizardInternalService internalService = new GenericWizardInternalService();
    ComponentWizard componentWizard = null;
    if (creation) {
        componentWizard = internalService.getComponentWizard(typeName, connectionProperty.getId());
    } else {
        String compPropertiesStr = connection.getCompProperties();
        if (compPropertiesStr != null) {
            ComponentProperties properties = ComponentsUtils.getComponentPropertiesFromSerialized(compPropertiesStr, connection, false);
            if (properties != null) {
                componentWizard = internalService.getTopLevelComponentWizard(properties, repNode.getId());
            }
        }
    }
    if (componentWizard == null) {
        return;
    }
    List<Form> forms = componentWizard.getForms();
    for (int i = 0; i < forms.size(); i++) {
        Form form = forms.get(i);
        boolean addContextSupport = false;
        if (i == 0) {
            // Add context support in the first form.
            addContextSupport = true;
        }
        wizPage = new GenericConnWizardPage(connectionItem, isRepositoryObjectEditable(), existingNames, creation, form, compService, addContextSupport);
        if (wizPage != null) {
            wizPage.setTitle(form.getTitle());
            wizPage.setDescription(form.getSubtitle());
            if (creation) {
                wizPage.setPageComplete(false);
            } else {
                wizPage.setPageComplete(isRepositoryObjectEditable());
            }
        }
        addPage(wizPage);
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) GenericWizardInternalService(org.talend.repository.generic.internal.service.GenericWizardInternalService) IGenericWizardInternalService(org.talend.repository.generic.internal.IGenericWizardInternalService) Image(org.eclipse.swt.graphics.Image) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) IGenericWizardInternalService(org.talend.repository.generic.internal.IGenericWizardInternalService) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem)

Example 2 with ComponentProperties

use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.

the class GenericContextUtil method setPropertiesForContextMode.

public static void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
    if (connection == null) {
        return;
    }
    if (connection instanceof GenericConnection) {
        GenericConnection genericConn = (GenericConnection) connection;
        ComponentProperties componentProperties = getComponentProperties(genericConn);
        String originalVariableName = prefixName + ConnectionContextHelper.LINE;
        String genericVariableName = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof GenericConnParamName) {
                GenericConnParamName genericParam = (GenericConnParamName) param;
                String paramVarName = genericParam.getContextVar();
                genericVariableName = originalVariableName + paramVarName;
                matchContextForAttribues(componentProperties, genericParam, genericVariableName);
            }
        }
        updateComponentProperties(genericConn, componentProperties);
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnParamName(org.talend.metadata.managment.ui.utils.GenericConnParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection)

Example 3 with ComponentProperties

use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.

the class Component method getElementParameterValueFromComponentProperties.

@Override
public Object getElementParameterValueFromComponentProperties(INode iNode, IElementParameter param) {
    if (iNode != null) {
        ComponentProperties iNodeComponentProperties = iNode.getComponentProperties();
        if (iNodeComponentProperties != null && param instanceof GenericElementParameter) {
            Properties paramProperties = ComponentsUtils.getCurrentProperties(iNodeComponentProperties, param.getName());
            if (paramProperties != null) {
                // update repository value
                Property property = iNodeComponentProperties.getValuedProperty(param.getName());
                if (property != null) {
                    if (property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
                        param.setRepositoryValue(param.getName());
                        param.setRepositoryValueUsed(true);
                    }
                }
                Object value = ComponentsUtils.getGenericPropertyValue(iNodeComponentProperties, param.getName());
                if (value == null && EParameterFieldType.TABLE.equals(param.getFieldType())) {
                    value = GenericTableUtils.getTableValues(iNodeComponentProperties.getProperties(param.getName()), param);
                }
                return value;
            }
        }
    }
    return null;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Properties(org.talend.daikon.properties.Properties) Property(org.talend.daikon.properties.property.Property) SchemaProperty(org.talend.daikon.properties.property.SchemaProperty)

Example 4 with ComponentProperties

use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.

the class Component method addPropertyParameters.

private void addPropertyParameters(final List<ElementParameter> listParam, final INode node, String formName, EComponentCategory category) {
    ComponentProperties props = node.getComponentProperties();
    Form form = props.getForm(formName);
    List<ElementParameter> parameters = ComponentsUtils.getParametersFromForm(node, this.isInitializing(), category, props, form);
    props.setValueEvaluator(new ComponentContextPropertyValueEvaluator(node));
    ComponentService componentService = ComponentsUtils.getComponentService();
    for (ElementParameter parameter : parameters) {
        if (parameter instanceof GenericElementParameter) {
            GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
            genericElementParameter.setComponentService(componentService);
        }
    }
    listParam.addAll(parameters);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) ComponentContextPropertyValueEvaluator(org.talend.designer.core.generic.context.ComponentContextPropertyValueEvaluator) ComponentService(org.talend.components.api.service.ComponentService)

Example 5 with ComponentProperties

use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.

the class Component method setGenericPropertyValue.

@Override
public boolean setGenericPropertyValue(IElementParameter param) {
    if (param == null || param.getName() == null) {
        return false;
    }
    if (param instanceof GenericElementParameter) {
        ComponentProperties componentProperties = ((Node) ((GenericElementParameter) param).getElement()).getComponentProperties();
        Properties currentProperties = ComponentsUtils.getCurrentProperties(componentProperties, param.getName());
        if (currentProperties == null) {
            return false;
        }
        Property<?> property = componentProperties.getValuedProperty(param.getName());
        if (property != null) {
            property.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, param.getName());
            return true;
        }
    }
    return false;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Properties(org.talend.daikon.properties.Properties)

Aggregations

ComponentProperties (org.talend.components.api.properties.ComponentProperties)76 Test (org.junit.Test)22 Form (org.talend.daikon.properties.presentation.Form)17 Property (org.talend.daikon.properties.property.Property)17 ArrayList (java.util.ArrayList)16 NamedThing (org.talend.daikon.NamedThing)13 GenericConnection (org.talend.repository.generic.model.genericMetadata.GenericConnection)13 Properties (org.talend.daikon.properties.Properties)10 List (java.util.List)9 IElementParameter (org.talend.core.model.process.IElementParameter)9 INode (org.talend.core.model.process.INode)9 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)8 Schema (org.apache.avro.Schema)7 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)7 ComponentService (org.talend.components.api.service.ComponentService)7 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)7 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)7 ConnectionItem (org.talend.core.model.properties.ConnectionItem)7 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)7 ElementParameter (org.talend.designer.core.model.components.ElementParameter)7