X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.fileimport%2Fsrc%2Forg%2Fsimantics%2Ffileimport%2FActivator.java;h=391f7ed912a07579ffba1603441e56946d73589a;hp=605e50347babec4e4fd0c29fd6a0344b0c7c9613;hb=55be1eddbfed0d3d9e9e95a7d2547e287fde84ca;hpb=96bb7ef9cbe42d82eb58306d8f9b62392cc29ba8 diff --git a/bundles/org.simantics.fileimport/src/org/simantics/fileimport/Activator.java b/bundles/org.simantics.fileimport/src/org/simantics/fileimport/Activator.java index 605e50347..391f7ed91 100644 --- a/bundles/org.simantics.fileimport/src/org/simantics/fileimport/Activator.java +++ b/bundles/org.simantics.fileimport/src/org/simantics/fileimport/Activator.java @@ -1,52 +1,60 @@ -package org.simantics.fileimport; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.simantics.fileimport.dropins.FileImportDropins; - -public class Activator implements BundleActivator { - - private static BundleContext context; - - private static Path dropinsFolder = null; - - static BundleContext getContext() { - return context; - } - - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext bundleContext) throws Exception { - Activator.context = bundleContext; - FileImportDropins.watchDropinsFolder(); - } - - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext bundleContext) throws Exception { - Activator.context = null; - FileImportDropins.unwatchDropinsFolder(); - } - - public static Path getDropinsFolder() throws IOException { - if (dropinsFolder == null) { - IPath state = Platform.getStateLocation(context.getBundle()); - dropinsFolder = Paths.get(state.append("dropins").toOSString()); - if (!Files.exists(dropinsFolder)) - Files.createDirectories(dropinsFolder); - } - return dropinsFolder; - } - -} +package org.simantics.fileimport; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.simantics.fileimport.dropins.FileImportDropins; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + private static Path modelsFolder = null; + private static Path dropinsFolder = null; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + FileImportDropins.unwatchDropinsFolder(); + } + + public static Path getDropinsFolder() throws IOException { + if (dropinsFolder == null) { + IPath state = Platform.getStateLocation(context.getBundle()); + dropinsFolder = Paths.get(state.append("dropins").toOSString()); + Files.createDirectories(dropinsFolder); + } + return dropinsFolder; + } + + public static Path getModelsFolder() throws IOException { + if (modelsFolder == null) { + IPath state = Platform.getStateLocation(context.getBundle()); + modelsFolder = Paths.get(state.append("models").toOSString()); + Files.createDirectories(modelsFolder); + } + return modelsFolder; + } + +}