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