Skip to content

Commit

Permalink
[#1370] Operator fails on startup
Browse files Browse the repository at this point in the history
Rework components back to v1.1.0
  • Loading branch information
ruspl-afed authored and eparovyshnaya committed May 23, 2024
1 parent 2e902c1 commit 98333a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor">
<property name="org.eclipse.passage.lic.emf.edit.domain.name" value="features"/>
<service>
<provide interface="org.eclipse.passage.loc.internal.emf.SelectionCommandAdvisor"/>
</service>
<reference cardinality="1..1" field="registry" interface="org.eclipse.passage.loc.internal.features.FeatureRegistry" name="registry"/>
<reference bind="bindFeatures" cardinality="1..1" interface="org.eclipse.passage.loc.internal.features.FeatureRegistry" name="Features" unbind="unbindFeatures"/>
<implementation class="org.eclipse.passage.loc.internal.features.core.FeaturesSelectionCommandAdvisor"/>
</scr:component>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<FeatureRegistry> 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) {
Expand All @@ -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();
}

}

0 comments on commit 98333a1

Please sign in to comment.