]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/internal/Activator.java
Disconnected subgraph analysis for district network diagrams
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / internal / Activator.java
index 977fe30c670ec13fd6d1c179faff03716c20befa..e0e7b47564f917a7ca416eda8286cd0d896e3f44 100644 (file)
@@ -2,24 +2,43 @@ package org.simantics.district.network.ui.internal;
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.simantics.district.network.ui.breakdown.SubgraphProvider;
 
 public class Activator implements BundleActivator {
 
     public static final String PLUGIN_ID = "org.simantics.district.network.ui";
+    private static Activator instance;
     private static BundleContext context;
+    private ServiceTracker<SubgraphProvider, SubgraphProvider> subgraphProviderTracker;
 
     @Override
     public void start(BundleContext context) throws Exception {
+        Activator.instance = this;
         Activator.context = context;
+
+        subgraphProviderTracker = new ServiceTracker<>(context, SubgraphProvider.class.getName(), null);
+        subgraphProviderTracker.open();
     }
 
     @Override
     public void stop(BundleContext context) throws Exception {
+        subgraphProviderTracker.close();
+
+        Activator.instance = null;
         Activator.context = null;
     }
-    
+
+    public static Activator getInstance() {
+        return instance;
+    }
+
     public static BundleContext getContext() {
         return context;
     }
 
+    public SubgraphProvider[] getSubgraphProviders() {
+        return subgraphProviderTracker.getServices(new SubgraphProvider[0]);
+    }
+
 }