Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2010-08-18 20:15:13 -0400
committercbateman2010-08-18 20:15:13 -0400
commit720918a5c49c54e6d51d9445e346c0f734e4ef4c (patch)
treedf952ea6b09e73af5c4d35399b860aadecad2406
parentc07f85e146107e752c4fbf159a41f28474b4c04f (diff)
downloadwebtools.jsf-720918a5c49c54e6d51d9445e346c0f734e4ef4c.tar.gz
webtools.jsf-720918a5c49c54e6d51d9445e346c0f734e4ef4c.tar.xz
webtools.jsf-720918a5c49c54e6d51d9445e346c0f734e4ef4c.zip
[bug 316385] Give priority to non-JSF tools factory delegates if registered. In 3.3 we will improve the API to provide for this explicitly.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java40
1 files changed, 39 insertions, 1 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java
index 4dde2c0cf..2a88ad6c0 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java
@@ -15,6 +15,7 @@ package org.eclipse.jst.jsf.context;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -61,7 +62,44 @@ public abstract class AbstractDelegatingFactory implements IDelegatingFactory
{
if (isValidDelegate(delegate))
{
- _delegates.addIfAbsent(delegate);
+ synchronized(_delegates)
+ {
+ _delegates.addIfAbsent(delegate);
+ if (_delegates.size() > 1)
+ {
+ List<IAdaptable> delegates = new ArrayList<IAdaptable>(_delegates);
+
+ Collections.sort(delegates, new Comparator()
+ {
+ public int compare(Object delegate1, Object delegate2)
+ {
+ final Class<?> clazz1 = delegate1.getClass();
+ final Class<?> clazz2 = delegate2.getClass();
+
+ Package package1 = clazz1.getPackage();
+ Package package2 = clazz2.getPackage();
+ boolean package1IsOSS = package1.getName().startsWith("org.eclipse.jst"); //$NON-NLS-1$
+ boolean package2IsOSS = package2.getName().startsWith("org.eclipse.jst"); //$NON-NLS-1$
+
+ if (package1IsOSS && !package2IsOSS)
+ {
+ // sort the oss one after the non-oss one
+ return 1;
+ }
+ else if (!package1IsOSS && package2IsOSS)
+ {
+ return -1;
+ }
+
+ // otherwise they are either both oss or both non-oss, so just
+ // sort canonically by name.
+ return clazz1.getName().compareTo(clazz2.getName());
+ }
+ });
+ _delegates.clear();
+ _delegates.addAll(delegates);
+ }
+ }
}
}

Back to the top