mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[165674] Sort subsystem configurations by priority then Id
This commit is contained in:
parent
a536024f44
commit
4792c8bb08
3 changed files with 24 additions and 39 deletions
|
@ -18,13 +18,15 @@
|
|||
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
|
||||
* Martin Oberhuber (Wind River) - [160293] NPE on startup when only Core feature is installed
|
||||
* Uwe Stieber (Wind River) - [192611] RSE Core plugin may fail to initialize because of cyclic code invocation
|
||||
* Martin Oberhuber (Wind River) - [165674] Sort subsystem configurations by priority then Id
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.core;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Vector;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
|
@ -282,21 +284,19 @@ public class RSECorePlugin extends Plugin {
|
|||
IConfigurationElement[] factoryPlugins = getSubSystemConfigurationPlugins();
|
||||
if (factoryPlugins != null)
|
||||
{
|
||||
Vector v = new Vector();
|
||||
List l = new ArrayList();
|
||||
for (int idx=0; idx<factoryPlugins.length; idx++)
|
||||
{
|
||||
SubSystemConfigurationProxy ssf =
|
||||
new SubSystemConfigurationProxy(factoryPlugins[idx]);
|
||||
|
||||
v.addElement(ssf);
|
||||
}
|
||||
if (v.size() != 0)
|
||||
{
|
||||
_subsystemConfigurations = new ISubSystemConfigurationProxy[v.size()];
|
||||
for (int idx=0; idx<v.size(); idx++)
|
||||
_subsystemConfigurations[idx] = (ISubSystemConfigurationProxy)v.elementAt(idx);
|
||||
l.add(ssf);
|
||||
}
|
||||
Arrays.sort(_subsystemConfigurations, new SubSystemConfigurationProxyComparator());
|
||||
ISubSystemConfigurationProxy[] newProxies = (ISubSystemConfigurationProxy[])l.toArray(new ISubSystemConfigurationProxy[l.size()]);
|
||||
//[149280][165674]: Sort proxies by priority then ID in order to
|
||||
//get deterministic results on all getSubSystemConfiguration*() queries
|
||||
Arrays.sort(newProxies, new SubSystemConfigurationProxyComparator());
|
||||
_subsystemConfigurations = newProxies;
|
||||
}
|
||||
|
||||
return _subsystemConfigurations;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - [165674] Sort subsystem configurations by priority then Id
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.core.subsystems;
|
||||
|
||||
|
@ -23,7 +24,7 @@ public class SubSystemConfigurationProxyComparator implements Comparator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compares priorities of subsystem configuration proxies.
|
||||
* Compares subsystem configuration proxies by Priority, then Id.
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare(Object o1, Object o2) {
|
||||
|
@ -36,14 +37,11 @@ public class SubSystemConfigurationProxyComparator implements Comparator {
|
|||
return -1;
|
||||
}
|
||||
else if (proxy1.getPriority() > proxy2.getPriority()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return +1;
|
||||
} else {
|
||||
return proxy1.getId().compareTo(proxy2.getId());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
package org.eclipse.rse.ui.internal.model;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
@ -255,29 +254,17 @@ public class SystemRegistry implements ISystemRegistry
|
|||
|
||||
/**
|
||||
* Private method used by RSEUIPlugin to tell registry all registered subsystem
|
||||
* factories. This way, all code can use this registry to access them versus the
|
||||
* RSEUIPlugin.
|
||||
* factories. This way, all code can use this registry to access them versus the
|
||||
* RSEUIPlugin.
|
||||
*
|
||||
* Proxies must be set sorted by priority, then ID in order to get deterministic
|
||||
* results for all getSubSystemConfiguration*() queries.
|
||||
*/
|
||||
public void setSubSystemConfigurationProxies(ISubSystemConfigurationProxy[] proxies)
|
||||
{
|
||||
//[165674]: Sort proxies by ID in order to get deterministic results
|
||||
//on all getSubSystemConfiguration*() queries
|
||||
ISubSystemConfigurationProxy[] newProxies = (ISubSystemConfigurationProxy[])proxies.clone();
|
||||
Arrays.sort(newProxies, new Comparator(){
|
||||
public int compare(Object o1, Object o2) {
|
||||
ISubSystemConfigurationProxy s1 = (ISubSystemConfigurationProxy)o1;
|
||||
ISubSystemConfigurationProxy s2 = (ISubSystemConfigurationProxy)o2;
|
||||
if (s1.getPriority() < s2.getPriority()) {
|
||||
return -1;
|
||||
} else if (s1.getPriority() > s2.getPriority()) {
|
||||
return +1;
|
||||
}
|
||||
return s1.getId().compareTo(s2.getId());
|
||||
}
|
||||
});
|
||||
//for (int idx=0; idx<newProxies.length; idx++)
|
||||
// newProxies[idx].setLogFile(logFile);
|
||||
subsystemConfigurationProxies = newProxies;
|
||||
subsystemConfigurationProxies = proxies;
|
||||
//for (int idx=0; idx<proxies.length; idx++)
|
||||
// proxies[idx].setLogFile(logFile);
|
||||
}
|
||||
/**
|
||||
* Public method to retrieve list of subsystem factory proxies registered by extension points.
|
||||
|
|
Loading…
Add table
Reference in a new issue