X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FActivator.java;fp=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FActivator.java;h=45a5809fcebb2406c50b4eb9646a6a331059da27;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/Activator.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/Activator.java new file mode 100644 index 000000000..45a5809fc --- /dev/null +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/Activator.java @@ -0,0 +1,64 @@ +package fi.vtt.simantics.procore.internal; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.simantics.db.common.utils.Logger; + +/** + * A bundle activator for org.simantics.db.procore that takes care of + * automatically finding a proper place for storing virtual graph files within + * the bundle metadata locations. + * + * @author Tuukka Lehtonen + */ +public class Activator implements BundleActivator { + + public static final String PLUGIN_ID = "org.simantics.db.procore"; + + // The shared instance + private static Activator plugin; + + private Bundle bundle; + + @Override + public void start(BundleContext context) throws Exception { + IPath stateLocation = Platform.getStateLocation(context.getBundle()); + StaticSessionProperties.virtualGraphStoragePath = stateLocation.toFile(); + this.bundle = context.getBundle(); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + this.bundle = null; + plugin = null; + StaticSessionProperties.virtualGraphStoragePath = null; + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * @return + */ + public static void log(IStatus status) { + Activator a = getDefault(); + if (a != null) { + // In OSGi environment + Platform.getLog(a.bundle).log(status); + } else { + Logger.defaultLogError(status.getMessage(), status.getException()); + } + } + +}