1 package org.simantics.help.core;
\r
4 import java.nio.file.Files;
\r
5 import java.nio.file.Path;
\r
6 import java.nio.file.Paths;
\r
7 import java.nio.file.StandardCopyOption;
\r
9 import org.eclipse.core.runtime.IPath;
\r
10 import org.eclipse.core.runtime.Platform;
\r
11 import org.eclipse.ui.plugin.AbstractUIPlugin;
\r
12 import org.osgi.framework.Bundle;
\r
13 import org.osgi.framework.BundleContext;
\r
16 * The activator class controls the plug-in life cycle
\r
18 public class Activator extends AbstractUIPlugin {
\r
21 public static final String PLUGIN_ID = "org.simantics.help.core"; //$NON-NLS-1$
\r
23 public static final String HTML_FOLDER = "html";
\r
25 // The shared instance
\r
26 private static Activator plugin;
\r
27 private static Path directory;
\r
32 public Activator() {
\r
37 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
\r
39 public void start(BundleContext context) throws Exception {
\r
40 super.start(context);
\r
42 Bundle bundle = context.getBundle();
\r
43 IPath path = Platform.getStateLocation(bundle);
\r
44 Path p = Paths.get(path.toOSString());
\r
45 directory = p.resolve(HTML_FOLDER);
\r
46 if (!Files.exists(directory))
\r
47 Files.createDirectories(directory);
\r
49 // Ensure that style.css is inside the html directory
\r
50 Path css = directory.resolve("style.css");
\r
51 if (!Files.exists(css)) {
\r
52 Files.createFile(css);
\r
53 URL url = bundle.getEntry("css/style.css");
\r
54 Files.copy(url.openStream(), css, StandardCopyOption.REPLACE_EXISTING);
\r
60 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
\r
62 public void stop(BundleContext context) throws Exception {
\r
64 super.stop(context);
\r
68 * Returns the shared instance
\r
70 * @return the shared instance
\r
72 public static Activator getDefault() {
\r
76 public static Path getHtmlDirectory() {
\r