Search in sources :

Example 6 with IGenericWizardService

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();
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) Composite(org.eclipse.swt.widgets.Composite) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) AbstractNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.AbstractNotePropertyComposite) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) Label(org.eclipse.swt.widgets.Label) MissingSettingsMultiThreadDynamicComposite(org.talend.designer.core.ui.views.properties.composites.MissingSettingsMultiThreadDynamicComposite) FillLayout(org.eclipse.swt.layout.FillLayout) SubjobBasicComposite(org.talend.designer.core.ui.views.subjob.SubjobBasicComposite) BasicNotePropertyComposite(org.talend.designer.core.ui.editor.properties.notes.BasicNotePropertyComposite) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MainConnectionComposite(org.talend.designer.core.ui.editor.properties.connections.MainConnectionComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 7 with IGenericWizardService

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;
}
Also used : ArrayList(java.util.ArrayList) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 8 with IGenericWizardService

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);
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SalesforceSchemaConnectionItem(org.talend.core.model.properties.SalesforceSchemaConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) ArrayList(java.util.ArrayList) SalesforceSchemaConnectionItem(org.talend.core.model.properties.SalesforceSchemaConnectionItem) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SalesforceSchemaConnectionItem(org.talend.core.model.properties.SalesforceSchemaConnectionItem) Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IElementParameter(org.talend.core.model.process.IElementParameter) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) List(java.util.List) SAPBWTable(org.talend.core.model.metadata.builder.connection.SAPBWTable) Map(java.util.Map)

Aggregations

IGenericWizardService (org.talend.core.runtime.services.IGenericWizardService)8 ArrayList (java.util.ArrayList)6 List (java.util.List)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 INode (org.talend.core.model.process.INode)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 Map (java.util.Map)3 ComponentProperties (org.talend.components.api.properties.ComponentProperties)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)3 IConnection (org.talend.core.model.process.IConnection)3 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 HashMap (java.util.HashMap)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 SalesforceSchemaConnection (org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection)2 INodeConnector (org.talend.core.model.process.INodeConnector)2 SAPConnectionItem (org.talend.core.model.properties.SAPConnectionItem)2