From: jsimomaa Date: Mon, 22 Aug 2016 10:55:05 +0000 (+0000) Subject: refs #6653 X-Git-Tag: v1.28.0~9 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=26dadd9389db2401c5ba59c37ead77d75b912ee5;p=simantics%2Fr.git refs #6653 Initial commit for org.simantics.fileimport enabling easy drag and drop import for supported file extensions (e.g. .r, .fmu etc) git-svn-id: https://www.simantics.org/svn/simantics/r/trunk@33128 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.r.fileimport/.classpath b/org.simantics.r.fileimport/.classpath new file mode 100644 index 0000000..b862a29 --- /dev/null +++ b/org.simantics.r.fileimport/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.simantics.r.fileimport/.project b/org.simantics.r.fileimport/.project new file mode 100644 index 0000000..cee0871 --- /dev/null +++ b/org.simantics.r.fileimport/.project @@ -0,0 +1,33 @@ + + + org.simantics.r.fileimport + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.simantics.r.fileimport/.settings/org.eclipse.jdt.core.prefs b/org.simantics.r.fileimport/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..295926d --- /dev/null +++ b/org.simantics.r.fileimport/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/org.simantics.r.fileimport/META-INF/MANIFEST.MF b/org.simantics.r.fileimport/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a997db9 --- /dev/null +++ b/org.simantics.r.fileimport/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Fileimport +Bundle-SymbolicName: org.simantics.r.fileimport +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.simantics.r.fileimport.Activator +Require-Bundle: org.eclipse.core.runtime, + org.simantics.fileimport, + org.simantics.r;bundle-version="0.1.0", + org.simantics.db +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Service-Component: OSGI-INF/component.xml diff --git a/org.simantics.r.fileimport/OSGI-INF/component.xml b/org.simantics.r.fileimport/OSGI-INF/component.xml new file mode 100644 index 0000000..109c9bf --- /dev/null +++ b/org.simantics.r.fileimport/OSGI-INF/component.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.simantics.r.fileimport/bin/org/simantics/r/fileimport/Activator.class b/org.simantics.r.fileimport/bin/org/simantics/r/fileimport/Activator.class new file mode 100644 index 0000000..51895a1 Binary files /dev/null and b/org.simantics.r.fileimport/bin/org/simantics/r/fileimport/Activator.class differ diff --git a/org.simantics.r.fileimport/bin/org/simantics/r/fileimport/RFileImport.class b/org.simantics.r.fileimport/bin/org/simantics/r/fileimport/RFileImport.class new file mode 100644 index 0000000..a9919ae Binary files /dev/null and b/org.simantics.r.fileimport/bin/org/simantics/r/fileimport/RFileImport.class differ diff --git a/org.simantics.r.fileimport/build.properties b/org.simantics.r.fileimport/build.properties new file mode 100644 index 0000000..7d2a7a8 --- /dev/null +++ b/org.simantics.r.fileimport/build.properties @@ -0,0 +1,5 @@ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/component.xml +source.. = src/ diff --git a/org.simantics.r.fileimport/src/org/simantics/r/fileimport/Activator.java b/org.simantics.r.fileimport/src/org/simantics/r/fileimport/Activator.java new file mode 100644 index 0000000..f3be837 --- /dev/null +++ b/org.simantics.r.fileimport/src/org/simantics/r/fileimport/Activator.java @@ -0,0 +1,30 @@ +package org.simantics.r.fileimport; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + 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; + } + +} diff --git a/org.simantics.r.fileimport/src/org/simantics/r/fileimport/RFileImport.java b/org.simantics.r.fileimport/src/org/simantics/r/fileimport/RFileImport.java new file mode 100644 index 0000000..21eed60 --- /dev/null +++ b/org.simantics.r.fileimport/src/org/simantics/r/fileimport/RFileImport.java @@ -0,0 +1,26 @@ +package org.simantics.r.fileimport; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import org.simantics.db.Resource; +import org.simantics.fileimport.SimanticsResourceFileImport; +import org.simantics.r.RModelUtils; + +public class RFileImport extends SimanticsResourceFileImport { + + private static final Map ALLOWED_EXTENSIONS = Collections.singletonMap("*.r", "R-file (*.r)"); + + @Override + public Optional perform(Resource parent, Path file) { + return Optional.ofNullable(RModelUtils.createRModel(parent, file)); + } + + @Override + public Map allowedExtensionsWithFilters() { + return ALLOWED_EXTENSIONS; + } + +}