1 package org.simantics.district.network.ui.internal;
3 import org.eclipse.ui.plugin.AbstractUIPlugin;
4 import org.osgi.framework.BundleContext;
5 import org.osgi.util.tracker.ServiceTracker;
6 import org.simantics.district.network.ui.breakdown.SubgraphProvider;
7 import org.simantics.district.route.RouteService;
9 public class Activator extends AbstractUIPlugin {
11 public static final String PLUGIN_ID = "org.simantics.district.network.ui";
13 private static Activator instance;
14 private static BundleContext context;
16 private ServiceTracker<SubgraphProvider, SubgraphProvider> subgraphProviderTracker;
17 private ServiceTracker<RouteService, RouteService> routeServiceTracker;
20 public void start(BundleContext context) throws Exception {
21 Activator.instance = this;
22 Activator.context = context;
24 subgraphProviderTracker = new ServiceTracker<>(context, SubgraphProvider.class.getName(), null);
25 subgraphProviderTracker.open();
26 routeServiceTracker = new ServiceTracker<>(context, RouteService.class.getName(), null);
27 routeServiceTracker.open();
31 public void stop(BundleContext context) throws Exception {
32 subgraphProviderTracker.close();
33 routeServiceTracker.close();
35 Activator.instance = null;
36 Activator.context = null;
39 public static Activator getInstance() {
43 public static BundleContext getContext() {
47 public SubgraphProvider[] getSubgraphProviders() {
48 return subgraphProviderTracker.getServices(new SubgraphProvider[0]);
51 public RouteService getRouteService() {
52 return routeServiceTracker.getService();