use of org.talend.core.runtime.services.IGenericWizardService in project tdi-studio-se by Talend.
the class ComponentSettingsView method createDynamicComposite.
/**
* yzhang Comment method "createDynamicComposite".
*
* @param parent
* @param element
* @param category
*/
private void createDynamicComposite(final Composite parent, Element element, EComponentCategory category) {
// DynamicComposite dc = null;
getParentMap().put(ComponentSettingsView.PARENT, parent);
getCategoryMap().put(ComponentSettingsView.CATEGORY, category);
if (element instanceof Node) {
IComponent component = ((Node) element).getComponent();
IGenericWizardService wizardService = null;
boolean generic = false;
if (EComponentType.GENERIC.equals(component.getComponentType())) {
generic = true;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
}
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
if (category == EComponentCategory.BASIC) {
// getElementMap().put(ComponentSettingsView.ELEMENT, element);
createButtonListener();
boolean isCompactView = true;
if (ComponentSettingsView.TABLEVIEW.equals(getPreference().getString(TalendDesignerPrefConstants.VIEW_OPTIONS))) {
isCompactView = false;
}
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(true);
tabFactory.getTabbedPropertyComposite().setCompactView(isCompactView);
// Generic
if (generic && wizardService != null) {
Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.BASIC, true);
if (composite instanceof MultipleThreadDynamicComposite) {
dc = (MultipleThreadDynamicComposite) composite;
}
} else {
dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, isCompactView);
}
} else if (category == EComponentCategory.DYNAMICS_SETTINGS) {
dc = new AdvancedContextComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
} else if (category == EComponentCategory.SQL_PATTERN) {
dc = new SQLPatternComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
} else if (category == EComponentCategory.ADVANCED) {
dc = new MissingSettingsMultiThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
// Generic
if (generic && wizardService != null) {
Composite composite = wizardService.creatDynamicComposite(parent, element, EComponentCategory.ADVANCED, true);
if (composite instanceof MultipleThreadDynamicComposite) {
dc = (MultipleThreadDynamicComposite) composite;
}
}
} else {
dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
}
} else if (element instanceof Connection) {
dc = new MainConnectionComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element);
} else if (element instanceof Note) {
if (category == EComponentCategory.BASIC) {
if (parent.getLayout() instanceof FillLayout) {
FillLayout layout = (FillLayout) parent.getLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.spacing = 0;
}
ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
scrolled.setMinWidth(600);
scrolled.setMinHeight(400);
Composite composite = tabFactory.getWidgetFactory().createComposite(scrolled);
scrolled.setContent(composite);
composite.setLayout(new FormLayout());
FormData d = new FormData();
d.left = new FormAttachment(0, 0);
d.right = new FormAttachment(100, 0);
d.top = new FormAttachment(0, 0);
d.bottom = new FormAttachment(100, 0);
composite.setLayoutData(d);
AbstractNotePropertyComposite c1 = new BasicNotePropertyComposite(composite, (Note) element, tabFactory);
// AbstractNotePropertyComposite c2 = new TextNotePropertyComposite(composite, (Note) element,
// tabFactory);
// FormData data = new FormData();
// data.top = new FormAttachment(c1.getComposite(), 20, SWT.DOWN);
// data.left = new FormAttachment(0, 0);
// data.right = new FormAttachment(100, 0);
// c2.getComposite().setLayoutData(data);
parent.layout();
}
} else if (element instanceof SubjobContainer) {
if (category == EComponentCategory.BASIC) {
dc = new SubjobBasicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, element);
}
} else {
tabFactory.getTabbedPropertyComposite().setCompactViewVisible(false);
dc = new MultipleThreadDynamicComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, category, element, true);
}
if (parent.getChildren().length == 0) {
if (parent.getLayout() instanceof FillLayout) {
FillLayout layout = (FillLayout) parent.getLayout();
layout.type = SWT.VERTICAL;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.spacing = 0;
}
Composite composite = tabFactory.getWidgetFactory().createComposite(parent);
composite.setLayout(new FormLayout());
FormData d = new FormData();
d.left = new FormAttachment(2, 0);
d.right = new FormAttachment(100, 0);
d.top = new FormAttachment(5, 0);
d.bottom = new FormAttachment(100, 0);
composite.setLayoutData(d);
Label alertText = new Label(composite, SWT.NONE);
//$NON-NLS-1$
alertText.setText(Messages.getString("ComponentSettingsView.noAdvancedSetting"));
alertText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
parent.layout();
}
if (dc != null) {
dc.refresh();
}
}
use of org.talend.core.runtime.services.IGenericWizardService in project tdi-studio-se by Talend.
the class GenericRepositorySeeker method getGenericTypes.
private List<ERepositoryObjectType> getGenericTypes() {
List<ERepositoryObjectType> repTypes = new ArrayList<>();
IGenericWizardService wizardService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
if (wizardService != null) {
List<String> genericTypeNames = wizardService.getGenericTypeNames();
for (String genericType : genericTypeNames) {
ERepositoryObjectType repObjType = ERepositoryObjectType.valueOf(genericType);
if (repObjType != null) {
repTypes.add(repObjType);
}
}
}
return repTypes;
}
use of org.talend.core.runtime.services.IGenericWizardService in project tdi-studio-se by Talend.
the class RepositoryChangeMetadataCommand method execute.
@Override
public void execute() {
node.setPropertyValue(propName, newPropValue);
String mainSchemaParamName = DesignerUtilities.getMainSchemaParameterName(node);
if (mainSchemaParamName.equals(propName)) {
IElementParameter elementParameter = node.getElementParameter(propName);
if (elementParameter != null) {
IElementParameter schemaTypeParam = elementParameter.getParentParameter().getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
if (schemaTypeParam != null) {
if (newPropValue != null && !"".equals(newPropValue)) {
//$NON-NLS-1$
schemaTypeParam.setValue(EmfComponent.REPOSITORY);
} else {
schemaTypeParam.setValue(EmfComponent.BUILTIN);
}
}
}
}
if (node.isExternalNode() && !node.isELTComponent()) {
for (IElementParameter parameter : node.getElementParameters()) {
if (parameter.getFieldType() == EParameterFieldType.TABLE) {
if (!node.getMetadataList().isEmpty() && !node.getMetadataList().get(0).sameMetadataAs(newOutputMetadata)) {
parameter.setValue(new ArrayList<Map<String, Object>>());
}
}
}
}
// ELT Input/output component need add the schema conetxt in Context Mode
if (node.isELTComponent()) {
//$NON-NLS-1$
IElementParameter schemaParam = node.getElementParameter("ELT_SCHEMA_NAME");
if (schemaParam != null && schemaParam.getValue() != null && newPropValue != null && connection != null && connection.isContextMode() && ContextParameterUtils.isContainContextParam(schemaParam.getValue().toString())) {
ConnectionItem connectionItem = MetadataToolHelper.getConnectionItemFromRepository(newPropValue.toString());
ConnectionContextHelper.addContextForNodeParameter(node, connectionItem, false);
}
}
// IElementParameter schemaTypeParameter =
// node.getElementParameter(propName).getParentParameter().getChildParameters().get(
// EParameterName.SCHEMA_TYPE.getName());
// IElementParameter repositorySchemaTypeParameter = node.getElementParameter(propName).getParentParameter()
// .getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
// String schemaType = (String) schemaTypeParameter.getValue();
// bug 6028, Display the parameter of REPOSITORY_SCHEMA_TYPE
// if (schemaType != null && schemaType.equals(EmfComponent.REPOSITORY)) {
// repositorySchemaTypeParameter.setShow(true);
// if (newRepositoryIdValue != null) {
// oldRepositoryIdValue = (String) repositorySchemaTypeParameter.getValue();
// repositorySchemaTypeParameter.setValue(newRepositoryIdValue);
// }
// } else {
// repositorySchemaTypeParameter.setShow(false);
// }
// Xstream Cdc Type Mode
boolean isXstreamCdcTypeMode = false;
if (connection != null && connection instanceof DatabaseConnection) {
String cdcTypeMode = ((DatabaseConnection) connection).getCdcTypeMode();
if (CDCTypeMode.XSTREAM_MODE == CDCTypeMode.indexOf(cdcTypeMode)) {
isXstreamCdcTypeMode = true;
}
}
node.getElementParameter(EParameterName.UPDATE_COMPONENTS.getName()).setValue(true);
String componentName = node.getComponent().getName();
if (newOutputMetadata != null) {
Map<String, String> addMap = newOutputMetadata.getAdditionalProperties();
if (addMap.get(TaggedValueHelper.SYSTEMTABLENAME) != null && componentName.equals("tAS400CDC")) {
//$NON-NLS-1$
setDBTableFieldValue(node, addMap.get(TaggedValueHelper.SYSTEMTABLENAME), oldOutputMetadata.getTableName());
} else if (isXstreamCdcTypeMode) {
IElementParameter elementParameter = node.getElementParameter(propName);
if (elementParameter != null) {
if (oracleCdcComponent[0].equals(componentName) || oracleCdcComponent[1].equals(componentName)) {
IElementParameter schemaTypeParam = elementParameter.getParentParameter().getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaTypeParam != null) {
schemaTypeParam.setValue(EmfComponent.BUILTIN);
if (schemaParam != null && schemaParam.getValue() != null && schemaParam.getValue() instanceof IMetadataTable) {
newOutputMetadata.setListColumns((((IMetadataTable) schemaParam.getValue()).clone(true)).getListColumns());
}
if (oracleCdcComponent[1].equals(componentName)) {
newOutputMetadata.setListColumns(new ArrayList<IMetadataColumn>());
}
}
}
}
setDBTableFieldValue(node, newOutputMetadata.getTableName(), oldOutputMetadata.getTableName());
} else {
setDBTableFieldValue(node, newOutputMetadata.getTableName(), oldOutputMetadata.getTableName());
}
//$NON-NLS-1$
IElementParameter parameter = node.getElementParameter("SAP_FUNCTION");
if (parameter != null) {
setSAPFunctionName(node, parameter.getValue() == null ? null : (String) parameter.getValue());
}
if (newPropValue instanceof String) {
if (orginalTable != null && orginalTable instanceof SAPBWTable) {
String innerIOType = ((SAPBWTable) orginalTable).getInnerIOType();
String sourceSysName = ((SAPBWTable) orginalTable).getSourceSystemName();
IElementParameter schemaTypeParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
IMetadataTable metadataTable = null;
if (schemaTypeParam != null) {
metadataTable = node.getMetadataFromConnector(schemaTypeParam.getContext());
}
if (metadataTable != null) {
if (innerIOType != null) {
//$NON-NLS-1$
IElementParameter param = node.getElementParameter("INFO_OBJECT_TYPE");
if (param != null) {
param.setValue(innerIOType);
metadataTable.getAdditionalProperties().put(SAPBWTableHelper.SAP_INFOOBJECT_INNER_TYPE, innerIOType);
}
}
if (sourceSysName != null) {
//$NON-NLS-1$
IElementParameter param = node.getElementParameter("SOURCE_SYSTEM_NAME");
if (param != null) {
param.setValue(TalendTextUtils.addQuotes(sourceSysName));
metadataTable.getAdditionalProperties().put(SAPBWTableHelper.SAP_DATASOURCE_SOURCESYSNAME, sourceSysName);
}
}
}
}
}
setTableRelevantParameterValues();
if (getConnection() != null) {
// for salesforce
IElementParameter param = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (param != null && EmfComponent.REPOSITORY.equals(param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getValue())) {
IElementParameter module = node.getElementParameter("module.moduleName");
if (module != null) {
String repositoryValue = module.getRepositoryValue();
if (repositoryValue == null) {
List<ComponentProperties> componentProperties = null;
IGenericWizardService wizardService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
if (wizardService != null && wizardService.isGenericConnection(getConnection())) {
componentProperties = wizardService.getAllComponentProperties(getConnection(), null);
}
repositoryValue = String.valueOf(RepositoryToComponentProperty.getGenericRepositoryValue(getConnection(), componentProperties, module.getName()));
}
if (repositoryValue != null) {
Object objectValue = RepositoryToComponentProperty.getValue(getConnection(), repositoryValue, newOutputMetadata, node.getComponent().getName());
if (objectValue != null) {
module.setValue(objectValue);
}
}
}
}
}
}
super.setConnection(connection);
super.execute();
String propertyType = (String) node.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
if (propertyType != null) {
if (propertyType.equals(EmfComponent.REPOSITORY)) {
String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
if (lastVersion == null) {
return;
}
Item item = lastVersion.getProperty().getItem();
if (item instanceof ConnectionItem) {
List<? extends IElementParameter> elementParameters = new ArrayList(node.getElementParameters());
for (IElementParameter param : elementParameters) {
if (param.getRepositoryValue() != null && !param.getRepositoryValue().equals("")) {
//$NON-NLS-1$
boolean isCustomSfConn = false;
if (item instanceof SalesforceSchemaConnectionItem) {
SalesforceSchemaConnection sfConn = (SalesforceSchemaConnection) ((SalesforceSchemaConnectionItem) item).getConnection();
isCustomSfConn = sfConn.isUseCustomModuleName();
}
if (//$NON-NLS-1$
param.getRepositoryValue().equals("TYPE") || (param.getRepositoryValue().equals("MODULENAME") && item instanceof SalesforceSchemaConnectionItem && !isCustomSfConn)) {
//$NON-NLS-1$
continue;
}
if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("XML_MAPPING")) {
//$NON-NLS-1$
List<Map<String, Object>> table = (List<Map<String, Object>>) node.getPropertyValue(param.getName());
IMetadataTable metaTable = node.getMetadataList().get(0);
RepositoryToComponentProperty.getTableXmlFileValue(((ConnectionItem) item).getConnection(), //$NON-NLS-1$
"XML_MAPPING", //$NON-NLS-1$
param, table, newOutputMetadata);
param.setRepositoryValueUsed(true);
} else {
if (connection != null && (xmlComponent[0].equals(componentName) || xmlComponent[1].equals(componentName) || xmlComponent[2].equals(componentName)) && connection instanceof XmlFileConnection && XmlUtil.isXSDFile(TalendQuoteUtils.removeQuotes(((XmlFileConnection) connection).getXmlFilePath())) && param.getRepositoryValue().equals("FILE_PATH")) {
// do nothing
} else {
Object value = RepositoryToComponentProperty.getValue(((ConnectionItem) item).getConnection(), param.getRepositoryValue(), newOutputMetadata);
if (value != null) {
param.setValue(value);
}
}
}
}
}
}
}
}
node.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
}
Aggregations