Search in sources :

Example 56 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class StatsAndLogsHelper method statsAndLogsParametersFilePart.

private static void statsAndLogsParametersFilePart(Element elem) {
    ElementParameter param;
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    // on files
    param = new ElementParameter(elem);
    param.setName(EParameterName.ON_FILES_FLAG.getName());
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.ON_FILES_FLAG.getName()));
    param.setDisplayName(EParameterName.ON_FILES_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(10);
    //$NON-NLS-1$
    param.setShowIf("(ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    paramList.add(param);
    // file path
    param = new ElementParameter(elem);
    param.setName(EParameterName.FILE_PATH.getName());
    param.setValue(addQuotes(replaceSlash(preferenceStore.getString(languagePrefix + EParameterName.FILE_PATH.getName()))));
    param.setDisplayName(EParameterName.FILE_PATH.getDisplayName());
    param.setFieldType(EParameterFieldType.DIRECTORY);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    param.setNumRow(11);
    paramList.add(param);
    // stats file name
    param = new ElementParameter(elem);
    param.setName(EParameterName.FILENAME_STATS.getName());
    param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.FILENAME_STATS.getName())));
    param.setDisplayName(EParameterName.FILENAME_STATS.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true' and ON_STATCATCHER_FLAG == 'true')");
    param.setRequired(true);
    param.setNumRow(12);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.FILENAME_LOGS.getName());
    param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.FILENAME_LOGS.getName())));
    param.setDisplayName(EParameterName.FILENAME_LOGS.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true' and ON_LOGCATCHER_FLAG == 'true')");
    param.setNumRow(13);
    param.setRequired(true);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.FILENAME_METTER.getName());
    param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.FILENAME_METTER.getName())));
    param.setDisplayName(EParameterName.FILENAME_METTER.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true' and ON_METERCATCHER_FLAG == 'true')");
    param.setRequired(true);
    param.setNumRow(14);
    paramList.add(param);
    // stats log encoding
    ElementParameter encodingParam = new ElementParameter(elem);
    encodingParam.setName(EParameterName.ENCODING.getName());
    encodingParam.setDisplayName(EParameterName.ENCODING.getDisplayName());
    encodingParam.setCategory(EComponentCategory.STATSANDLOGS);
    encodingParam.setFieldType(EParameterFieldType.ENCODING_TYPE);
    encodingParam.setShowIf(//$NON-NLS-1$
    "(ON_FILES_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    encodingParam.setValue(ENCODING_TYPE_ISO_8859_15);
    encodingParam.setNumRow(15);
    paramList.add(encodingParam);
    ElementParameter childPram = new ElementParameter(elem);
    childPram.setName(EParameterName.ENCODING_TYPE.getName());
    childPram.setDisplayName(EParameterName.ENCODING_TYPE.getDisplayName());
    childPram.setFieldType(EParameterFieldType.TECHNICAL);
    childPram.setCategory(EComponentCategory.STATSANDLOGS);
    childPram.setListItemsDisplayName(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
    childPram.setListItemsDisplayCodeName(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
    childPram.setListItemsValue(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
    childPram.setValue(ENCODING_TYPE_ISO_8859_15);
    childPram.setNumRow(15);
    childPram.setShowIf(//$NON-NLS-1$
    "(ON_FILES_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    childPram.setParentParameter(encodingParam);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 57 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ProjectSettingManager method createExtraOnDBParameters.

private static void createExtraOnDBParameters(Element elem) {
    ElementParameter param;
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    // checks current language, if it is perl, set languageType to 0(default value), otherwise to 1.
    int languageType = 0;
    if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        languageType = 1;
    }
    final String onDBCondition = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName()) + //$NON-NLS-1$
    " == 'true'";
    final String dbCondition = JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION) + " and " + //$NON-NLS-1$
    JobSettingsConstants.addBrackets(onDBCondition);
    // property type
    ElementParameter parentPropertyType = new ElementParameter(elem);
    parentPropertyType.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
    parentPropertyType.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
    parentPropertyType.setValue(preferenceStore.getString(getPreferenceName(EParameterName.PROPERTY_TYPE)));
    parentPropertyType.setCategory(EComponentCategory.EXTRA);
    parentPropertyType.setFieldType(EParameterFieldType.PROPERTY_TYPE);
    parentPropertyType.setRepositoryValue(ERepositoryCategoryType.DATABASE.getName());
    parentPropertyType.setNumRow(41);
    parentPropertyType.setShowIf(dbCondition);
    parentPropertyType.setGroup(IMPLICIT_GROUP);
    paramList.add(parentPropertyType);
    param = new ElementParameter(elem);
    param.setName(EParameterName.PROPERTY_TYPE.getName());
    param.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
    param.setListItemsDisplayName(new String[] { EmfComponent.TEXT_BUILTIN, EmfComponent.TEXT_REPOSITORY });
    param.setListItemsDisplayCodeName(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
    param.setListItemsValue(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
    param.setValue(preferenceStore.getString(getPreferenceName(EParameterName.PROPERTY_TYPE)));
    param.setCategory(EComponentCategory.EXTRA);
    param.setFieldType(EParameterFieldType.TECHNICAL);
    param.setRepositoryValue(ERepositoryCategoryType.DATABASE.getName());
    param.setNumRow(41);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    param.setParentParameter(parentPropertyType);
    // paramList.add(param);
    // repository property type
    param = new ElementParameter(elem);
    param.setName(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    param.setDisplayName(EParameterName.REPOSITORY_PROPERTY_TYPE.getDisplayName());
    param.setListItemsDisplayName(new String[] {});
    param.setListItemsValue(new String[] {});
    param.setValue(// +
    preferenceStore.getString(// +
    getPreferenceName(EParameterName.REPOSITORY_PROPERTY_TYPE)));
    param.setCategory(EComponentCategory.EXTRA);
    param.setFieldType(EParameterFieldType.TECHNICAL);
    param.setShow(false);
    param.setRequired(true);
    param.setNumRow(41);
    param.setGroup(IMPLICIT_GROUP);
    param.setParentParameter(parentPropertyType);
    // paramList.add(param);
    // dbType
    final String dbTypeName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName());
    param = new ElementParameter(elem);
    param.setName(dbTypeName);
    param.setDisplayName(EParameterName.DB_TYPE.getDisplayName());
    param.setFieldType(EParameterFieldType.CLOSED_LIST);
    param.setCategory(EComponentCategory.EXTRA);
    param.setListItemsDisplayName(StatsAndLogsConstants.DISPLAY_DBNAMES[languageType]);
    param.setListItemsValue(JobSettingsConstants.DB_INPUT_COMPONENTS[languageType]);
    param.setListRepositoryItems(StatsAndLogsConstants.REPOSITORY_ITEMS[languageType]);
    param.setListItemsDisplayCodeName(StatsAndLogsConstants.CODE_LIST[languageType]);
    param.setValue(preferenceStore.getString(getPreferenceName(EParameterName.DB_TYPE)));
    param.setNumRow(42);
    //$NON-NLS-1$
    param.setRepositoryValue("TYPE");
    param.setRequired(true);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // dbVersion
    final String dbVersionName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
    param = new ElementParameter(elem);
    param.setName(dbVersionName);
    param.setValue(preferenceStore.getString(getPreferenceName(EParameterName.DB_VERSION)));
    param.setDisplayName(EParameterName.DB_VERSION.getDisplayName());
    param.setFieldType(EParameterFieldType.CLOSED_LIST);
    param.setCategory(EComponentCategory.EXTRA);
    param.setListItemsDisplayName(StatsAndLogsConstants.DB_VERSION_DISPLAY);
    param.setListItemsValue(StatsAndLogsConstants.DB_VERSION_DRIVER);
    param.setListItemsDisplayCodeName(StatsAndLogsConstants.DB_VERSION_CODE);
    param.setNumRow(42);
    //$NON-NLS-1$
    param.setRepositoryValue("DB_VERSION");
    param.setRequired(true);
    param.setShowIf(dbCondition + " and (" + dbTypeName + " == 'OCLE' or " + dbTypeName + " == 'OCLE_OCI' or " + dbTypeName + " =='ACCESS' or " + dbTypeName + " =='MSSQL' or " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
    " =='MYSQL')");
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // jdbc url
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName()));
    param.setValue(StatsAndLogsManager.addQuotes(preferenceStore.getString(languagePrefix + EParameterName.URL.getName())));
    param.setDisplayName(EParameterName.URL.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(43);
    //$NON-NLS-1$
    param.setRepositoryValue("URL");
    String dbCon = dbTypeName + " == 'JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // jdbc child param
    List<ModuleNeeded> moduleNeededList = ModulesNeededProvider.getModulesNeeded();
    Set<String> moduleNameList = new TreeSet<String>();
    Set<String> moduleValueList = new TreeSet<String>();
    for (ModuleNeeded module : moduleNeededList) {
        String moduleName = module.getModuleName();
        if (moduleName != null) {
            moduleNameList.add(moduleName);
            moduleValueList.add(TalendTextUtils.addQuotes(moduleName));
        }
    }
    Comparator<String> comprarator = new IgnoreCaseComparator();
    String[] moduleNameArray = moduleNameList.toArray(new String[0]);
    String[] moduleValueArray = moduleValueList.toArray(new String[0]);
    Arrays.sort(moduleNameArray, comprarator);
    Arrays.sort(moduleValueArray, comprarator);
    ElementParameter childParam = new ElementParameter(elem);
    //$NON-NLS-1$
    childParam.setName("JAR_NAME");
    //$NON-NLS-1$
    childParam.setDisplayName("JAR_NAME");
    childParam.setFieldType(EParameterFieldType.MODULE_LIST);
    childParam.setListItemsDisplayName(moduleNameArray);
    childParam.setListItemsValue(moduleValueArray);
    // driver jar for jdbc
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName()));
    param.setDisplayName(EParameterName.DRIVER_JAR.getDisplayName());
    param.setFieldType(EParameterFieldType.TABLE);
    //$NON-NLS-1$
    param.setListItemsDisplayCodeName(new String[] { "JAR_NAME" });
    //$NON-NLS-1$
    param.setListItemsDisplayName(new String[] { "Jar Name" });
    param.setListItemsValue(new ElementParameter[] { childParam });
    param.setValue(new ArrayList<Map<String, Object>>());
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(44);
    //$NON-NLS-1$
    param.setRepositoryValue("DRIVER_JAR");
    //$NON-NLS-1$
    dbCon = dbTypeName + " == 'JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // class name for jdbc
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName()));
    param.setValue(StatsAndLogsManager.addQuotes(preferenceStore.getString(languagePrefix + EParameterName.DRIVER_CLASS.getName())));
    param.setDisplayName(EParameterName.DRIVER_CLASS.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(45);
    //$NON-NLS-1$
    param.setRepositoryValue("DRIVER_CLASS");
    dbCon = dbTypeName + " == 'JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // host
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.HOST))));
    param.setDisplayName(EParameterName.HOST.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(43);
    //$NON-NLS-1$
    param.setRepositoryValue("SERVER_NAME");
    dbCon = //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
    dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + "!='JDBC'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "!='ODBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // port
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.PORT))));
    param.setDisplayName(EParameterName.PORT.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(43);
    //$NON-NLS-1$
    param.setRepositoryValue("PORT");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + " != 'FIREBIRD'" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$//$NON-NLS-6$
    " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + "!='JDBC'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "!='ODBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // dbName
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.DBNAME))));
    param.setDisplayName(EParameterName.DBNAME.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(44);
    //$NON-NLS-1$
    param.setRepositoryValue("SID");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + " != 'FIREBIRD'" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$//$NON-NLS-6$
    " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "!='JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // local service name
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.LOCAL_SERVICE_NAME.getName()));
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.LOCAL_SERVICE_NAME.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(44);
    //$NON-NLS-1$
    param.setRepositoryValue("SID");
    //$NON-NLS-1$
    dbCon = dbTypeName + " == 'OCLE_OCI' ";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        // additional parameters
        param = new ElementParameter(elem);
        param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName()));
        param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.PROPERTIES))));
        param.setDisplayName(EParameterName.PROPERTIES.getDisplayName());
        param.setFieldType(EParameterFieldType.TEXT);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(44);
        //$NON-NLS-1$
        param.setRepositoryValue("PROPERTIES_STRING");
        dbCon = dbTypeName + " == 'MSSQL'" + " or " + dbTypeName + " == 'MYSQL'" + " or " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        dbTypeName + " == 'INFORMIX'" + " or " + dbTypeName + " == 'OCLE'" + " or " + dbTypeName + " == 'OCLE_OCI'" + " or " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
        " == 'SYBASE'";
        //$NON-NLS-1$
        param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
    }
    // schema
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.SCHEMA_DB))));
    param.setDisplayName(EParameterName.SCHEMA_DB.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(44);
    //$NON-NLS-1$
    param.setRepositoryValue("SCHEMA");
    final String schemaCondition = JobSettingsConstants.addBrackets(dbTypeName + " =='OCLE' or " + dbTypeName + " =='OCLE_OCI' or " + dbTypeName + " =='POSTGRESQL' or " + dbTypeName + " =='POSTGRESPLUS' or " + dbTypeName + " =='MSSQL' or " + dbTypeName + " =='INFORMIX' or " + dbTypeName + " =='IBM_DB2' or " + dbTypeName + //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$
    " =='SYBASE'");
    //$NON-NLS-1$
    param.setShowIf(schemaCondition + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // username
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.USER))));
    param.setDisplayName(EParameterName.USER.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(45);
    param.setRequired(true);
    //$NON-NLS-1$
    param.setRepositoryValue("USERNAME");
    //$NON-NLS-1$
    dbCon = dbTypeName + " != 'SQLITE'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // password
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.PASS))));
    param.setDisplayName(EParameterName.PASS.getDisplayName());
    param.setFieldType(EParameterFieldType.PASSWORD);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(45);
    param.setRequired(true);
    //$NON-NLS-1$
    param.setRepositoryValue("PASSWORD");
    //$NON-NLS-1$
    dbCon = dbTypeName + " != 'SQLITE'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // databse file path
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBFILE.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.DBFILE))));
    param.setDisplayName(EParameterName.DBFILE.getDisplayName());
    param.setFieldType(EParameterFieldType.FILE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(46);
    //$NON-NLS-1$
    param.setRepositoryValue("FILE");
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    dbCon = dbTypeName + " == 'SQLITE'" + " or " + dbTypeName + " == 'ACCESS'" + " or " + dbTypeName + " == 'FIREBIRD'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // table
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.DBTABLE))));
    param.setDisplayName(EParameterName.DBTABLE.getDisplayName());
    param.setFieldType(EParameterFieldType.DBTABLE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // query condition
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.QUERY_CONDITION.getName()));
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.QUERY_CONDITION))));
    param.setDisplayName(EParameterName.QUERY_CONDITION.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(48);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) TreeSet(java.util.TreeSet) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Map(java.util.Map)

Example 58 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ProjectSettingManager method createExtraOnFileParameters.

private static void createExtraOnFileParameters(Element elem) {
    ElementParameter param;
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    // // set Implicit tContextLoad file
    //        String fileName = ElementParameterParser.parse(elem, "__COMP_DEFAULT_FILE_DIR__/in.csv"); //$NON-NLS-1$
    // IPath path = Path.fromOSString(fileName);
    // fileName = TalendTextUtils.addQuotes(path.toPortableString());
    // set Implicit tContextLoad file
    param = new ElementParameter(elem);
    param.setName(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName());
    param.setValue(addQuotes(replaceSlash(preferenceStore.getString(getPreferenceName(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE)))));
    param.setDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getDisplayName());
    param.setFieldType(EParameterFieldType.FILE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(31);
    String condition = JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION) + //$NON-NLS-1$
    " and " + JobSettingsConstants.addBrackets(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName()) + //$NON-NLS-1$
    " == 'true'");
    param.setShowIf(condition);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.FIELDSEPARATOR.getName());
    param.setValue(addQuotes(preferenceStore.getString(getPreferenceName(EParameterName.FIELDSEPARATOR))));
    param.setDisplayName(EParameterName.FIELDSEPARATOR.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(32);
    param.setShowIf(condition);
    paramList.add(param);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList)

Example 59 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ProjectSettingManager method createExtraContextLoadParameters.

private static void createExtraContextLoadParameters(Element elem) {
    ElementParameter param;
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        final String[] itemValues = new String[] { ContextLoadInfo.ERROR.getDisplayName(), ContextLoadInfo.WARNING.getDisplayName(), ContextLoadInfo.INFO.getDisplayName() };
        //
        param = new ElementParameter(elem);
        param.setName(EParameterName.LOAD_NEW_VARIABLE.getName());
        param.setDisplayName(EParameterName.LOAD_NEW_VARIABLE.getDisplayName());
        param.setValue(preferenceStore.getString(getPreferenceName(EParameterName.LOAD_NEW_VARIABLE)));
        param.setListItemsDisplayName(itemValues);
        param.setListItemsValue(itemValues);
        param.setFieldType(EParameterFieldType.CLOSED_LIST);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(80);
        param.setShowIf(CONTEXTLOAD_CONDITION);
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
        //
        param = new ElementParameter(elem);
        param.setName(EParameterName.NOT_LOAD_OLD_VARIABLE.getName());
        param.setDisplayName(EParameterName.NOT_LOAD_OLD_VARIABLE.getDisplayName());
        param.setValue(preferenceStore.getString(getPreferenceName(EParameterName.NOT_LOAD_OLD_VARIABLE)));
        param.setListItemsDisplayName(itemValues);
        param.setListItemsValue(itemValues);
        param.setFieldType(EParameterFieldType.CLOSED_LIST);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(81);
        param.setShowIf(CONTEXTLOAD_CONDITION);
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
    }
    // print operations
    param = new ElementParameter(elem);
    param.setName(EParameterName.PRINT_OPERATIONS.getName());
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.PRINT_OPERATIONS)));
    param.setDisplayName(EParameterName.PRINT_OPERATIONS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(82);
    param.setRequired(true);
    param.setShowIf(CONTEXTLOAD_CONDITION);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        // disable error
        param = new ElementParameter(elem);
        param.setName(EParameterName.DISABLE_ERROR.getName());
        param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.DISABLE_ERROR)));
        param.setDisplayName(EParameterName.DISABLE_ERROR.getDisplayName());
        param.setFieldType(EParameterFieldType.CHECK);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(83);
        param.setRequired(true);
        param.setShowIf(CONTEXTLOAD_CONDITION);
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
    }
    // disable warnings
    param = new ElementParameter(elem);
    param.setName(EParameterName.DISABLE_WARNINGS.getName());
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.DISABLE_WARNINGS)));
    param.setDisplayName(EParameterName.DISABLE_WARNINGS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(83);
    param.setRequired(true);
    param.setShowIf(CONTEXTLOAD_CONDITION);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        // disable info
        param = new ElementParameter(elem);
        param.setName(EParameterName.DISABLE_INFO.getName());
        param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.DISABLE_INFO)));
        param.setDisplayName(EParameterName.DISABLE_INFO.getDisplayName());
        param.setFieldType(EParameterFieldType.CHECK);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(83);
        param.setRequired(true);
        param.setShowIf(CONTEXTLOAD_CONDITION);
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList)

Example 60 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter 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;
}
Also used : INode(org.talend.core.model.process.INode) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) DynamicComposite(org.talend.repository.generic.ui.DynamicComposite) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ElementParameter (org.talend.designer.core.model.components.ElementParameter)72 IElementParameter (org.talend.core.model.process.IElementParameter)62 ArrayList (java.util.ArrayList)44 List (java.util.List)26 INode (org.talend.core.model.process.INode)20 Map (java.util.Map)19 HashMap (java.util.HashMap)15 Node (org.talend.designer.core.ui.editor.nodes.Node)12 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)10 Test (org.junit.Test)9 IComponent (org.talend.core.model.components.IComponent)8 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)7 IConnection (org.talend.core.model.process.IConnection)7 Form (org.talend.daikon.properties.presentation.Form)6 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)5 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 INodeConnector (org.talend.core.model.process.INodeConnector)5 IProcess (org.talend.core.model.process.IProcess)4