Search in sources :

Example 1 with DynamicPluginComparator

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);
    }
}
Also used : IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DynamicPluginComparator(org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) LinkedList(java.util.LinkedList)

Example 2 with DynamicPluginComparator

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;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DynamicPluginComparator(org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)2 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)2 DynamicPluginComparator (org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)1