diff --git a/bundles/org.eclipse.passage.loc.features.core/OSGI-INF/org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor.xml b/bundles/org.eclipse.passage.loc.features.core/OSGI-INF/org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor.xml index 270c7c124..efb1f0703 100644 --- a/bundles/org.eclipse.passage.loc.features.core/OSGI-INF/org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor.xml +++ b/bundles/org.eclipse.passage.loc.features.core/OSGI-INF/org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor.xml @@ -1,9 +1,9 @@ - + - + \ No newline at end of file diff --git a/bundles/org.eclipse.passage.loc.features.core/src/org/eclipse/passage/loc/internal/features/core/FeaturesSelectionCommandAdvisor.java b/bundles/org.eclipse.passage.loc.features.core/src/org/eclipse/passage/loc/internal/features/core/FeaturesSelectionCommandAdvisor.java index f7d3b5c4c..a4f63b37e 100644 --- a/bundles/org.eclipse.passage.loc.features.core/src/org/eclipse/passage/loc/internal/features/core/FeaturesSelectionCommandAdvisor.java +++ b/bundles/org.eclipse.passage.loc.features.core/src/org/eclipse/passage/loc/internal/features/core/FeaturesSelectionCommandAdvisor.java @@ -12,7 +12,9 @@ *******************************************************************************/ package org.eclipse.passage.loc.internal.features.core; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; import org.eclipse.passage.lic.features.model.meta.FeaturesPackage; import org.eclipse.passage.loc.internal.emf.EditingDomainRegistryAccess; @@ -21,12 +23,21 @@ import org.eclipse.passage.loc.internal.features.core.i18n.FeaturesCoreMessages; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; @Component(property = { EditingDomainRegistryAccess.PROPERTY_DOMAIN_NAME + '=' + FeaturesPackage.eNAME }) public class FeaturesSelectionCommandAdvisor implements SelectionCommandAdvisor { - @Reference - private FeatureRegistry registry; + private final List features = new ArrayList<>(); + + @Reference(cardinality = ReferenceCardinality.MANDATORY) + public void bindFeatures(FeatureRegistry registry) { + this.features.add(registry); + } + + public void unbindFeatures(FeatureRegistry registry) { + this.features.remove(registry); + } @Override public String getSelectionTitle(String classifier) { @@ -44,19 +55,20 @@ public String getSelectionTitle(String classifier) { @Override public Iterable getSelectionInput(String classifier) { - if (registry == null) { - return Collections.emptyList(); - } if (FeaturesPackage.eINSTANCE.getFeatureSet().getName().equals(classifier)) { - return registry.featureSets(); + return features().featureSets(); } if (FeaturesPackage.eINSTANCE.getFeature().getName().equals(classifier)) { - return registry.features(); + return features().features(); } if (FeaturesPackage.eINSTANCE.getFeatureVersion().getName().equals(classifier)) { - return registry.featureVersions(); + return features().featureVersions(); } return Collections.emptyList(); } + private FeatureRegistry features() { + return features.stream().findAny().get(); + } + }