1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.equation;
14 import org.eclipse.ui.plugin.AbstractUIPlugin;
15 import org.osgi.framework.BundleContext;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.common.request.ReadRequest;
18 import org.simantics.db.management.ISessionContext;
19 import org.simantics.db.management.ISessionContextChangedListener;
20 import org.simantics.db.management.SessionContextChangedEvent;
21 import org.simantics.ui.SimanticsUI;
24 * The activator class controls the plug-in life cycle
26 public class Activator extends AbstractUIPlugin {
29 public static final String PLUGIN_ID = "org.simantics.equation";
31 // The shared instance
32 private static Activator plugin;
42 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
44 public void start(BundleContext context) throws Exception {
48 SimanticsUI.getSessionContextProvider().addContextChangedListener(new ISessionContextChangedListener() {
50 public void sessionContextChanged(SessionContextChangedEvent event) {
51 ISessionContext ctx = event.getNewValue();
53 ctx.getSession().asyncRequest(new ReadRequest() {
55 public void run(ReadGraph g) {
56 EquationResources.initialize(g);
60 EquationResources.deinitialize();
66 SimanticsUI.getSession().syncRequest(new ReadRequest() {
68 public void run(ReadGraph g) {
69 EquationResources.initialize(g);
72 } catch (Exception e) {
81 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
83 public void stop(BundleContext context) throws Exception {
89 * Returns the shared instance
91 * @return the shared instance
93 public static Activator getDefault() {