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 modelsFolder = null;
19 private static Path dropinsFolder = null;
21 static BundleContext getContext() {
27 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
29 public void start(BundleContext bundleContext) throws Exception {
30 Activator.context = bundleContext;
35 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
37 public void stop(BundleContext bundleContext) throws Exception {
38 Activator.context = null;
39 FileImportDropins.unwatchDropinsFolder();
42 public static Path getDropinsFolder() throws IOException {
43 if (dropinsFolder == null) {
44 IPath state = Platform.getStateLocation(context.getBundle());
45 dropinsFolder = Paths.get(state.append("dropins").toOSString());
46 if (!Files.exists(dropinsFolder))
47 Files.createDirectories(dropinsFolder);
52 public static Path getModelsFolder() throws IOException {
53 if (modelsFolder == null) {
54 IPath state = Platform.getStateLocation(context.getBundle());
55 modelsFolder = Paths.get(state.append("models").toOSString());
56 if (!Files.exists(modelsFolder))
57 Files.createDirectories(modelsFolder);