]> gerrit.simantics Code Review - simantics/3d.git/blob - dev/org.simantics.proconf.g3d.occ/src/org/simantics/proconf/g3d/occ/Activator.java
Release
[simantics/3d.git] / dev / org.simantics.proconf.g3d.occ / src / org / simantics / proconf / g3d / occ / Activator.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.occ;\r
12 \r
13 import org.eclipse.ui.plugin.AbstractUIPlugin;\r
14 import org.osgi.framework.BundleContext;\r
15 import org.simantics.proconf.g3d.csg.stubs.CSGResource;\r
16 import org.simantics.db.Graph;\r
17 import org.simantics.db.GraphRequestAdapter;\r
18 import org.simantics.db.GraphRequestStatus;\r
19 import org.simantics.proconf.g3d.stubs.G3DResource;\r
20 import org.simantics.proconf.ui.ProConfUI;\r
21 \r
22 /**\r
23  * The activator class controls the plug-in life cycle\r
24  */\r
25 public class Activator extends AbstractUIPlugin {\r
26 \r
27         // The plug-in ID\r
28         public static final String PLUGIN_ID = "org.simantics.proconf.g3d.occ";\r
29 \r
30         // The shared instance\r
31         private static Activator plugin;\r
32         \r
33         /**\r
34          * The constructor\r
35          */\r
36         public Activator() {\r
37         }\r
38 \r
39         /*\r
40          * (non-Javadoc)\r
41          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
42          */\r
43         public void start(BundleContext context) throws Exception {\r
44                 super.start(context);\r
45                 plugin = this;\r
46                 \r
47                 ProConfUI.getSession().syncRead(new GraphRequestAdapter() {\r
48                         @Override\r
49                         public GraphRequestStatus perform(Graph g) throws Exception {\r
50                                 OccResources.csgResource = CSGResource.getInstance(g);\r
51                                 OccResources.g3dResource = G3DResource.getInstance(g);\r
52                                 return GraphRequestStatus.transactionComplete();\r
53                         }\r
54                 });\r
55         }\r
56 \r
57         /*\r
58          * (non-Javadoc)\r
59          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
60          */\r
61         public void stop(BundleContext context) throws Exception {\r
62                 plugin = null;\r
63                 super.stop(context);\r
64         }\r
65 \r
66         /**\r
67          * Returns the shared instance\r
68          *\r
69          * @return the shared instance\r
70          */\r
71         public static Activator getDefault() {\r
72                 return plugin;\r
73         }\r
74 \r
75 }\r