X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Finternal%2FActivator.java;h=e0e7b47564f917a7ca416eda8286cd0d896e3f44;hb=404106a6a8c09ce3f320e8831894f4fe399662fc;hp=1e7a4d512fae8ba7216410f91c6adec6578416f9;hpb=a2e0d3dfba1245a13dcc8aa23c0188926e2a03c5;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/internal/Activator.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/internal/Activator.java index 1e7a4d51..e0e7b475 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/internal/Activator.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/internal/Activator.java @@ -1,18 +1,44 @@ -package org.simantics.district.network.ui.internal; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator implements BundleActivator { - - @Override - public void start(BundleContext context) throws Exception { - - } - - @Override - public void stop(BundleContext context) throws Exception { - - } - -} +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 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]); + } + +}