use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method refreshVersionList.
private void refreshVersionList(IDynamicMonitor monitor) {
try {
IStructuredSelection selection = (IStructuredSelection) distributionCombo.getSelection();
if (selection != null) {
String selectedObject = (String) selection.getFirstElement();
if (selectedObject != null) {
IDynamicDistributionsGroup dynDistriGroup = DynamicDistributionManager.getInstance().getDynamicDistributionGroup(selectedObject);
if (dynDistriGroup == null) {
throw new Exception(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistributionPreferenceForm.exception.noDistributionGroupFound", dynDistriGroup));
}
List<IDynamicPlugin> dynamicPlugins = new LinkedList<>();
List<IDynamicPlugin> allBuiltinDynamicPlugins = dynDistriGroup.getAllBuiltinDynamicPlugins(monitor);
if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
dynamicPlugins.addAll(allBuiltinDynamicPlugins);
}
List<IDynamicPlugin> allUsersDynamicPlugins = DynamicDistributionManager.getInstance().getAllUsersDynamicPlugins(monitor);
if (allUsersDynamicPlugins != null && !allUsersDynamicPlugins.isEmpty()) {
List<IDynamicPlugin> tempDynamicPlugins = dynDistriGroup.filterDynamicPlugins(allUsersDynamicPlugins, monitor);
if (tempDynamicPlugins != null && !tempDynamicPlugins.isEmpty()) {
dynamicPlugins.addAll(tempDynamicPlugins);
}
}
Collections.sort(dynamicPlugins, Collections.reverseOrder(new DynamicPluginComparator()));
versionCombo.setInput(dynamicPlugins);
if (!dynamicPlugins.isEmpty()) {
versionCombo.setSelection(new StructuredSelection(dynamicPlugins.get(0)));
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method doDelete.
private void doDelete(IDynamicPlugin dynamicPlugin) throws Throwable {
final Throwable[] throwable = new Throwable[1];
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell());
progressDialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor pMonitor) throws InvocationTargetException, InterruptedException {
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(new RepositoryWorkUnit<Boolean>(// $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.form.deleteExistingConfig.workunit.title")) {
@Override
protected void run() throws LoginException, PersistenceException {
IDynamicMonitor monitor = new AbsDynamicProgressMonitor(pMonitor) {
@Override
public void writeMessage(String message) {
// nothing to do
}
};
try {
IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
monitor.beginTask(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistributionPreferenceForm.delete.progress.unregist", pluginConfiguration.getName()), IDynamicMonitor.UNKNOWN);
String distribution = pluginConfiguration.getDistribution();
IDynamicDistributionsGroup dynamicDistributionGroup = DynamicDistributionManager.getInstance().getDynamicDistributionGroup(distribution);
dynamicDistributionGroup.unregister(dynamicPlugin, monitor, false);
monitor.setTaskName(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistributionPreferenceForm.delete.progress.deleteFile", pluginConfiguration.getName()));
String filePath = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_FILE_PATH);
File file = new File(filePath);
file.delete();
monitor.setTaskName(// $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.delete.progress.resetCache"));
DynamicDistributionManager.getInstance().resetSystemCache();
} catch (Throwable e) {
throwable[0] = e;
}
}
});
}
});
if (throwable[0] != null) {
throw throwable[0];
}
}
use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method addListeners.
private void addListeners() {
if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
distributionCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
refreshVersionList(new DummyDynamicMonitor());
updateButtons();
}
});
versionCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateButtons();
}
});
buildConfigBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
IStructuredSelection selection = (IStructuredSelection) distributionCombo.getSelection();
if (selection == null) {
ExceptionHandler.process(new Exception(// $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.exception.noDistributionSelected")));
return;
}
String distribution = (String) selection.getFirstElement();
if (distribution == null) {
ExceptionHandler.process(new Exception(// $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.exception.noDistributionSelected")));
return;
}
IDynamicDistributionsGroup dynamicDistributionsGroup = DynamicDistributionManager.getInstance().getDynamicDistributionGroup(distribution);
DynamicDistributionSetupData configData = new DynamicDistributionSetupData();
configData.setDynamicDistributionsGroup(dynamicDistributionsGroup);
DynamicDistributionSetupWizard wizard = new DynamicDistributionSetupWizard(configData);
WizardDialog wizardDialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
wizardDialog.setMinimumPageSize(600, 400);
wizardDialog.create();
if (wizardDialog.open() == IDialogConstants.OK_ID) {
// nothing to do
}
IDynamicMonitor monitor = new DummyDynamicMonitor();
refreshVersionList(monitor);
} catch (Throwable ex) {
ExceptionHandler.process(ex);
}
updateButtons();
}
});
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
onDeleteBtnPressed();
updateButtons();
}
});
} else {
setupDistriCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
try {
loadRepositorySetupGroup();
} catch (Exception e) {
ExceptionHandler.process(e);
}
updateButtons();
}
});
overrideDefaultSetupBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
}
});
repositoryText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String newRepositoryText = repositoryText.getText();
if (StringUtils.equals(newRepositoryText, repositoryUrlCache)) {
return;
}
repositoryUrlCache = newRepositoryText;
updateButtons();
}
});
anonymousBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
}
});
userText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String newUsername = userText.getText();
if (StringUtils.equals(newUsername, usernameCache)) {
return;
}
usernameCache = newUsername;
updateButtons();
}
});
passwordText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String newPassword = passwordText.getText();
if (StringUtils.equals(newPassword, passwordCache)) {
return;
}
passwordCache = newPassword;
updateButtons();
}
});
checkConnectionBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!isComplete()) {
return;
}
TypedReturnCode tc = new TypedReturnCode();
try {
IDynamicDistributionsGroup distriGroup = getSelectedSetupDynamicDistriGroup();
DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
dynamicConfiguration.setDistribution(distriGroup.getDistribution());
IDependencyResolver dependencyResolver = distriGroup.getDependencyResolver(dynamicConfiguration);
tc = dependencyResolver.checkConnection(repositoryText.getText(), userText.getText(), passwordText.getText());
} catch (Exception e1) {
ExceptionHandler.process(e1);
tc.setOk(false);
tc.setMessage(e1.getMessage());
}
showCheckConnectionInformation(true, tc);
}
});
}
}
use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup in project tbd-studio-se by Talend.
the class DynamicDistributionOptionForm method initData.
private void initData(IDynamicMonitor monitor) {
try {
namePluginMap = getNamePluginMap();
getDynamicDistributionSetupData().setNamePluginMap(namePluginMap);
} catch (Exception e) {
ExceptionHandler.process(e);
}
DynamicDistributionSetupData dynConfigData = getDynamicDistributionSetupData();
IDynamicDistributionsGroup dynamicDistributionsGroup = dynConfigData.getDynamicDistributionsGroup();
dynamicConfiguration = new DynamicConfiguration();
dynamicConfiguration.setDistribution(dynamicDistributionsGroup.getDistribution());
try {
refreshExistingConfigsCombo(monitor, dynamicDistributionsGroup);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup 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();
}
Aggregations