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.graphviz;
15 import java.io.IOException;
17 import java.net.URLDecoder;
19 import org.eclipse.core.runtime.FileLocator;
20 import org.eclipse.core.runtime.Plugin;
21 import org.osgi.framework.Bundle;
22 import org.osgi.framework.BundleContext;
25 * The activator class controls the plug-in life cycle
27 * @author Hannu Niemistö
29 public class Activator extends Plugin {
32 public static final String PLUGIN_ID = "org.simantics.graphviz";
34 // The shared instance
35 private static Activator plugin;
37 // private File stateDir;
38 private Bundle bundle;
45 * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
48 public void start(BundleContext context) throws Exception {
51 bundle = context.getBundle();
52 URL url = FileLocator.toFileURL(bundle.getEntry("dot"));
53 DOT_EXE = new File(url.getPath(), "dot.exe");
62 * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
65 public void stop(BundleContext context) throws Exception {
71 * Returns the shared instance
73 * @return the shared instance
75 public static Activator getDefault() {
79 public static File getDotExe() {
80 Activator activator = getDefault();
82 return activator.DOT_EXE;
85 URL path = Activator.class.getResource(".");
86 URL resource = new URL(path, "../../../../dot/dot.exe");
87 return new File(URLDecoder.decode(resource.getPath(), "UTF-8"));
88 } catch (IOException e) {