]> gerrit.simantics Code Review - simantics/r.git/commitdiff
refs #6653
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 22 Aug 2016 10:55:05 +0000 (10:55 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 22 Aug 2016 10:55:05 +0000 (10:55 +0000)
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

org.simantics.r.fileimport/.classpath [new file with mode: 0644]
org.simantics.r.fileimport/.project [new file with mode: 0644]
org.simantics.r.fileimport/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.simantics.r.fileimport/META-INF/MANIFEST.MF [new file with mode: 0644]
org.simantics.r.fileimport/OSGI-INF/component.xml [new file with mode: 0644]
org.simantics.r.fileimport/bin/org/simantics/r/fileimport/Activator.class [new file with mode: 0644]
org.simantics.r.fileimport/bin/org/simantics/r/fileimport/RFileImport.class [new file with mode: 0644]
org.simantics.r.fileimport/build.properties [new file with mode: 0644]
org.simantics.r.fileimport/src/org/simantics/r/fileimport/Activator.java [new file with mode: 0644]
org.simantics.r.fileimport/src/org/simantics/r/fileimport/RFileImport.java [new file with mode: 0644]

diff --git a/org.simantics.r.fileimport/.classpath b/org.simantics.r.fileimport/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/org.simantics.r.fileimport/.project b/org.simantics.r.fileimport/.project
new file mode 100644 (file)
index 0000000..cee0871
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.r.fileimport</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ds.core.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
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 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/org.simantics.r.fileimport/META-INF/MANIFEST.MF b/org.simantics.r.fileimport/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..a997db9
--- /dev/null
@@ -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 (file)
index 0000000..109c9bf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.simantics.r.fileimport">\r
+   <implementation class="org.simantics.r.fileimport.RFileImport"/>\r
+   <service>\r
+      <provide interface="org.simantics.fileimport.IGenericFileImport"/>\r
+   </service>\r
+</scr:component>\r
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 (file)
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 (file)
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 (file)
index 0000000..7d2a7a8
--- /dev/null
@@ -0,0 +1,5 @@
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               OSGI-INF/component.xml\r
+source.. = src/\r
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 (file)
index 0000000..f3be837
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.r.fileimport;\r
+\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+       private static BundleContext context;\r
+\r
+       static BundleContext getContext() {\r
+               return context;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext bundleContext) throws Exception {\r
+               Activator.context = bundleContext;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext bundleContext) throws Exception {\r
+               Activator.context = null;\r
+       }\r
+\r
+}\r
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 (file)
index 0000000..21eed60
--- /dev/null
@@ -0,0 +1,26 @@
+package org.simantics.r.fileimport;\r
+\r
+import java.nio.file.Path;\r
+import java.util.Collections;\r
+import java.util.Map;\r
+import java.util.Optional;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.fileimport.SimanticsResourceFileImport;\r
+import org.simantics.r.RModelUtils;\r
+\r
+public class RFileImport extends SimanticsResourceFileImport {\r
+\r
+    private static final Map<String, String> ALLOWED_EXTENSIONS = Collections.singletonMap("*.r", "R-file (*.r)");\r
+    \r
+    @Override\r
+    public Optional<Resource> perform(Resource parent, Path file) {\r
+        return Optional.ofNullable(RModelUtils.createRModel(parent, file));\r
+    }\r
+\r
+    @Override\r
+    public Map<String, String> allowedExtensionsWithFilters() {\r
+        return ALLOWED_EXTENSIONS;\r
+    }\r
+\r
+}\r