Search in sources :

Example 86 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractElementPropertySectionController method openSQLBuilder.

/**
     * DOC qzhang Comment method "openSQLBuilder".
     *
     * @param repositoryType
     * @param propertyName
     * @param query
     */
protected String openSQLBuilder(String repositoryType, String propertyName, String query) {
    if (repositoryType.equals(EmfComponent.BUILTIN)) {
        connParameters.setQuery(query);
        if (connParameters.isShowConfigParamDialog()) {
            if (!isUseExistingConnection()) {
                initConnectionParametersWithContext(elem, part.getProcess().getContextManager().getDefaultContext());
            } else {
                initConnectionParametersWithContext(connectionNode, part.getProcess().getContextManager().getDefaultContext());
            }
        }
        // add for bug TDI-20335
        if (part == null) {
            Shell parentShell = new Shell(composite.getShell().getDisplay());
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, "", connParameters);
            sqlBuilder.open();
        } else {
            openSqlBuilderBuildIn(connParameters, propertyName);
        }
    } else if (repositoryType.equals(EmfComponent.REPOSITORY)) {
        //$NON-NLS-1$
        String repositoryName2 = "";
        String repositoryId = null;
        IElementParameter memoParam = elem.getElementParameter(propertyName);
        IElementParameter repositoryParam = null;
        for (IElementParameter param : elem.getElementParameters()) {
            if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getRepositoryValue().startsWith("DATABASE")) {
                repositoryParam = param;
                break;
            }
        }
        // in case no database property found, take the first property (to keep compatibility with old code)
        if (repositoryParam == null) {
            for (IElementParameter param : elem.getElementParameters()) {
                if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
                    repositoryParam = param;
                    break;
                }
            }
        }
        if (repositoryParam != null) {
            IElementParameter itemFromRepository = repositoryParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            String value = (String) itemFromRepository.getValue();
            repositoryId = value;
            // for (String key : this.dynamicProperty.getRepositoryConnectionItemMap().keySet()) {
            // if (key.equals(value)) {
            // repositoryName2 =
            // this.dynamicProperty.getRepositoryConnectionItemMap().get(key).getProperty().getLabel();
            // }
            // }
            /* get connection item dynamictly,not from cache ,see 16969 */
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(value);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        repositoryName2 = property.getLabel();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
        // When no repository avaiable on "Repository" mode, open a MessageDialog.
        if (repositoryName2 == null || repositoryName2.length() == 0) {
            MessageDialog.openError(composite.getShell(), Messages.getString("NoRepositoryDialog.Title"), //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "NoRepositoryDialog.Text"));
            return null;
        }
        // Part maybe not exist
        //$NON-NLS-1$
        String processName = "";
        //$NON-NLS-1$
        String key = "";
        if (elem instanceof Node) {
            processName = ((Node) elem).getProcess().getName();
            key = processName + ((Node) elem).getUniqueName();
        } else if (elem instanceof IProcess) {
            processName = ((IProcess) elem).getName();
            key = processName;
        }
        key += repositoryName2;
        final Dialog builderDialog = sqlbuilers.get(key);
        if (!composite.isDisposed() && builderDialog != null && builderDialog.getShell() != null && !builderDialog.getShell().isDisposed()) {
            builderDialog.getShell().setActive();
        } else {
            connParameters.setRepositoryName(repositoryName2);
            if (repositoryId != null) {
                connParameters.setRepositoryId(repositoryId);
            }
            Shell parentShell = new Shell(composite.getShell().getDisplay());
            String nodeLabel = null;
            if (elem instanceof Node) {
                nodeLabel = (String) ((Node) elem).getElementParameter(EParameterName.LABEL.getName()).getValue();
            }
            TextUtil.setDialogTitle(processName, nodeLabel, elem.getElementName());
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            connParameters.setQuery(query);
            // first open Sql Builder,set true
            connParameters.setFirstOpenSqlBuilder(true);
            Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, processName, connParameters);
            sqlbuilers.put(key, sqlBuilder);
            if (Window.OK == sqlBuilder.open()) {
                if (!composite.isDisposed() && !connParameters.isNodeReadOnly()) {
                    String sql = connParameters.getQuery();
                    // modified by hyWang
                    if (!connParameters.getIfContextButtonCheckedFromBuiltIn()) {
                        sql = QueryUtil.checkAndAddQuotes(sql);
                    }
                    return sql;
                }
            }
        }
    }
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Dialog(org.eclipse.jface.dialogs.Dialog) ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProcess(org.talend.core.model.process.IProcess) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 87 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractElementPropertySectionController method initConnectionParameters.

protected void initConnectionParameters() {
    connParameters = null;
    IElementParameter basePropertyParameter = null;
    for (IElementParameter param : elem.getElementParameters()) {
        if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
            if (param.getRepositoryValue().startsWith("DATABASE")) {
                basePropertyParameter = param;
                break;
            }
        }
    }
    // jobsetting view load the db info from current selected category
    IElementParameter updateBasePropertyParameter = updateBasePropertyParameter();
    if (updateBasePropertyParameter != null && !updateBasePropertyParameter.equals(basePropertyParameter)) {
        basePropertyParameter = updateBasePropertyParameter;
    }
    connParameters = new ConnectionParameters();
    //$NON-NLS-1$
    String type = getValueFromRepositoryName(elem, "TYPE", basePropertyParameter);
    if (type.equals("Oracle") || type.contains("OCLE")) {
        IElementParameter ele = elem.getElementParameter("CONNECTION_TYPE");
        if (ele != null) {
            type = (String) ele.getValue();
        } else {
            //$NON-NLS-1$
            type = "ORACLE_SID";
        }
    } else if (EDatabaseTypeName.HIVE.getProduct().equalsIgnoreCase(type)) {
        // if (EDatabaseVersion4Drivers.HIVE_EMBEDDED.getVersionValue().equals(
        // elem.getElementParameter("CONNECTION_MODE").getValue())) {
        setHiveRelatedParams(elem);
    // }
    } else if (EDatabaseTypeName.IMPALA.getProduct().equalsIgnoreCase(type)) {
        String distroKey = getValueFromRepositoryName(elem, "DISTRIBUTION");
        connParameters.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_IMPALA_DISTRIBUTION, distroKey);
        String distroVersion = getValueFromRepositoryName(elem, "IMPALA_VERSION");
        connParameters.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_IMPALA_VERSION, distroVersion);
    }
    // Get real hsqldb type
    if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(elem, "RUNNING_MODE").equals("HSQLDB_INPROGRESS_PERSISTENT")) {
        //$NON-NLS-1$
        type = EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
    }
    connParameters.setDbType(type);
    //$NON-NLS-1$
    String driverName = getValueFromRepositoryName(elem, "DB_VERSION", basePropertyParameter);
    String dbVersionName = EDatabaseVersion4Drivers.getDbVersionName(type, driverName);
    if (EDatabaseTypeName.HIVE.getProduct().equalsIgnoreCase(type)) {
        if (EDatabaseVersion4Drivers.HIVE_EMBEDDED.getVersionValue().equals(elem.getElementParameter("CONNECTION_MODE").getValue())) {
            connParameters.setDbVersion(EDatabaseVersion4Drivers.HIVE_EMBEDDED.getVersionValue());
        } else {
            connParameters.setDbVersion(EDatabaseVersion4Drivers.HIVE.getVersionValue());
        }
    } else {
        connParameters.setDbVersion(dbVersionName);
    }
    connParameters.setNode(elem);
    String selectedComponentName = (String) elem.getPropertyValue(EParameterName.UNIQUE_NAME.getName());
    connParameters.setSelectedComponentName(selectedComponentName);
    connParameters.setFieldType(paramFieldType);
    if (elem instanceof Node && !((Node) elem).getMetadataList().isEmpty()) {
        connParameters.setMetadataTable(((Node) elem).getMetadataList().get(0));
    }
    connParameters.setSchemaRepository(EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName())));
    connParameters.setFromDBNode(true);
    //$NON-NLS-1$
    connParameters.setQuery("");
    List<? extends IElementParameter> list = elem.getElementParameters();
    boolean end = false;
    for (int i = 0; i < list.size() && !end; i++) {
        IElementParameter param = list.get(i);
        if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
            connParameters.setNodeReadOnly(param.isReadOnly());
            end = true;
        }
    }
    //$NON-NLS-1$
    Object value = elem.getPropertyValue("USE_EXISTING_CONNECTION");
    IElementParameter compList = elem.getElementParameterFromField(EParameterFieldType.COMPONENT_LIST);
    if (value != null && (value instanceof Boolean) && ((Boolean) value) && compList != null) {
        Object compValue = compList.getValue();
        if (compValue != null && !compValue.equals("")) {
            //$NON-NLS-1$
            List<? extends INode> nodes = part.getProcess().getGraphicalNodes();
            for (INode node : nodes) {
                if (node.getUniqueName().equals(compValue) && (node instanceof Node)) {
                    connectionNode = node;
                    break;
                }
            }
            if (connectionNode == null) {
                nodes = part.getProcess().getGeneratingNodes();
                for (INode node : nodes) {
                    if (node.getUniqueName().equals(compValue) && (node instanceof INode)) {
                        connectionNode = node;
                        break;
                    }
                }
            }
            if (connectionNode != null) {
                setAllConnectionParameters(type, connectionNode);
            }
        }
    } else {
        setAllConnectionParameters(null, elem);
    }
    if (connectionNode != null) {
        setConnectionParameterNames(connectionNode, connParameters, basePropertyParameter);
    } else {
        setConnectionParameterNames(elem, connParameters, basePropertyParameter);
    }
}
Also used : INode(org.talend.core.model.process.INode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Node(org.talend.designer.core.ui.editor.nodes.Node) ConnectionParameters(org.talend.core.sqlbuilder.util.ConnectionParameters) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 88 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractElementPropertySectionController method addDragAndDropTarget.

/**
     * Accept Text and StyledText control.
     *
     * @param labelText
     */
public void addDragAndDropTarget(final Control textControl) {
    DropTargetListener dropTargetListener = new DropTargetListener() {

        String propertyName = null;

        @Override
        public void dragEnter(final DropTargetEvent event) {
        }

        @Override
        public void dragLeave(final DropTargetEvent event) {
        }

        @Override
        public void dragOperationChanged(final DropTargetEvent event) {
        }

        @Override
        public void dragOver(final DropTargetEvent event) {
            if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
                propertyName = getParameterName(textControl);
                for (int i = 0; i < elem.getElementParameters().size(); i++) {
                    IElementParameter param = elem.getElementParameters().get(i);
                    if (param.getName().equals(propertyName)) {
                        if (param.isReadOnly()) {
                            event.detail = DND.ERROR_INVALID_DATA;
                        }
                    }
                }
            }
        }

        @Override
        public void drop(final DropTargetEvent event) {
            if (propertyName != null) {
                String text;
                if (textControl instanceof StyledText) {
                    text = ((StyledText) textControl).getText() + (String) event.data;
                    ((StyledText) textControl).setText(text);
                } else {
                    text = ((Text) textControl).getText() + (String) event.data;
                    ((Text) textControl).setText(text);
                }
                Command cmd = new PropertyChangeCommand(elem, propertyName, text);
                // getCommandStack().execute(cmd);
                executeCommand(cmd);
            }
        }

        @Override
        public void dropAccept(final DropTargetEvent event) {
        }
    };
    DropTarget target = new DropTarget(textControl, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
    Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
    target.setTransfer(transfers);
    target.addDropListener(dropTargetListener);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Command(org.eclipse.gef.commands.Command) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) IElementParameter(org.talend.core.model.process.IElementParameter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 89 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractElementPropertySectionController method setAllConnectionParameters.

private void setAllConnectionParameters(String typ, IElement element) {
    IElementParameter basePropertyParameter = null;
    for (IElementParameter param : elem.getElementParameters()) {
        if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
            if (param.getRepositoryValue().startsWith("DATABASE")) {
                basePropertyParameter = param;
                break;
            }
        }
    }
    // jobsetting view load the db info from current selected category
    IElementParameter updateBasePropertyParameter = updateBasePropertyParameter();
    if (updateBasePropertyParameter != null && !updateBasePropertyParameter.equals(basePropertyParameter)) {
        basePropertyParameter = updateBasePropertyParameter;
    }
    String type = null;
    ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
    if (typ != null && !typ.equals("")) {
        //$NON-NLS-1$
        type = typ;
    } else {
        //$NON-NLS-1$
        type = getValueFromRepositoryName(element, "TYPE", basePropertyParameter);
    }
    if (type.equals("Oracle") || type.contains("OCLE")) {
        IElementParameter ele = element.getElementParameter("CONNECTION_TYPE");
        if (ele != null) {
            type = (String) ele.getValue();
        } else {
            //$NON-NLS-1$
            type = "ORACLE_SID";
        }
    }
    // Get real hsqldb type
    if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(element, "RUNNING_MODE", basePropertyParameter).equals("HSQLDB_INPROGRESS_PERSISTENT")) {
        //$NON-NLS-1$
        type = EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
    }
    // If the dbtype has been setted don't reset it again unless the dbtype of connParameters is null.
    if (StringUtils.trimToNull(type) == null && StringUtils.trimToNull(connParameters.getDbType()) == null) {
        type = EDatabaseTypeName.GENERAL_JDBC.getXmlName();
    }
    if (StringUtils.trimToNull(type) != null) {
        connParameters.setDbType(type);
    }
    //$NON-NLS-1$
    String frameWorkKey = getValueFromRepositoryName(element, "FRAMEWORK_TYPE", basePropertyParameter);
    connParameters.setFrameworkType(frameWorkKey);
    String schema = getValueFromRepositoryName(element, EConnectionParameterName.SCHEMA.getName(), basePropertyParameter);
    connParameters.setSchema(schema);
    String userName = getValueFromRepositoryName(element, EConnectionParameterName.USERNAME.getName(), basePropertyParameter);
    connParameters.setUserName(userName);
    String password = getValueFromRepositoryName(element, EConnectionParameterName.PASSWORD.getName(), basePropertyParameter);
    connParameters.setPassword(password);
    String host = getValueFromRepositoryName(element, EConnectionParameterName.SERVER_NAME.getName(), basePropertyParameter);
    connParameters.setHost(host);
    String port = getValueFromRepositoryName(element, EConnectionParameterName.PORT.getName(), basePropertyParameter);
    connParameters.setPort(port);
    boolean https = Boolean.parseBoolean(getValueFromRepositoryName(element, EConnectionParameterName.HTTPS.getName(), basePropertyParameter));
    connParameters.setHttps(https);
    boolean isOracleOCI = type.equals(EDatabaseTypeName.ORACLE_OCI.getXmlName()) || type.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName());
    if (isOracleOCI) {
        String localServiceName = getValueFromRepositoryNameAndParameterName(element, EConnectionParameterName.SID.getName(), EParameterName.LOCAL_SERVICE_NAME.getName());
        // sid is the repository value both for DBName and Local_service_name
        connParameters.setLocalServiceName(localServiceName);
    }
    String datasource = getValueFromRepositoryName(element, EConnectionParameterName.DATASOURCE.getName(), basePropertyParameter);
    connParameters.setDatasource(datasource);
    // qli modified to fix the bug "7364".
    String dbName = getValueFromRepositoryName(element, EConnectionParameterName.SID.getName(), basePropertyParameter);
    if (EDatabaseTypeName.EXASOL.getDisplayName().equals(connParameters.getDbType())) {
        if (dbName.contains("\\\"")) {
            dbName = dbName.replace("\\\"", "");
        }
        dbName = TextUtil.removeQuots(dbName);
    } else if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
        //$NON-NLS-1$
        dbName = "";
    }
    connParameters.setDbName(dbName);
    if (connParameters.getDbType().equals(EDatabaseTypeName.SQLITE.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.ACCESS.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.FIREBIRD.getXmlName())) {
        String file = getValueFromRepositoryName(element, EConnectionParameterName.FILE.getName(), basePropertyParameter);
        connParameters.setFilename(file);
    }
    String dir = getValueFromRepositoryName(element, EConnectionParameterName.DIRECTORY.getName(), basePropertyParameter);
    if (type.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) {
        dir = getValueFromRepositoryName(elem, EConnectionParameterName.DBPATH.getName(), basePropertyParameter);
    }
    connParameters.setDirectory(dir);
    // General jdbc
    String url = getValueFromRepositoryName(element, EConnectionParameterName.URL.getName(), basePropertyParameter);
    if (StringUtils.isEmpty(url)) {
        // to get the Oracle RAC url.
        if (EDatabaseTypeName.ORACLE_CUSTOM.getXmlName().equals(type)) {
            url = getValueFromRepositoryName(element, "RAC_" + EConnectionParameterName.URL.getName(), basePropertyParameter);
        }
    }
    connParameters.setUrl(TalendTextUtils.removeQuotes(url));
    String driverJar = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_JAR.getName(), basePropertyParameter);
    connParameters.setDriverJar(TalendTextUtils.removeQuotes(driverJar));
    String driverClass = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_CLASS.getName(), basePropertyParameter);
    String dbVersion = getValueFromRepositoryName(element, "DB_VERSION", basePropertyParameter);
    connParameters.setDbVersion(dbVersion);
    if (EDatabaseVersion4Drivers.VERTICA_5_1.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6_1_X.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_7.getVersionValue().equals(dbVersion)) {
        driverClass = EDatabase4DriverClassName.VERTICA2.getDriverClass();
    }
    connParameters.setDriverClass(TalendTextUtils.removeQuotes(driverClass));
    if (driverClass != null && !"".equals(driverClass) && !EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
        if (driverClass.startsWith("\"") && driverClass.endsWith("\"")) {
            driverClass = TalendTextUtils.removeQuotes(driverClass);
        }
        String dbTypeByClassName = "";
        if (driverJar != null && !"".equals(driverJar)) {
            dbTypeByClassName = extractMeta.getDbTypeByClassNameAndDriverJar(driverClass, driverJar);
        } else {
            dbTypeByClassName = extractMeta.getDbTypeByClassName(driverClass);
        }
        if (dbTypeByClassName != null) {
            connParameters.setDbType(dbTypeByClassName);
        }
    }
    String jdbcProps = getValueFromRepositoryName(element, EConnectionParameterName.PROPERTIES_STRING.getName(), basePropertyParameter);
    connParameters.setJdbcProperties(jdbcProps);
    String realTableName = null;
    if (EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()))) {
        final Object propertyValue = elem.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        IMetadataTable metadataTable = null;
        String connectionId = propertyValue.toString().split(" - ")[0];
        String tableLabel = propertyValue.toString().split(" - ")[1];
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        Item item = null;
        try {
            IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
            if (repobj != null) {
                Property property = repobj.getProperty();
                if (property != null) {
                    item = property.getItem();
                }
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
        if (item != null && item instanceof ConnectionItem) {
            Connection connection = ((ConnectionItem) item).getConnection();
            for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                if (table.getLabel().equals(tableLabel)) {
                    metadataTable = ConvertionHelper.convert(table);
                    break;
                }
            }
        }
        if (metadataTable != null) {
            realTableName = metadataTable.getTableName();
        }
    }
    connParameters.setSchemaName(QueryUtil.getTableName(elem, connParameters.getMetadataTable(), TalendTextUtils.removeQuotes(schema), type, realTableName));
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ExtractMetaDataUtils(org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 90 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method estimatePropertyHeightSize.

/**
     * DOC nrousseau Comment method "estimatePropertyHeightSize".
     * 
     * @param maxRow
     * @param listParam
     * @param tabbedPropertyComposite
     */
private int estimatePropertyHeightSize(int maxRow, List<? extends IElementParameter> listParam, TabbedPropertyComposite tabbedPropertyComposite) {
    int estimatedHeightSize = 0, estimatedMaxRowSize = 0;
    int additionalHeightSize = 0;
    int compositeHeight = tabbedPropertyComposite.getClientArea().height - tabbedPropertyComposite.getTitle().computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    // System.out.println("size composite:" + compositeHeight);
    int nbDynamic = 0;
    for (int curRow = 1; curRow <= maxRow; curRow++) {
        estimatedMaxRowSize = 0;
        for (int i = 0; i < listParam.size(); i++) {
            IElementParameter curParam = listParam.get(i);
            if (curParam.getCategory() == section) {
                if (curParam.getNumRow() == curRow && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
                    // field:"+curParam.getField());
                    if (curParam.isShow(listParam)) {
                        // System.out.println("show:" + curParam.getName()+
                        // " field:"+curParam.getField());
                        AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
                        if (controller == null) {
                            break;
                        }
                        int estimatedSize = controller.estimateRowSize(composite, curParam);
                        if (controller.hasDynamicRowSize()) {
                            nbDynamic++;
                        }
                        if (estimatedSize > estimatedMaxRowSize) {
                            estimatedMaxRowSize = estimatedSize;
                        }
                    }
                }
            }
        }
        estimatedHeightSize += estimatedMaxRowSize;
    }
    // System.out.println("*** ESTIMATED SIZE:" + estimatedHeightSize + "
    // ***");
    int emptySpace = compositeHeight - estimatedHeightSize;
    // System.out.println("--- EMPTY SPACE:" + emptySpace);
    if (emptySpace > 0 && nbDynamic > 0) {
        additionalHeightSize = emptySpace / nbDynamic;
    // System.out.println("--- DIVIDED ADDITIONAL HEIGHT (for each
    // dynamic):" + additionalHeightSize);
    }
    return additionalHeightSize;
}
Also used : AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) IElementParameter(org.talend.core.model.process.IElementParameter) Point(org.eclipse.swt.graphics.Point)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)439 ArrayList (java.util.ArrayList)165 List (java.util.List)112 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)99 INode (org.talend.core.model.process.INode)94 HashMap (java.util.HashMap)87 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)38 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)36 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28