use of org.talend.core.ui.properties.tab.IDynamicProperty in project tdi-studio-se by Talend.
the class StatsAndLogsViewHelper method reloadValuesFromPreferencePage.
/**
* ftang Comment method "reloadValuesFromPreferencePage".
*
* @param preferenceStore
* @param element
*/
public static void reloadValuesFromPreferencePage(Element element, IDynamicProperty propertyComposite) {
List<? extends IElementParameter> elementParameters = element.getElementParameters();
for (IElementParameter elementParameter : elementParameters) {
String name = elementParameter.getName();
if (name.equals(EParameterName.ON_STATCATCHER_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_STATCATCHER_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.ON_LOGCATCHER_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_LOGCATCHER_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.ON_METERCATCHER_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_METERCATCHER_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.ON_FILES_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_FILES_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.FILE_PATH.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILE_PATH.getName())));
continue;
}
if (name.equals(EParameterName.FILENAME_STATS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILENAME_STATS.getName())));
continue;
}
if (name.equals(EParameterName.FILENAME_LOGS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILENAME_LOGS.getName())));
continue;
}
if (name.equals(EParameterName.FILENAME_METTER.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.FILENAME_METTER.getName())));
continue;
}
if (name.equals(EParameterName.ON_DATABASE_FLAG.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.ON_DATABASE_FLAG.getName()));
continue;
}
if (name.equals(EParameterName.PROPERTY_TYPE.getName())) {
String propertyType = PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName());
String id = PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
/* 16969 */
Connection repositoryConnection = null;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
// Map<String, ConnectionItem> repositoryConnectionItemMap =
// propertyComposite.getRepositoryConnectionItemMap();
//
// if (repositoryConnectionItemMap.containsKey(id)) {
// repositoryConnection = repositoryConnectionItemMap.get(id).getConnection();
// } else {
// repositoryConnection = null;
// }
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(element, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(element, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) element).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = part.getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
continue;
}
if (PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName()).equals(EmfComponent.BUILTIN)) {
if (name.equals(EParameterName.DB_TYPE.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.DB_TYPE.getName()));
continue;
}
if (name.equals(EParameterName.HOST.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.HOST.getName())));
continue;
}
if (name.equals(EParameterName.PORT.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PORT.getName())));
continue;
}
if (name.equals(EParameterName.DBNAME.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.DBNAME.getName())));
continue;
}
if (name.equals(EParameterName.PROPERTIES.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTIES.getName())));
continue;
}
if (name.equals(EParameterName.DBFILE.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.DBFILE.getName())));
continue;
}
if (name.equals(EParameterName.SCHEMA_DB.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.SCHEMA_DB.getName())));
continue;
}
if (name.equals(EParameterName.USER.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.USER.getName())));
continue;
}
if (name.equals(EParameterName.PASS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PASS.getName())));
continue;
}
}
if (name.equals(EParameterName.TABLE_STATS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.TABLE_STATS.getName())));
continue;
}
if (name.equals(EParameterName.TABLE_LOGS.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.TABLE_LOGS.getName())));
continue;
}
if (name.equals(EParameterName.TABLE_METER.getName())) {
elementParameter.setValue(checkAndAddQuote(PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.TABLE_METER.getName())));
continue;
}
if (name.equals(EParameterName.CATCH_RUNTIME_ERRORS.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_RUNTIME_ERRORS.getName()));
continue;
}
if (name.equals(EParameterName.CATCH_USER_ERRORS.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_USER_ERRORS.getName()));
continue;
}
if (name.equals(EParameterName.CATCH_USER_WARNING.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_USER_WARNING.getName()));
continue;
}
if (name.equals(EParameterName.CATCH_REALTIME_STATS.getName())) {
elementParameter.setValue(PREFERENCE_STORE.getBoolean(LANGUAGE_PREFIX + EParameterName.CATCH_REALTIME_STATS.getName()));
continue;
}
}
}
Aggregations