Search in sources :

Example 51 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class StatsAndLogsHelper method statsAndLogsParametersFinalPart.

private static void statsAndLogsParametersFinalPart(Element elem) {
    ElementParameter param;
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    // Catch runtime errors
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_RUNTIME_ERRORS");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_RUNTIME_ERRORS.getName()));
    param.setDisplayName(EParameterName.CATCH_RUNTIME_ERRORS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(90);
    //$NON-NLS-1$
    param.setShowIf("ON_LOGCATCHER_FLAG == 'true'");
    paramList.add(param);
    // Catch user errors
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_USER_ERRORS");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_USER_ERRORS.getName()));
    param.setDisplayName(EParameterName.CATCH_USER_ERRORS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(90);
    //$NON-NLS-1$
    param.setShowIf("ON_LOGCATCHER_FLAG == 'true'");
    paramList.add(param);
    // Catch user warning
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_USER_WARNING");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_USER_WARNING.getName()));
    param.setDisplayName(EParameterName.CATCH_USER_WARNING.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(90);
    //$NON-NLS-1$
    param.setShowIf("ON_LOGCATCHER_FLAG == 'true'");
    paramList.add(param);
    // Catch realtime statistics
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_REALTIME_STATS");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_REALTIME_STATS.getName()));
    param.setDisplayName(//$NON-NLS-1$
    EParameterName.CATCH_REALTIME_STATS.getDisplayName() + " (" + EParameterName.TSTATCATCHER_STATS.getDisplayName() + //$NON-NLS-1$
    ")");
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(91);
    //$NON-NLS-1$
    param.setShowIf("ON_STATCATCHER_FLAG == 'true'");
    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) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 52 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class TosTokenCollector method collect.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.token.AbstractTokenCollector#collect()
     */
@Override
public JSONObject collect() throws Exception {
    JSONObject finalToken = new JSONObject();
    JSONObject mergedData = new JSONObject();
    IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore();
    String records = preferenceStore.getString(PREF_TOS_JOBS_RECORDS);
    JSONObject allProjectRecords = null;
    try {
        // reset
        allProjectRecords = new JSONObject(records);
    } catch (Exception e) {
        // the value is not set, or is empty
        allProjectRecords = new JSONObject();
    }
    Iterator<String> keys = allProjectRecords.keys();
    JSONObject projectTypes = new JSONObject();
    while (keys.hasNext()) {
        String projectName = keys.next();
        JSONObject object = (JSONObject) allProjectRecords.get(projectName);
        if (object != null) {
            TokenInforUtil.mergeJSON(object, mergedData);
            if (object.has(TYPE.getKey())) {
                String type = object.getString(TYPE.getKey());
                // count the number of project for each type
                if (!projectTypes.has(type)) {
                    projectTypes.put(type, 1);
                } else {
                    int nb = projectTypes.getInt(type);
                    nb++;
                    projectTypes.put(type, nb);
                }
            }
        }
    }
    if (mergedData.has(PROJECTS.getKey())) {
        finalToken.put(PROJECTS_REPOSITORY.getKey(), mergedData.get(PROJECTS.getKey()));
    }
    finalToken.put("projects.type", projectTypes);
    return finalToken;
}
Also used : JSONObject(us.monoid.json.JSONObject) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) JSONException(us.monoid.json.JSONException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 53 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class JavaVersionProjectSettingPageInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    IPreferenceStore preferenceStore = CoreRuntimePlugin.getInstance().getProjectPreferenceManager().getPreferenceStore();
    preferenceStore.setDefault(JavaUtils.PROJECT_JAVA_VERSION_KEY, JavaCore.VERSION_1_8);
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 54 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class JobSettingsManager method getExtraOnDBParameters.

private static List<IElementParameter> getExtraOnDBParameters(IProcess process) {
    ElementParameter param;
    List<IElementParameter> paramList = new ArrayList<IElementParameter>();
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    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(process);
    parentPropertyType.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
    parentPropertyType.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
    //$NON-NLS-1$
    parentPropertyType.setValue("");
    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(process);
    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(EmfComponent.BUILTIN);
    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(process);
    param.setName(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    param.setDisplayName(EParameterName.REPOSITORY_PROPERTY_TYPE.getDisplayName());
    param.setListItemsDisplayName(new String[] {});
    param.setListItemsValue(new String[] {});
    // param.setValue(""); //$NON-NLS-1$
    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(process);
    param.setName(dbTypeName);
    param.setDisplayName(EParameterName.DB_TYPE.getDisplayName());
    param.setFieldType(EParameterFieldType.CLOSED_LIST);
    param.setCategory(EComponentCategory.EXTRA);
    param.setListItemsDisplayName(StatsAndLogsConstants.DISPLAY_DBNAMES[1]);
    param.setListItemsValue(JobSettingsConstants.DB_INPUT_COMPONENTS[1]);
    param.setListRepositoryItems(StatsAndLogsConstants.REPOSITORY_ITEMS[1]);
    param.setListItemsDisplayCodeName(StatsAndLogsConstants.CODE_LIST[1]);
    param.setValue("");
    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());
    if (process.getElementParameter(dbVersionName) == null) {
        param = new ElementParameter(process);
        param.setName(dbVersionName);
        param.setValue(StatsAndLogsConstants.DB_VERSION_DRIVER[1]);
        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$//$NON-NLS-5$
        " =='MYSQL') ");
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
    }
    // jdbc url
    param = new ElementParameter(process);
    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
    if (moduleNameList == null) {
        List<ModuleNeeded> moduleNeededList = ModulesNeededProvider.getModulesNeeded();
        moduleNameList = new ArrayList<String>();
        moduleValueList = new ArrayList<String>();
        for (ModuleNeeded module : moduleNeededList) {
            String moduleName = module.getModuleName();
            if (moduleName != null) {
                if (!moduleNameList.contains(moduleName)) {
                    moduleNameList.add(moduleName);
                }
                String moduleValue = TalendTextUtils.addQuotes(moduleName);
                if (!moduleValueList.contains(moduleValue)) {
                    moduleValueList.add(moduleValue);
                }
            }
        }
        Comparator<String> comprarator = new IgnoreCaseComparator();
        Collections.sort(moduleNameList, comprarator);
        Collections.sort(moduleValueList, comprarator);
    }
    String[] moduleNameArray = moduleNameList.toArray(new String[0]);
    String[] moduleValueArray = moduleValueList.toArray(new String[0]);
    ElementParameter childParam = new ElementParameter(process);
    childParam.setName("JAR_NAME");
    childParam.setDisplayName("JAR_NAME");
    childParam.setFieldType(EParameterFieldType.MODULE_LIST);
    childParam.setListItemsDisplayName(moduleNameArray);
    childParam.setListItemsValue(moduleValueArray);
    // driver jar for jdbc
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName()));
    param.setDisplayName(EParameterName.DRIVER_JAR.getDisplayName());
    param.setFieldType(EParameterFieldType.TABLE);
    param.setListItemsDisplayCodeName(new String[] { "JAR_NAME" });
    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");
    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(process);
    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(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.HOST.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(46);
    //$NON-NLS-1$
    param.setRepositoryValue("SERVER_NAME");
    dbCon = 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$//$NON-NLS-5$
    "!='ODBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // port
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.PORT.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(46);
    //$NON-NLS-1$
    param.setRepositoryValue("PORT");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + " != 'FIREBIRD'" + " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + "!='JDBC'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
    "!='ODBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // dbName
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.DBNAME.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$NON-NLS-1$
    param.setRepositoryValue("SID");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + " != 'FIREBIRD'" + " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
    "!='JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // local service name
    param = new ElementParameter(process);
    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(47);
    //$NON-NLS-1$
    param.setRepositoryValue("SID");
    dbCon = dbTypeName + " =='OCLE_OCI' ";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // additional parameters
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.PROPERTIES.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$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(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.SCHEMA_DB.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$NON-NLS-1$
    param.setRepositoryValue("SCHEMA");
    final String schemaCondition = JobSettingsConstants.addBrackets(dbTypeName + " =='OCLE' or " + //$NON-NLS-1$
    dbTypeName + " =='POSTGRESQL' or " + dbTypeName + " =='POSTGRESPLUS' or " + dbTypeName + " =='OCLE_OCI' 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$
    " =='SYBASE'");
    //$NON-NLS-1$
    param.setShowIf(schemaCondition + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // username
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.USER.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(48);
    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(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.PASS.getDisplayName());
    param.setFieldType(EParameterFieldType.PASSWORD);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(48);
    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(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBFILE.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.DBFILE.getDisplayName());
    param.setFieldType(EParameterFieldType.FILE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(49);
    //$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(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.DBTABLE.getDisplayName());
    param.setFieldType(EParameterFieldType.DBTABLE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(50);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // query condition
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.QUERY_CONDITION.getName()));
    param.setValue(QUOTE + QUOTE);
    param.setDisplayName(EParameterName.QUERY_CONDITION.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(51);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    for (IElementParameter currentParam : paramList) {
        if (currentParam.getRepositoryValue() != null) {
            // if any of the parameter of stat&logs is using repository, then force to link it to the name of the
            // property for implicit
            currentParam.setRepositoryProperty(parentPropertyType.getName());
        }
    }
    return paramList;
}
Also used : ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Map(java.util.Map)

Example 55 with IPreferenceStore

use of org.eclipse.jface.preference.IPreferenceStore in project tdi-studio-se by Talend.

the class JobSettingsManager method getExtraParameters.

/**
     * 
     * create parameter for extra tab.
     */
private static List<IElementParameter> getExtraParameters(IProcess process) {
    ElementParameter param;
    List<IElementParameter> paramList = new ArrayList<IElementParameter>();
    // use project settings
    param = new ElementParameter(process);
    param.setName(EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName());
    param.setValue(Boolean.FALSE);
    param.setDisplayName(EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(2);
    param.setShow(false);
    paramList.add(param);
    param = new ElementParameter(process);
    param.setName(EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName());
    param.setValue(Boolean.FALSE);
    param.setDisplayName(EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(2);
    param.setShow(false);
    paramList.add(param);
    // end
    boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(process);
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    param = new ElementParameter(process);
    param.setName(EParameterName.MULTI_THREAD_EXECATION.getName());
    param.setValue(preferenceStore.getBoolean(ITalendCorePrefConstants.RUN_IN_MULTI_THREAD));
    param.setDisplayName(EParameterName.MULTI_THREAD_EXECATION.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(2);
    param.setShow(!isJoblet);
    //$NON-NLS-1$
    param.setShowIf("(MULTI_THREAD_EXECATION=='true' or MULTI_THREAD_EXECATION=='false')");
    paramList.add(param);
    if (isTeamEdition) {
        param = new ElementParameter(process);
        param.setName(EParameterName.PARALLELIZE_UNIT_SIZE.getName());
        //$NON-NLS-1$
        param.setValue("25000");
        param.setDisplayName(EParameterName.PARALLELIZE_UNIT_SIZE.getDisplayName());
        param.setFieldType(EParameterFieldType.TEXT);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(2);
        param.setShow(!isJoblet);
        paramList.add(param);
    }
    // achen modify to fix bug 0006241
    if (isJoblet) {
        param = new ElementParameter(process);
        param.setName(EParameterName.STARTABLE.getName());
        param.setValue(false);
        param.setDisplayName(EParameterName.STARTABLE.getDisplayName());
        param.setFieldType(EParameterFieldType.CHECK);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(2);
        paramList.add(param);
        param = new ElementParameter(process);
        param.setName(EParameterName.UPDATE_COMPONENTS.getName());
        param.setValue(Boolean.FALSE);
        param.setDisplayName(EParameterName.UPDATE_COMPONENTS.getDisplayName());
        param.setFieldType(EParameterFieldType.CHECK);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(1);
        param.setReadOnly(true);
        param.setRequired(false);
        param.setShow(false);
        paramList.add(param);
        // zywang added to fix feature 5545
        param = new ElementParameter(process);
        param.setName(EParameterName.ICONSELECTION.getName());
        //$NON-NLS-1$
        param.setValue("");
        param.setDisplayName(EParameterName.ICONSELECTION.getDisplayName());
        param.setFieldType(EParameterFieldType.ICON_SELECTION);
        param.setCategory(EComponentCategory.EXTRA);
        param.setNumRow(3);
        param.setReadOnly(false);
        param.setRequired(false);
        paramList.add(param);
    }
    param = new ElementParameter(process);
    param.setName(EParameterName.IMPLICIT_TCONTEXTLOAD.getName());
    param.setValue(false);
    param.setGroupDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD.getDisplayName());
    param.setDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(3);
    param.setShow(!isJoblet);
    paramList.add(param);
    // on files
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName()));
    param.setValue(false);
    param.setDisplayName(EParameterName.FROM_FILE_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.RADIO);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(4);
    param.setShowIf(JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION));
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // on database
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName()));
    param.setValue(false);
    param.setDisplayName(EParameterName.FROM_DATABASE_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.RADIO);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(5);
    param.setShowIf(JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION));
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // on file
    paramList.addAll(getExtraOnFileParameters(process));
    // on database
    paramList.addAll(getExtraOnDBParameters(process));
    // tContextLoad
    paramList.addAll(getExtraContextLoadParameters(process));
    return paramList;
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)311 ArrayList (java.util.ArrayList)35 Test (org.junit.Test)23 Hashtable (java.util.Hashtable)19 File (java.io.File)18 Before (org.junit.Before)17 List (java.util.List)14 IPath (org.eclipse.core.runtime.IPath)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 IOException (java.io.IOException)12 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)12 IElementParameter (org.talend.core.model.process.IElementParameter)12 CoreException (org.eclipse.core.runtime.CoreException)11 Path (org.eclipse.core.runtime.Path)11 Font (org.eclipse.swt.graphics.Font)11 Point (org.eclipse.swt.graphics.Point)11 Composite (org.eclipse.swt.widgets.Composite)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 IStatus (org.eclipse.core.runtime.IStatus)10 StyledText (org.eclipse.swt.custom.StyledText)10