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