1 package org.simantics.fileimport;
3 import java.io.IOException;
4 import java.nio.file.Files;
5 import java.nio.file.Path;
6 import java.nio.file.Paths;
8 import org.eclipse.core.runtime.IPath;
9 import org.eclipse.core.runtime.Platform;
10 import org.osgi.framework.BundleActivator;
11 import org.osgi.framework.BundleContext;
12 import org.simantics.fileimport.dropins.FileImportDropins;
14 public class Activator implements BundleActivator {
16 private static BundleContext context;
18 private static Path dropinsFolder = null;
20 static BundleContext getContext() {
26 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
28 public void start(BundleContext bundleContext) throws Exception {
29 Activator.context = bundleContext;
34 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
36 public void stop(BundleContext bundleContext) throws Exception {
37 Activator.context = null;
38 FileImportDropins.unwatchDropinsFolder();
41 public static Path getDropinsFolder() throws IOException {
42 if (dropinsFolder == null) {
43 IPath state = Platform.getStateLocation(context.getBundle());
44 dropinsFolder = Paths.get(state.append("dropins").toOSString());
45 if (!Files.exists(dropinsFolder))
46 Files.createDirectories(dropinsFolder);