use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup 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();
}
use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method loadData.
private void loadData(IDynamicMonitor monitor) {
try {
DynamicDistributionManager dynDistriManager = DynamicDistributionManager.getInstance();
List<IDynamicDistributionsGroup> dynDistriGroups = dynDistriManager.getDynamicDistributionsGroups();
if (dynDistriGroups != null && !dynDistriGroups.isEmpty()) {
List<String> distributionDisplayNames = new ArrayList<>();
for (IDynamicDistributionsGroup dynDistriGroup : dynDistriGroups) {
String displayName = dynDistriGroup.getDistributionDisplay();
distributionDisplayNames.add(displayName);
}
Collections.sort(distributionDisplayNames);
if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
distributionCombo.setInput(distributionDisplayNames);
} else {
setupDistriCombo.setInput(distributionDisplayNames);
}
if (0 < distributionDisplayNames.size()) {
if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
distributionCombo.setSelection(new StructuredSelection(distributionDisplayNames.get(0)));
refreshVersionList(monitor);
} else {
setupDistriCombo.setSelection(new StructuredSelection(distributionDisplayNames.get(0)));
}
}
}
if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING != showPart) {
loadRepositorySetupGroup();
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup in project tbd-studio-se by Talend.
the class DynamicDistributionOptionForm method checkNewConfig.
private boolean checkNewConfig() {
try {
if (!newConfigBtn.getSelection()) {
return true;
}
versionsComboViewer.getControl().setEnabled(false);
List<String> versionList = (List<String>) versionsComboViewer.getInput();
if (versionList == null || versionList.isEmpty()) {
String errorMessage = // $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistributionOptionForm.newConfig.check.empty", refreshButton.getText());
showMessage(errorMessage, WizardPage.ERROR);
return false;
}
// $NON-NLS-1$
String selectedVersion = "";
IStructuredSelection selection = (IStructuredSelection) versionsComboViewer.getSelection();
if (selection != null) {
selectedVersion = (String) selection.getFirstElement();
}
if (StringUtils.isEmpty(selectedVersion)) {
String errorMessage = // $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistributionOptionForm.newConfig.check.empty", refreshButton.getText());
showMessage(errorMessage, WizardPage.ERROR);
return false;
}
versionsComboViewer.getControl().setEnabled(true);
DynamicDistributionSetupData dynamicBuildConfigurationData = getDynamicDistributionSetupData();
IDynamicDistributionsGroup dynamicDistributionsGroup = dynamicBuildConfigurationData.getDynamicDistributionsGroup();
String versionName = dynamicDistributionsGroup.generateVersionName(selectedVersion);
if (dynamicBuildConfigurationData.getNamePluginMap().containsKey(versionName)) {
String errorMessage = // $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistributionOptionForm.newConfig.check.nameExist", // $NON-NLS-1$
versionName, editExistingConfigBtn.getText());
showMessage(errorMessage, WizardPage.ERROR);
return false;
}
String versionId = dynamicDistributionsGroup.generateVersionId(selectedVersion);
versionId = DynamicDistributionUtils.appendTimestamp(versionId);
dynamicConfiguration.setId(versionId);
dynamicConfiguration.setName(versionName);
dynamicConfiguration.setVersion(selectedVersion);
if (!checkSparkVersonSelection()) {
return false;
}
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
return false;
}
}
Aggregations