use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method isValid.
private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
// TUP-4151
IRepositoryViewObject object = seletetedNode.getObject();
if (component == null || object == null) {
return false;
}
ComponentProperties currentComponentProperties = null;
if (object instanceof RepositoryViewObject) {
RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
if (canHandle(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
}
} else if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
} else if (object instanceof MetadataColumnRepositoryObject) {
MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
ModelElement element = metaColumnRepObj.getTdColumn();
if (element != null && element.eContainer() instanceof MetadataTable) {
MetadataTable metadataTable = (MetadataTable) element.eContainer();
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
}
}
if (currentComponentProperties != null) {
try {
List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
if (component instanceof Component) {
ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
return possibleComponents.contains(componentDefinition);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
return false;
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method getComponentMainName.
private String getComponentMainName(GenericConnection connection) {
IGenericWizardInternalService internalService = new GenericWizardInternalService();
ComponentWizard componentWizard = null;
String compPropertiesStr = connection.getCompProperties();
if (compPropertiesStr != null) {
ComponentProperties properties = ComponentsUtils.getComponentPropertiesFromSerialized(compPropertiesStr, connection);
if (properties != null) {
componentWizard = internalService.getTopLevelComponentWizard(properties, null);
}
}
if (componentWizard != null) {
return StringUtils.capitalize(componentWizard.getDefinition().getName());
}
return null;
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericWizardService method creatDynamicComposite.
@Override
public Composite creatDynamicComposite(Composite composite, Element element, EComponentCategory sectionCategory, boolean isCompactView) {
DynamicComposite dynamicComposite = null;
if (element != null && element instanceof INode) {
INode node = (INode) element;
ComponentProperties props = null;
if (node.getComponentProperties() == null) {
props = ComponentsUtils.getComponentProperties(node.getComponent().getName());
} else {
props = node.getComponentProperties();
}
if (props != null) {
Form form = props.getForm(EComponentCategory.ADVANCED.equals(sectionCategory) ? Form.ADVANCED : Form.MAIN);
dynamicComposite = new DynamicComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, sectionCategory, element, isCompactView, composite.getBackground(), form);
List<ElementParameter> elementParameters = (List<ElementParameter>) node.getElementParameters();
for (ElementParameter parameter : elementParameters) {
if (parameter instanceof GenericElementParameter) {
GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
genericElementParameter.callBeforePresent();
genericElementParameter.removePropertyChangeListener(dynamicComposite);
genericElementParameter.addPropertyChangeListener(dynamicComposite);
}
}
}
}
return dynamicComposite;
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericWizardService method getAllComponentProperties.
@Override
public List<ComponentProperties> getAllComponentProperties(Connection connection, String tableLabel) {
List<ComponentProperties> componentProperties = new ArrayList<>();
if (isGenericConnection(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
String compProperties = genericConnection.getCompProperties();
ComponentProperties cp = ComponentsUtils.getComponentPropertiesFromSerialized(compProperties, connection, false);
if (cp != null) {
componentProperties.add(cp);
}
List<MetadataTable> metadataTables;
if (tableLabel == null) {
metadataTables = SchemaUtils.getMetadataTables(genericConnection, SubContainer.class);
} else {
metadataTables = Arrays.asList(SchemaUtils.getMetadataTable(genericConnection, tableLabel, SubContainer.class));
}
for (MetadataTable metadataTable : metadataTables) {
if (metadataTable == null) {
continue;
}
for (TaggedValue taggedValue : metadataTable.getTaggedValue()) {
if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(taggedValue.getTag())) {
ComponentProperties compPros = ComponentsUtils.getComponentPropertiesFromSerialized(taggedValue.getValue(), connection, false);
if (compPros != null && !componentProperties.contains(compPros)) {
compPros.updateNestedProperties(cp);
componentProperties.add(compPros);
}
}
}
}
}
return componentProperties;
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class DynamicComposite method resetParameters.
public List<ElementParameter> resetParameters() {
final List<ElementParameter> newParameters = new ArrayList<>();
List<ElementParameter> currentParameters = (List<ElementParameter>) element.getElementParameters();
List<ElementParameter> parameters = new ArrayList<>();
ComponentService componentService = internalService.getComponentService();
Connection theConnection = null;
if (connectionItem != null) {
theConnection = connectionItem.getConnection();
}
Properties properties = null;
PropertyValueEvaluator evaluator = null;
if (element instanceof FakeElement) {
properties = form.getProperties();
evaluator = new MetadataContextPropertyValueEvaluator(theConnection);
currentParameters.clear();
} else {
properties = ((INode) element).getComponentProperties();
evaluator = new ComponentContextPropertyValueEvaluator((INode) element);
}
if (properties instanceof ComponentProperties) {
if (form != null) {
properties.setValueEvaluator(evaluator);
properties.refreshLayout(form);
}
// For context display.
properties.setValueEvaluator(null);
boolean isInitializing = false;
if (element instanceof INode) {
INode node = (INode) element;
IComponent component = node.getComponent();
if (component instanceof AbstractBasicComponent) {
isInitializing = ((AbstractBasicComponent) component).isInitializing();
}
}
parameters = ComponentsUtils.getParametersFromForm(element, isInitializing, section, (ComponentProperties) properties, form);
addUpdateParameterIfNotExist(parameters);
properties.setValueEvaluator(evaluator);
}
for (ElementParameter parameter : parameters) {
if (parameter instanceof GenericElementParameter) {
GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
genericElementParameter.setComponentService(componentService);
genericElementParameter.setDrivedByForm(drivedByForm);
genericElementParameter.callBeforePresent();
genericElementParameter.removePropertyChangeListener(this);
genericElementParameter.addPropertyChangeListener(this);
if (wizardPropertyChangeListener != null && IGenericConstants.NAME_PROPERTY.equals(parameter.getName())) {
genericElementParameter.addPropertyChangeListener(wizardPropertyChangeListener);
}
if (EParameterFieldType.SCHEMA_REFERENCE.equals(genericElementParameter.getFieldType())) {
if (genericElementParameter.getChildParameters().size() == 0) {
IElementParameter schemaParameter = element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE, section);
genericElementParameter.getChildParameters().putAll(schemaParameter.getChildParameters());
}
} else if (EParameterFieldType.NAME_SELECTION_AREA.equals(genericElementParameter.getFieldType()) && theConnection != null) {
List<NamedThing> values = new ArrayList<>();
List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(theConnection, SubContainer.class);
List<String> tableLabels = new ArrayList<>();
for (MetadataTable metaTable : metadataTables) {
tableLabels.add(metaTable.getLabel());
}
List<NamedThing> possibleValues = ComponentsUtils.getFormalPossibleValues(genericElementParameter);
for (NamedThing possibleValue : possibleValues) {
if (tableLabels.contains(possibleValue.getName())) {
values.add(possibleValue);
}
}
genericElementParameter.setValue(values);
}
if (properties != null && isRepository(element)) {
String repositoryValue = genericElementParameter.getRepositoryValue();
if (genericElementParameter.isShow(currentParameters) && (repositoryValue != null) && (!genericElementParameter.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && genericElementParameter.getCategory() == section) {
org.talend.daikon.properties.property.Property property = properties.getValuedProperty(genericElementParameter.getName());
if (property != null && property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
genericElementParameter.setRepositoryValueUsed(true);
genericElementParameter.setReadOnly(true);
}
}
}
}
}
boolean added = false;
for (ElementParameter currentParameter : currentParameters) {
if (EParameterName.UPDATE_COMPONENTS.getName().equals(currentParameter.getName())) {
currentParameter.setValue(true);
}
if (currentParameter.isSerialized() && currentParameter.getCategory().equals(section)) {
if (!added) {
newParameters.addAll(parameters);
added = true;
}
continue;
}
newParameters.add(currentParameter);
}
if (element instanceof FakeElement) {
newParameters.addAll(reverseParameters(parameters));
}
element.setElementParameters(newParameters);
return newParameters;
}
Aggregations