1 /*******************************************************************************
\r
2 * Copyright (c) 2007- VTT Technical Research Centre of Finland.
\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
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.proconf.g3d.shapeeditor;
\r
13 import org.eclipse.ui.plugin.AbstractUIPlugin;
\r
14 import org.osgi.framework.BundleContext;
\r
15 import org.simantics.db.Graph;
\r
16 import org.simantics.db.GraphRequestAdapter;
\r
17 import org.simantics.db.GraphRequestStatus;
\r
18 import org.simantics.db.management.ISessionContext;
\r
19 import org.simantics.db.management.ISessionContextChangedListener;
\r
20 import org.simantics.db.management.SessionContextChangedEvent;
\r
21 import org.simantics.proconf.ui.ProConfUI;
\r
24 * The activator class controls the plug-in life cycle
\r
26 public class Activator extends AbstractUIPlugin {
\r
29 public static final String PLUGIN_ID = "org.simantics.proconf.g3d.shapeeditor";
\r
31 // The shared instance
\r
32 private static Activator plugin;
\r
37 public Activator() {
\r
42 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
\r
44 public void start(BundleContext context) throws Exception {
\r
45 super.start(context);
\r
47 ProConfUI.getSessionContextProvider().addContextChangedListener(new ISessionContextChangedListener() {
\r
49 public void sessionContextChanged(SessionContextChangedEvent event) {
\r
50 ISessionContext ctx = event.getNewValue();
\r
52 ctx.getSession().asyncRead(new GraphRequestAdapter() {
\r
53 public GraphRequestStatus perform(Graph g) throws Exception {
\r
54 ShapeEditorResources.initialize(g);
\r
55 return GraphRequestStatus.transactionComplete();
\r
59 ShapeEditorResources.deinitialize();
\r
64 ProConfUI.getSession().asyncRead(new GraphRequestAdapter() {
\r
66 public GraphRequestStatus perform(Graph g) throws Exception {
\r
67 ShapeEditorResources.initialize(g);
\r
68 return GraphRequestStatus.transactionComplete();
\r
71 } catch (Exception e) {
\r
79 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
\r
81 public void stop(BundleContext context) throws Exception {
\r
83 super.stop(context);
\r
87 * Returns the shared instance
\r
89 * @return the shared instance
\r
91 public static Activator getDefault() {
\r