Search in sources :

Example 1 with GenericElementParameter

use of org.talend.designer.core.generic.model.GenericElementParameter in project tdi-studio-se by Talend.

the class GenericWizardPage method getContextParameters.

public List<IElementParameter> getContextParameters() {
    List<IElementParameter> contextParameters = new ArrayList<>();
    for (IElementParameter parameter : baseElement.getElementParameters()) {
        if (parameter instanceof GenericElementParameter) {
            GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
            if (genericElementParameter.isSupportContext()) {
                contextParameters.add(parameter);
            }
            List<ElementParameter> relatedParameters = ComponentsUtils.getRelatedParameters(genericElementParameter);
            for (ElementParameter relatedParameter : relatedParameters) {
                if (relatedParameter instanceof GenericElementParameter && ((GenericElementParameter) relatedParameter).isSupportContext()) {
                    contextParameters.add(relatedParameter);
                }
            }
        }
    }
    return contextParameters;
}
Also used : GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ArrayList(java.util.ArrayList) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 2 with GenericElementParameter

use of org.talend.designer.core.generic.model.GenericElementParameter in project tdi-studio-se by Talend.

the class DynamicComposite method dispose.

@Override
public synchronized void dispose() {
    List<? extends IElementParameter> elementParameters = element.getElementParameters();
    for (IElementParameter elementParameter : elementParameters) {
        if (elementParameter instanceof GenericElementParameter) {
            ((GenericElementParameter) elementParameter).removePropertyChangeListener(this);
        }
    }
    super.dispose();
}
Also used : GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 3 with GenericElementParameter

use of org.talend.designer.core.generic.model.GenericElementParameter in project tdi-studio-se by Talend.

the class DynamicComposite method isShouldDisParameter.

@Override
protected boolean isShouldDisParameter(IElementParameter curParam) {
    if (EParameterFieldType.PROPERTY_TYPE.equals(curParam.getFieldType())) {
        IElementParameter compRefParameter = elem.getElementParameterFromField(EParameterFieldType.COMPONENT_REFERENCE);
        if (compRefParameter != null) {
            GenericElementParameter gParam = (GenericElementParameter) compRefParameter;
            ComponentReferenceProperties props = (ComponentReferenceProperties) gParam.getWidget().getContent();
            return props.getReference() == null;
        }
    }
    return true;
}
Also used : GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties)

Example 4 with GenericElementParameter

use of org.talend.designer.core.generic.model.GenericElementParameter in project tdi-studio-se by Talend.

the class ComponentsUtilsTest method checkParameterInitializationStatus.

private void checkParameterInitializationStatus(List<ElementParameter> parameters, boolean isInitializing) {
    for (ElementParameter parameter : parameters) {
        if (parameter instanceof GenericElementParameter) {
            GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
            Property property = genericElementParameter.getProperty();
            if (property != null) {
                if (GenericTypeUtils.isStringType(property)) {
                    String propertyValue = (String) property.getValue();
                    String parameterValue = (String) parameter.getValue();
                    // If value is empty (from default value or input) add double quotes.
                    if (StringUtils.isEmpty(propertyValue)) {
                        //$NON-NLS-1$
                        assertTrue("\"\"".equals(parameterValue));
                    } else {
                        // Else value is not empty.
                        if (isInitializing) {
                            // If isInitializing is true value will be surrounded with quotes if not exist.
                            //$NON-NLS-1$ //$NON-NLS-2$
                            assertTrue(parameterValue.startsWith("\"") && parameterValue.endsWith("\""));
                        } else if (!propertyValue.startsWith("\"") || !propertyValue.endsWith("\"")) {
                            //$NON-NLS-1$ //$NON-NLS-2$
                            // Else shouldn't add quotes to the value.
                            //$NON-NLS-1$ //$NON-NLS-2$
                            assertFalse(parameterValue.startsWith("\"") && parameterValue.endsWith("\""));
                        }
                    }
                }
            }
        }
    }
}
Also used : GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) StringProperty(org.talend.daikon.properties.property.StringProperty) Property(org.talend.daikon.properties.property.Property)

Example 5 with GenericElementParameter

use of org.talend.designer.core.generic.model.GenericElementParameter in project tdi-studio-se by Talend.

the class NameAndLabelsTreeController method createControl.

@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    Composite parentComp = new Composite(subComposite, SWT.NONE);
    parentComp.setLayoutData(data);
    parentComp.setLayout(new GridLayout());
    ElementsSelectionComposite<NamedThing> selectionComposite = new ElementsSelectionComposite<NamedThing>(parentComp) {

        @Override
        protected IBaseLabelProvider getLabelProvider() {
            return new LabelProvider() {

                @Override
                public String getText(Object obj) {
                    NamedThing nal = (NamedThing) obj;
                    return nal.getDisplayName();
                }

                @Override
                public Image getImage(Object obj) {
                    return null;
                }
            };
        }

        ;

        @Override
        protected void doSelectionChanged() {
            param.setValue(getSelectedElements());
        }

        @Override
        protected List<String> getSelectedElementLabels() {
            List<String> labels = new ArrayList<>();
            Object value = param.getValue();
            if (value instanceof List) {
                List<?> values = (List<?>) value;
                for (Object valueObj : values) {
                    if (valueObj instanceof NamedThing) {
                        labels.add(((NamedThing) valueObj).getName());
                    }
                }
                return labels;
            }
            return null;
        }

        @Override
        protected List<NamedThing> getInitSelectedElements(List<String> selectedElementLabels) {
            List<NamedThing> selectedElements = new ArrayList<>();
            List<NamedThing> viewerDatas = getViewerData();
            for (NamedThing viewerData : viewerDatas) {
                if (selectedElementLabels.contains(viewerData.getName())) {
                    selectedElements.add(viewerData);
                }
            }
            return selectedElements;
        }
    }.setShowToolbar(true).create();
    selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (param instanceof GenericElementParameter) {
        selectionComposite.setViewerData(ComponentsUtils.getFormalPossibleValues((GenericElementParameter) param));
    }
    selectionComposite.setCheckedState();
    return parentComp;
}
Also used : FormData(org.eclipse.swt.layout.FormData) ElementsSelectionComposite(org.talend.core.ui.composite.ElementsSelectionComposite) ElementsSelectionComposite(org.talend.core.ui.composite.ElementsSelectionComposite) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)21 ArrayList (java.util.ArrayList)11 IElementParameter (org.talend.core.model.process.IElementParameter)9 INode (org.talend.core.model.process.INode)8 List (java.util.List)6 ComponentProperties (org.talend.components.api.properties.ComponentProperties)6 ElementParameter (org.talend.designer.core.model.components.ElementParameter)6 ComponentReferenceProperties (org.talend.components.api.properties.ComponentReferenceProperties)5 NamedThing (org.talend.daikon.NamedThing)5 Form (org.talend.daikon.properties.presentation.Form)4 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 Schema (org.apache.avro.Schema)3 CCombo (org.eclipse.swt.custom.CCombo)3 Point (org.eclipse.swt.graphics.Point)3 INodeConnector (org.talend.core.model.process.INodeConnector)3 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)3 Widget (org.talend.daikon.properties.presentation.Widget)3 Property (org.talend.daikon.properties.property.Property)3 FakeElement (org.talend.designer.core.model.FakeElement)3