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;
}
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();
}
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;
}
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("\""));
}
}
}
}
}
}
}
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;
}
Aggregations