use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method performDefaults.
@Override
public boolean performDefaults() {
boolean isReadonly = isReadonly();
if (isReadonly) {
super.performDefaults();
return false;
}
boolean agree = MessageDialog.openConfirm(getShell(), // $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.performDefaults.confirm.title"), // $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.performDefaults.confirm.message"));
if (!agree) {
return false;
}
try {
IDynamicDistributionsGroup selectedSetupDynamicDistriGroup = getSelectedSetupDynamicDistriGroup();
if (selectedSetupDynamicDistriGroup != null) {
IDynamicDistributionPreference dynamicDistributionPreference = selectedSetupDynamicDistriGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
if (dynamicDistributionPreference != null) {
boolean changed = false;
boolean isAnonymous = dynamicDistributionPreference.getDefaultIsAnonymous();
changed = changed || dynamicDistributionPreference.isAnonymous() != isAnonymous;
dynamicDistributionPreference.setAnonymous(isAnonymous);
boolean overrideDefaultSetup = dynamicDistributionPreference.getDefaultOverrideDefaultSetup();
changed = changed || dynamicDistributionPreference.overrideDefaultSetup() != overrideDefaultSetup;
dynamicDistributionPreference.setOverrideDefaultSetup(overrideDefaultSetup);
String password = dynamicDistributionPreference.getDefaultPassword();
changed = changed || !StringUtils.equals(dynamicDistributionPreference.getPassword(), password);
dynamicDistributionPreference.setPassword(password);
String repository = dynamicDistributionPreference.getDefaultRepository();
changed = changed || !StringUtils.equals(dynamicDistributionPreference.getRepository(), repository);
dynamicDistributionPreference.setRepository(repository);
String username = dynamicDistributionPreference.getDefaultUsername();
changed = changed || !StringUtils.equals(dynamicDistributionPreference.getUsername(), username);
dynamicDistributionPreference.setUsername(username);
dynamicDistributionPreference.save();
loadRepositorySetupGroup();
isComplete();
if (changed) {
reloadDynamicDistributions();
}
}
}
} catch (Throwable e) {
ExceptionHandler.process(e);
String message = e.getMessage();
if (StringUtils.isEmpty(message)) {
// $NON-NLS-1$
message = Messages.getString("ExceptionDialog.message.empty");
}
// $NON-NLS-1$
ExceptionMessageDialog.openError(getShell(), Messages.getString("ExceptionDialog.title"), message, e);
}
return super.performDefaults();
}
use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method performApply.
@Override
public boolean performApply() {
boolean isReadonly = isReadonly();
if (isReadonly) {
return super.performApply();
}
try {
IDynamicDistributionsGroup selectedSetupDynamicDistriGroup = getSelectedSetupDynamicDistriGroup();
if (selectedSetupDynamicDistriGroup != null) {
IDynamicDistributionPreference dynamicDistributionPreference = selectedSetupDynamicDistriGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
if (dynamicDistributionPreference != null) {
boolean changed = false;
boolean isAnonymous = anonymousBtn.getSelection();
changed = changed || dynamicDistributionPreference.isAnonymous() != isAnonymous;
dynamicDistributionPreference.setAnonymous(isAnonymous);
boolean overrideDefaultSetup = overrideDefaultSetupBtn.getSelection();
changed = changed || dynamicDistributionPreference.overrideDefaultSetup() != overrideDefaultSetup;
dynamicDistributionPreference.setOverrideDefaultSetup(overrideDefaultSetup);
String password = passwordText.getText();
changed = changed || !StringUtils.equals(dynamicDistributionPreference.getPassword(), password);
dynamicDistributionPreference.setPassword(password);
String repository = repositoryText.getText();
changed = changed || !StringUtils.equals(dynamicDistributionPreference.getRepository(), repository);
dynamicDistributionPreference.setRepository(repository);
String username = userText.getText();
changed = changed || !StringUtils.equals(dynamicDistributionPreference.getUsername(), username);
dynamicDistributionPreference.setUsername(username);
dynamicDistributionPreference.save();
isComplete();
if (changed) {
reloadDynamicDistributions();
}
}
}
} catch (Throwable e) {
ExceptionHandler.process(e);
String message = e.getMessage();
if (StringUtils.isEmpty(message)) {
// $NON-NLS-1$
message = Messages.getString("ExceptionDialog.message.empty");
}
// $NON-NLS-1$
ExceptionMessageDialog.openError(getShell(), Messages.getString("ExceptionDialog.title"), message, e);
}
return super.performApply();
}
Aggregations