use of org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator 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.comparator.DynamicPluginComparator in project tbd-studio-se by Talend.
the class DynamicDistributionOptionForm method copyAllUsersDynamicPlugins.
private List<IDynamicPlugin> copyAllUsersDynamicPlugins(IDynamicMonitor monitor, IDynamicDistributionsGroup dynamicDistributionsGroup) throws Exception {
List<IDynamicPlugin> distriDynamicPlugins = new LinkedList<>();
/**
* Can't edit builtin plugins
*/
allBuiltinDynamicPlugins = dynamicDistributionsGroup.getAllBuiltinDynamicPlugins(monitor);
if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
distriDynamicPlugins.addAll(allBuiltinDynamicPlugins);
}
// List<IDynamicPlugin> allUsersDynamicPlugins = DynamicDistributionManager.getInstance()
// .getAllUsersDynamicPluginsForProject(ProjectManager.getInstance().getCurrentProject(), monitor);
List<IDynamicPlugin> allUsersDynamicPlugins = DynamicDistributionManager.getInstance().getAllUsersDynamicPlugins(monitor);
if (allUsersDynamicPlugins != null && !allUsersDynamicPlugins.isEmpty()) {
List<IDynamicPlugin> filterDynamicPlugins = dynamicDistributionsGroup.filterDynamicPlugins(allUsersDynamicPlugins, monitor);
if (filterDynamicPlugins != null && !filterDynamicPlugins.isEmpty()) {
for (IDynamicPlugin dynPlugin : filterDynamicPlugins) {
IDynamicPlugin clonedPlugin = DynamicFactory.getInstance().createPluginFromJson(dynPlugin.toXmlJson().toString());
distriDynamicPlugins.add(clonedPlugin);
}
}
}
allCurrentUsersDynamicPlugins = allUsersDynamicPlugins;
Collections.sort(distriDynamicPlugins, Collections.reverseOrder(new DynamicPluginComparator()));
return distriDynamicPlugins;
}
Aggregations