]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/internal/Activator.java
Fix CopyAdvisorUtil.copy2 to copy IsRelatedTo-statements left out before
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / internal / Activator.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.project.internal;
13
14 import java.util.Hashtable;
15
16 import org.eclipse.core.runtime.Plugin;
17 import org.osgi.framework.BundleContext;
18 import org.osgi.framework.ServiceRegistration;
19 import org.simantics.project.features.registry.IProjectFeatureRegistry;
20
21 /**
22  * @author Tuukka Lehtonen
23  */
24 public class Activator extends Plugin {
25
26     // The plug-in ID
27     public static final String     PLUGIN_ID                     = "org.simantics.project";
28
29     // The shared instance
30     private static Activator       plugin;
31
32     private BundleContext          bundleContext;
33
34     private ProjectFeatureRegistry projectFeatureRegistryService = null;
35     @SuppressWarnings("rawtypes")
36     private ServiceRegistration    projectFeatureRegistry        = null;
37
38     /**
39      * The constructor
40      */
41     public Activator() {
42     }
43
44     /*
45      * (non-Javadoc)
46      * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
47      */
48     @SuppressWarnings({ "unchecked", "rawtypes" })
49     @Override
50     public void start(BundleContext context) throws Exception {
51         super.start(context);
52         this.bundleContext = context;
53         plugin = this;
54
55         projectFeatureRegistryService = new ProjectFeatureRegistry();
56         projectFeatureRegistry = bundleContext.registerService(IProjectFeatureRegistry.class.getName(), projectFeatureRegistryService, new Hashtable());
57     }
58
59     /*
60      * (non-Javadoc)
61      * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
62      */
63     @Override
64     public void stop(BundleContext context) throws Exception {
65         if (projectFeatureRegistry != null) {
66             projectFeatureRegistry.unregister();
67             projectFeatureRegistry = null;
68         }
69
70         this.bundleContext = null;
71         plugin = null;
72         super.stop(context);
73     }
74
75     /**
76      * Returns the shared instance
77      *
78      * @return the shared instance
79      */
80     public static Activator getDefault() {
81         return plugin;
82     }
83
84     /**
85      * @return
86      */
87     public IProjectFeatureRegistry getProjectFeatureRegistry() {
88         return projectFeatureRegistryService;
89     }
90
91     public BundleContext getContext() {
92         return bundleContext;
93     }
94
95 }