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
30 FileImportDropins.watchDropinsFolder();
\r
35 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
\r
37 public void stop(BundleContext bundleContext) throws Exception {
\r
38 Activator.context = null;
\r
39 FileImportDropins.unwatchDropinsFolder();
\r
42 public static Path getDropinsFolder() throws IOException {
\r
43 if (dropinsFolder == null) {
\r
44 IPath state = Platform.getStateLocation(context.getBundle());
\r
45 dropinsFolder = Paths.get(state.append("dropins").toOSString());
\r
46 if (!Files.exists(dropinsFolder))
\r
47 Files.createDirectories(dropinsFolder);
\r
49 return dropinsFolder;
\r