mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 20:45:22 +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) - [175680] Deprecate obsolete ISystemRegistry methods
|
||||||
* Martin Oberhuber (Wind River) - [160293] NPE on startup when only Core feature is installed
|
* 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
|
* 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;
|
package org.eclipse.rse.core;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Vector;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||||
|
@ -282,21 +284,19 @@ public class RSECorePlugin extends Plugin {
|
||||||
IConfigurationElement[] factoryPlugins = getSubSystemConfigurationPlugins();
|
IConfigurationElement[] factoryPlugins = getSubSystemConfigurationPlugins();
|
||||||
if (factoryPlugins != null)
|
if (factoryPlugins != null)
|
||||||
{
|
{
|
||||||
Vector v = new Vector();
|
List l = new ArrayList();
|
||||||
for (int idx=0; idx<factoryPlugins.length; idx++)
|
for (int idx=0; idx<factoryPlugins.length; idx++)
|
||||||
{
|
{
|
||||||
SubSystemConfigurationProxy ssf =
|
SubSystemConfigurationProxy ssf =
|
||||||
new SubSystemConfigurationProxy(factoryPlugins[idx]);
|
new SubSystemConfigurationProxy(factoryPlugins[idx]);
|
||||||
|
|
||||||
v.addElement(ssf);
|
l.add(ssf);
|
||||||
}
|
|
||||||
if (v.size() != 0)
|
|
||||||
{
|
|
||||||
_subsystemConfigurations = new ISubSystemConfigurationProxy[v.size()];
|
|
||||||
for (int idx=0; idx<v.size(); idx++)
|
|
||||||
_subsystemConfigurations[idx] = (ISubSystemConfigurationProxy)v.elementAt(idx);
|
|
||||||
}
|
}
|
||||||
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;
|
return _subsystemConfigurations;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* 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;
|
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)
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Object o1, Object o2) {
|
||||||
|
@ -36,14 +37,11 @@ public class SubSystemConfigurationProxyComparator implements Comparator {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (proxy1.getPriority() > proxy2.getPriority()) {
|
else if (proxy1.getPriority() > proxy2.getPriority()) {
|
||||||
return 1;
|
return +1;
|
||||||
}
|
} else {
|
||||||
else {
|
return proxy1.getId().compareTo(proxy2.getId());
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
package org.eclipse.rse.ui.internal.model;
|
package org.eclipse.rse.ui.internal.model;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
@ -255,29 +254,17 @@ public class SystemRegistry implements ISystemRegistry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private method used by RSEUIPlugin to tell registry all registered subsystem
|
* 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
|
* factories. This way, all code can use this registry to access them versus the
|
||||||
* RSEUIPlugin.
|
* 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)
|
public void setSubSystemConfigurationProxies(ISubSystemConfigurationProxy[] proxies)
|
||||||
{
|
{
|
||||||
//[165674]: Sort proxies by ID in order to get deterministic results
|
subsystemConfigurationProxies = proxies;
|
||||||
//on all getSubSystemConfiguration*() queries
|
//for (int idx=0; idx<proxies.length; idx++)
|
||||||
ISubSystemConfigurationProxy[] newProxies = (ISubSystemConfigurationProxy[])proxies.clone();
|
// proxies[idx].setLogFile(logFile);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Public method to retrieve list of subsystem factory proxies registered by extension points.
|
* Public method to retrieve list of subsystem factory proxies registered by extension points.
|
||||||
|
|
Loading…
Add table
Reference in a new issue