diff options
author | DJ Houghton | 2010-05-18 16:14:20 +0000 |
---|---|---|
committer | DJ Houghton | 2010-05-18 16:14:20 +0000 |
commit | 73af8433dfe36f141873f4634a37c0132a941485 (patch) | |
tree | 9363d2cf5631a9715aa1a0be2725f05f87558105 /bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director | |
parent | fe4c5acc4103663ed8ffbfb2ae156ef887883a1c (diff) | |
download | rt.equinox.p2-73af8433dfe36f141873f4634a37c0132a941485.tar.gz rt.equinox.p2-73af8433dfe36f141873f4634a37c0132a941485.tar.xz rt.equinox.p2-73af8433dfe36f141873f4634a37c0132a941485.zip |
Bug 312668 - [director] Only single IU Fragments are attached to IUs
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java index b8090b9be..fc60f0d16 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java @@ -18,7 +18,7 @@ public class AttachmentHelper { private static final IInstallableUnitFragment[] NO_FRAGMENTS = new IInstallableUnitFragment[0]; public static Collection<IInstallableUnit> attachFragments(Iterator<IInstallableUnit> toAttach, Map<IInstallableUnitFragment, List<IInstallableUnit>> fragmentsToIUs) { - Map<IInstallableUnit, IInstallableUnitFragment> fragmentBindings = new HashMap<IInstallableUnit, IInstallableUnitFragment>(); + Map<IInstallableUnit, IInstallableUnitFragment[]> fragmentBindings = new HashMap<IInstallableUnit, IInstallableUnitFragment[]>(); //Build a map inverse of the one provided in input (host --> List of fragments) Map<IInstallableUnit, List<IInstallableUnitFragment>> iusToFragment = new HashMap<IInstallableUnit, List<IInstallableUnitFragment>>(fragmentsToIUs.size()); for (Map.Entry<IInstallableUnitFragment, List<IInstallableUnit>> mapping : fragmentsToIUs.entrySet()) { @@ -65,14 +65,21 @@ public class AttachmentHelper { IInstallableUnitFragment theFragment = null; int specificityLevel = 0; + LinkedList<IInstallableUnitFragment> fragments = new LinkedList<IInstallableUnitFragment>(); for (IInstallableUnitFragment fragment : applicableFragments) { + if (isTranslation(fragment)) { + fragments.add(fragment); + continue; + } if (fragment.getHost().size() > specificityLevel) { theFragment = fragment; specificityLevel = fragment.getHost().size(); } } if (theFragment != null) - fragmentBindings.put(hostIU, theFragment); + fragments.addFirst(theFragment); + if (!fragments.isEmpty()) + fragmentBindings.put(hostIU, fragments.toArray(new IInstallableUnitFragment[fragments.size()])); } //build the collection of resolved IUs Collection<IInstallableUnit> result = new HashSet<IInstallableUnit>(); @@ -86,14 +93,20 @@ public class AttachmentHelper { continue; } //return a new IU that combines the IU with its bound fragments - IInstallableUnitFragment fragment = fragmentBindings.get(iu); - IInstallableUnitFragment[] fragments; - if (fragment == null) + IInstallableUnitFragment[] fragments = fragmentBindings.get(iu); + if (fragments == null) fragments = NO_FRAGMENTS; - else - fragments = new IInstallableUnitFragment[] {fragment}; result.add(MetadataFactory.createResolvedInstallableUnit(iu, fragments)); } return result; } + + private static boolean isTranslation(IInstallableUnitFragment fragment) { + for (IProvidedCapability capability : fragment.getProvidedCapabilities()) { + // TODO make the constant in the TranslationSupport class public and use it + if ("org.eclipse.equinox.p2.localization".equals(capability.getNamespace())) //$NON-NLS-1$ + return true; + } + return false; + } } |