]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network.ui/src/org/simantics/district/network/ui/internal/Activator.java
e0e7b47564f917a7ca416eda8286cd0d896e3f44
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / internal / Activator.java
1 package org.simantics.district.network.ui.internal;
2
3 import org.osgi.framework.BundleActivator;
4 import org.osgi.framework.BundleContext;
5 import org.osgi.util.tracker.ServiceTracker;
6 import org.simantics.district.network.ui.breakdown.SubgraphProvider;
7
8 public class Activator implements BundleActivator {
9
10     public static final String PLUGIN_ID = "org.simantics.district.network.ui";
11     private static Activator instance;
12     private static BundleContext context;
13     private ServiceTracker<SubgraphProvider, SubgraphProvider> subgraphProviderTracker;
14
15     @Override
16     public void start(BundleContext context) throws Exception {
17         Activator.instance = this;
18         Activator.context = context;
19
20         subgraphProviderTracker = new ServiceTracker<>(context, SubgraphProvider.class.getName(), null);
21         subgraphProviderTracker.open();
22     }
23
24     @Override
25     public void stop(BundleContext context) throws Exception {
26         subgraphProviderTracker.close();
27
28         Activator.instance = null;
29         Activator.context = null;
30     }
31
32     public static Activator getInstance() {
33         return instance;
34     }
35
36     public static BundleContext getContext() {
37         return context;
38     }
39
40     public SubgraphProvider[] getSubgraphProviders() {
41         return subgraphProviderTracker.getServices(new SubgraphProvider[0]);
42     }
43
44 }