]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Added missing plug-ins from old SVN repository trunk 58/258/4
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 9 Jan 2017 16:55:23 +0000 (18:55 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 9 Jan 2017 18:48:07 +0000 (20:48 +0200)
Included the following plug-ins in bundles/:
* org.simantics.gnuplot
* org.simantics.msvc.runtime{,x86,x86_64}

refs #6945

Change-Id: Ibf8709f4cb22945dce4925897ee7de684a46675b

57 files changed:
bundles/org.simantics.gnuplot/.classpath [new file with mode: 0644]
bundles/org.simantics.gnuplot/.project [new file with mode: 0644]
bundles/org.simantics.gnuplot/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
bundles/org.simantics.gnuplot/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.gnuplot/.settings/org.eclipse.m2e.core.prefs [new file with mode: 0644]
bundles/org.simantics.gnuplot/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
bundles/org.simantics.gnuplot/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.gnuplot/build.properties [new file with mode: 0644]
bundles/org.simantics.gnuplot/pom.xml [new file with mode: 0644]
bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java [new file with mode: 0644]
bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java [new file with mode: 0644]
bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/InputStreamToFileCopier.java [new file with mode: 0644]
bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/package-info.java [new file with mode: 0644]
bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java [new file with mode: 0644]
bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.dat [new file with mode: 0644]
bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.plt [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/.classpath [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/.project [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/build.properties [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/msvcp100.dll [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/msvcr100.dll [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/pom.xml [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86/src/.keep [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/.classpath [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/.project [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/build.properties [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/pom.xml [new file with mode: 0644]
bundles/org.simantics.msvc.runtime.x86_64/src/.keep [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/.classpath [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/.project [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/build.properties [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java [new file with mode: 0644]
bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java [new file with mode: 0644]
bundles/pom.xml
features/org.simantics.sdk.feature/feature.xml

diff --git a/bundles/org.simantics.gnuplot/.classpath b/bundles/org.simantics.gnuplot/.classpath
new file mode 100644 (file)
index 0000000..eca7bdb
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.simantics.gnuplot/.project b/bundles/org.simantics.gnuplot/.project
new file mode 100644 (file)
index 0000000..4c9d741
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.gnuplot</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.core.resources.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..99f26c0
--- /dev/null
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..0c68a61
--- /dev/null
@@ -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/bundles/org.simantics.gnuplot/.settings/org.eclipse.m2e.core.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.m2e.core.prefs
new file mode 100644 (file)
index 0000000..f897a7f
--- /dev/null
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.pde.core.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..f29e940
--- /dev/null
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/bundles/org.simantics.gnuplot/META-INF/MANIFEST.MF b/bundles/org.simantics.gnuplot/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..d0dd4a0
--- /dev/null
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Gnuplot front end
+Bundle-SymbolicName: org.simantics.gnuplot
+Bundle-Version: 0.0.1.qualifier
+Bundle-Vendor: Semantum Oy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Export-Package: org.simantics.gnuplot
+Bundle-ClassPath: .
diff --git a/bundles/org.simantics.gnuplot/build.properties b/bundles/org.simantics.gnuplot/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/bundles/org.simantics.gnuplot/pom.xml b/bundles/org.simantics.gnuplot/pom.xml
new file mode 100644 (file)
index 0000000..cc1b5c2
--- /dev/null
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+       xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+       <modelVersion>4.0.0</modelVersion>
+
+       <groupId>org.simantics</groupId>
+       <artifactId>org.simantics.gnuplot</artifactId>
+       <version>0.0.1-SNAPSHOT</version>
+       <packaging>eclipse-plugin</packaging>
+
+       <parent>
+               <groupId>org.simantics</groupId>
+               <artifactId>org.simantics.root.bundles</artifactId>
+               <version>1.0.0-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+
+       <!-- common settings for all modules -->
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <tycho-version>0.26.0</tycho-version>
+       </properties>
+
+       <build>
+               <sourceDirectory>src</sourceDirectory>
+               <plugins>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>tycho-maven-plugin</artifactId>
+                               <version>${tycho-version}</version>
+                               <extensions>true</extensions>
+                       </plugin>
+                       <plugin>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.3</version>
+                               <configuration>
+                                       <source>1.8</source>
+                                       <target>1.8</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <version>2.6</version>
+                               <configuration>
+                                       <descriptorRefs>
+                                               <descriptorRef>jar-with-dependencies</descriptorRef>
+                                       </descriptorRefs>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <id>standalone</id>
+                                               <phase>package</phase>
+                                               <goals>
+                                                       <goal>single</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+               <pluginManagement>
+                       <plugins>
+                               <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+                               <plugin>
+                                       <groupId>org.eclipse.m2e</groupId>
+                                       <artifactId>lifecycle-mapping</artifactId>
+                                       <version>1.0.0</version>
+                                       <configuration>
+                                               <lifecycleMappingMetadata>
+                                                       <pluginExecutions>
+                                                               <pluginExecution>
+                                                                       <pluginExecutionFilter>
+                                                                               <groupId>
+                                                                                       org.eclipse.tycho
+                                                                               </groupId>
+                                                                               <artifactId>
+                                                                                       tycho-packaging-plugin
+                                                                               </artifactId>
+                                                                               <versionRange>
+                                                                                       [0.24.0,)
+                                                                               </versionRange>
+                                                                               <goals>
+                                                                                       <goal>validate-id</goal>
+                                                                                       <goal>build-qualifier</goal>
+                                                                                       <goal>
+                                                                                               validate-version
+                                                                                       </goal>
+                                                                               </goals>
+                                                                       </pluginExecutionFilter>
+                                                                       <action>
+                                                                               <ignore></ignore>
+                                                                       </action>
+                                                               </pluginExecution>
+                                                               <pluginExecution>
+                                                                       <pluginExecutionFilter>
+                                                                               <groupId>
+                                                                                       org.eclipse.tycho
+                                                                               </groupId>
+                                                                               <artifactId>
+                                                                                       tycho-compiler-plugin
+                                                                               </artifactId>
+                                                                               <versionRange>
+                                                                                       [0.24.0,)
+                                                                               </versionRange>
+                                                                               <goals>
+                                                                                       <goal>compile</goal>
+                                                                               </goals>
+                                                                       </pluginExecutionFilter>
+                                                                       <action>
+                                                                               <ignore></ignore>
+                                                                       </action>
+                                                               </pluginExecution>
+                                                       </pluginExecutions>
+                                               </lifecycleMappingMetadata>
+                                       </configuration>
+                               </plugin>
+                       </plugins>
+               </pluginManagement>
+       </build>
+
+<!--   <dependencies> -->
+<!--           <dependency> -->
+<!--                   <groupId>junit</groupId> -->
+<!--                   <artifactId>junit</artifactId> -->
+<!--                   <version>4.12</version> -->
+<!--                   <scope>test</scope> -->
+<!--           </dependency> -->
+<!--   </dependencies> -->
+</project>
diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java
new file mode 100644 (file)
index 0000000..f132179
--- /dev/null
@@ -0,0 +1,167 @@
+package org.simantics.gnuplot;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.24
+ */
+public class Gnuplot {
+
+    private static final String GNUPLOT_VERSION_STRING_STARTS_WITH = "gnuplot ";
+    private static final String GNUPLOT_ENV = "GNUPLOT";
+    private static final String PATH_ENV = "PATH";
+
+    private Path executable;
+
+    public Gnuplot(Path executable) {
+        this.executable = executable;
+    }
+
+    public static Gnuplot detect() throws IOException {
+        try {
+            return new Gnuplot(findGnuplotPath());
+        } catch (InterruptedException e) {
+            throw new IOException(e);
+        }
+    }
+
+    private static String readInput(InputStream in) throws IOException {
+        StringWriter sw = new StringWriter();
+        for (int l = 0; l < GNUPLOT_VERSION_STRING_STARTS_WITH.length(); ++l) {
+            int c;
+            c = in.read();
+            if(c <= 0)
+                break;
+            sw.write(c);
+        }
+        return sw.toString();
+    }
+
+    private static boolean testExecutable(Path exe) throws IOException, InterruptedException {
+        Process process = new ProcessBuilder(exe.toString(), "-V").start();
+        try {
+            if (GNUPLOT_VERSION_STRING_STARTS_WITH.startsWith( readInput(process.getInputStream()) ))
+                return true;
+            return false;
+        } finally {
+            process.getInputStream().close();
+            process.getErrorStream().close();
+            process.waitFor();
+        }
+    }
+
+    private static Path findExecutable(String[] paths, String executableName, boolean fail) throws IOException, InterruptedException {
+        for (String p : paths) {
+            Path exe = Paths.get(p);
+            if (executableName != null)
+                exe = exe.resolve(executableName);
+            if (Files.exists(exe) && Files.isExecutable(exe) && testExecutable(exe)) {
+                return exe;
+            }
+        }
+        if (fail)
+            throw new UnsupportedOperationException("Couldn't find executable '" + executableName + "' on the system path.");
+        return null;
+    }
+
+    private static Path findExecutable(String path, boolean splitPath, boolean fail) throws IOException, InterruptedException {
+        switch (OSType.calculate()) {
+        case APPLE:
+        case SUN:
+        case LINUX:
+            return findExecutable(splitPath ? path.split(":") : new String[] { path }, "gnuplot", fail);
+        case WINDOWS:
+            return findExecutable(splitPath ? path.split(";") : new String[] { path }, "gnuplot.exe", fail);
+        default:
+            throw new UnsupportedOperationException("unsupported platform");
+        }
+    }
+
+    private static Path findGnuplotPath() throws IOException, InterruptedException {
+        String path = System.getenv(GNUPLOT_ENV);
+        if (path != null) {
+            // Does GNUPLOT point directly to the executable?
+            Path p = findExecutable(new String[] { path }, null, false);
+            if (p != null)
+                return p;
+            // Does GNUPLOT point to the gnuplot installation bin directory?
+            p = findExecutable(path, false, false);
+            if (p != null)
+                return p;
+            // Does GNUPLOT point to the gnuplot installation root directory?
+            p = findExecutable(path + "/bin", false, false);
+            if (p != null)
+                return p;
+        }
+        path = System.getenv(PATH_ENV);
+        return findExecutable(path, true, true);
+    }
+
+    private void execute0(Path workingDirectory, Path stdout, Path stderr, String... cmdline) throws IOException {
+        Process process = new ProcessBuilder(cmdline)
+                .directory(workingDirectory.toFile())
+                .start();
+        process.getOutputStream().close();
+        Thread stdoutDumper = new Thread(new InputStreamToFileCopier(process.getInputStream(), stdout));
+        Thread stderrDumper = new Thread(new InputStreamToFileCopier(process.getErrorStream(), stderr));
+        stdoutDumper.start();
+        stderrDumper.start();
+        try {
+            stdoutDumper.join();
+            stderrDumper.join();
+            process.waitFor();
+        } catch (InterruptedException e) {
+            throw new IOException(e);
+        }
+    }
+
+    public void execute(Path workingDirectory, Path stdout, Path stderr, Path script) throws IOException {
+        execute0(workingDirectory, stdout, stderr, executable.toString(), "-c", script.toString());
+    }
+
+    public void execute(Path workingDirectory, Path stdout, Path stderr, String... commands) throws IOException {
+        StringBuilder e = new StringBuilder().append('"');
+        boolean first = true;
+        for (String cmd : commands) {
+            if (!first)
+                e.append("; ");
+            first = false;
+            e.append(cmd);
+        }
+        e.append('"');
+        execute0(workingDirectory, stdout, stderr, executable.toString(), "-e", e.toString());
+    }
+
+    public GnuplotSession newSession(Path workingDirectory, Path stdout, Path stderr) throws IOException {
+        Process process = new ProcessBuilder(executable.toString())
+                .directory(workingDirectory.toFile())
+                .start();
+        return new GnuplotSession(workingDirectory, stdout, stderr, process);
+    }
+
+    static enum OSType {
+        APPLE, LINUX, SUN, WINDOWS, UNKNOWN;
+
+        public static OSType calculate() {
+            String osName = System.getProperty("os.name");
+            assert osName != null;
+            osName = osName.toLowerCase();
+            if (osName.startsWith("mac os x"))
+                return APPLE;
+            if (osName.startsWith("windows"))
+                return WINDOWS;
+            if (osName.startsWith("linux"))
+                return LINUX;
+            if (osName.startsWith("sun"))
+                return SUN;
+            return UNKNOWN;
+        }
+    }
+
+}
diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java
new file mode 100644 (file)
index 0000000..32534e0
--- /dev/null
@@ -0,0 +1,79 @@
+package org.simantics.gnuplot;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.24
+ */
+public class GnuplotSession implements Closeable {
+
+    private Process process;
+    private PrintStream out;
+
+    private Thread stdoutDumper;
+    private Thread stderrDumper;
+
+    GnuplotSession(Path workingDirectory, Path stdout, Path stderr, Process process) {
+        this.process = process;
+        this.out = new PrintStream(process.getOutputStream());
+        stdoutDumper = new Thread(new InputStreamToFileCopier(process.getInputStream(), stdout));
+        stderrDumper = new Thread(new InputStreamToFileCopier(process.getErrorStream(), stderr));
+        stdoutDumper.start();
+        stderrDumper.start();
+    }
+
+    private void assertAlive() {
+        if (process == null)
+            throw new IllegalStateException("session has been closed already");
+    }
+
+    public void evaluate(String commands) throws IOException {
+        assertAlive();
+        out.println(commands);
+    }
+
+    public void evaluateFile(Path file) throws IOException {
+        try {
+            Files.lines(file).forEachOrdered(l -> {
+                try {
+                    evaluate(l);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            });
+        } catch (RuntimeException e) {
+            Throwable t = e.getCause();
+            if (t instanceof IOException)
+                throw (IOException) t;
+            throw e;
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        Process p = process;
+        synchronized (this) {
+            if (process == null)
+                return;
+            process = null;
+        }
+
+        // Inform the process that its stdin has closed, i.e. is done.
+        out.close();
+        try {
+            // Wait for the outputs to be closed by the process itself.
+            stdoutDumper.join();
+            stderrDumper.join();
+            p.waitFor();
+            //System.out.println("gnuplot process ended");
+        } catch (InterruptedException e) {
+            throw new IOException(e);
+        }
+    }
+
+}
diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/InputStreamToFileCopier.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/InputStreamToFileCopier.java
new file mode 100644 (file)
index 0000000..02720d0
--- /dev/null
@@ -0,0 +1,40 @@
+package org.simantics.gnuplot;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.24
+ */
+class InputStreamToFileCopier implements Runnable {
+
+    private final InputStream in;
+    private final Path out;
+
+    public InputStreamToFileCopier(InputStream in, Path out) {
+        this.in = in;
+        this.out = out;
+    }
+
+    @Override
+    public void run() {
+        try {
+            if (out != null) {
+                Files.copy(in, out, StandardCopyOption.REPLACE_EXISTING);
+            } else {
+                drain(in);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static void drain(InputStream in) throws IOException {
+        while (in.read() >= 0);
+    }
+
+}
\ No newline at end of file
diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/package-info.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/package-info.java
new file mode 100644 (file)
index 0000000..2fc4e58
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * Contains simple <code>gnuplot</code> installation detection and
+ * <code>gnuplot</code> execution facilities.
+ * 
+ * <p>
+ * The installation detection logic relies purely on two environment variables.
+ * Primarily the <code>GNUPLOT</code> variable and secondarily on
+ * <code>PATH</code>. <code>GNUPLOT</code> can be set to point to one of the
+ * following:
+ * <ul>
+ * <li>the full path to the gnuplot executable directly (including file name
+ * suffix</li>
+ * <li>the <code>bin</code> directory of a gnuplot installation</li>
+ * <li>the root directory of a gnuplot installation</li>
+ * </ul>
+ * Secondarily the detection will check whether the <code>PATH</code> variable
+ * contains any files system path that corresponds to a gnuplot installation
+ * <code>bin</code> directory, i.e. the directory contains a
+ * <code>gnuplot</code> excutable.
+ * 
+ * <p>
+ * In both cases the detection will also ensure that the discovered gnuplot
+ * executable responds to the <code>-V</code> (version) argument as expected,
+ * i.e. returns a line starting with "gnuplot ".
+ * 
+ * @author Tuukka Lehtonen
+ * @since 1.24
+ */
+package org.simantics.gnuplot;
\ No newline at end of file
diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java
new file mode 100644 (file)
index 0000000..ccc1444
--- /dev/null
@@ -0,0 +1,58 @@
+package org.simantics.gnuplot.tests;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.simantics.gnuplot.Gnuplot;
+import org.simantics.gnuplot.GnuplotSession;
+
+public class GnuplotTest {
+
+    private Path dataPath;
+    private Path plot;
+    private Path stdout;
+    private Path stderr;
+    private Path stdout2;
+    private Path stderr2;
+
+    private Path getDir() throws IOException {
+        URL path = getClass().getResource(".");
+        // Avoid the beginning '/'
+        String p = path.getPath().substring(1);
+        String dp = URLDecoder.decode(p, "UTF-8");
+        return Paths.get(dp).toAbsolutePath();
+    }
+
+    @Before
+    public void before() throws IOException {
+        dataPath = getDir();
+        plot = dataPath.resolve("hexagons.plt");
+        stdout = dataPath.resolve("hexagons.svg");
+        stderr = dataPath.resolve("hexagons.stderr.txt");
+        stdout2 = dataPath.resolve("hexagons2.svg");
+        stderr2 = dataPath.resolve("hexagons2.stderr.txt");
+    }
+
+    @After
+    public void after() {
+    }
+
+    @Test
+    public void testGnuplot() throws IOException {
+        Gnuplot.detect().execute(dataPath, stdout, stderr, plot);
+    }
+
+    @Test
+    public void testGnuplotSession() throws IOException {
+        try (GnuplotSession session = Gnuplot.detect().newSession(dataPath, stdout2, stderr2)) {
+            session.evaluateFile(plot);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.dat b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.dat
new file mode 100644 (file)
index 0000000..912b30c
--- /dev/null
@@ -0,0 +1,11 @@
+3      1.73205080756888        0.627868065218539\r
+2      3.46410161513775        0.0381587751648738\r
+3      5.19615242270663        0.372697677268786\r
+2      6.92820323027551        0.421502736487078\r
+3      8.66025403784439        0.274237128801435\r
+5      1.73205080756888        0.202129157245494\r
+4      3.46410161513775        0.769320237819866\r
+5      5.19615242270663        0.031500208931071\r
+4      6.92820323027551        0.562379837027411\r
+5      8.66025403784439        0.504284749332101\r
+7      1.73205080756888        0.217345187922358\r
diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.plt b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.plt
new file mode 100644 (file)
index 0000000..8b5aca1
--- /dev/null
@@ -0,0 +1,31 @@
+reset\r
+fn = 'hexagons.dat'\r
+S = 0.5\r
+C = sqrt(3)/2\r
+A = 1/C\r
+a = 0.95*A\r
+\r
+hex_id = 1\r
+\r
+cmd = ''\r
+\r
+hex_cmd(x, y, c) = sprintf("set obj hex_id poly from %g,%g-a to %g+a*C, %g-a*S to %g+a*C,%g+a*S to %g,%g+a to %g-a*C,%g+a*S to %g-a*C,%g-a*S to %g,%g-a fs solid 0.8 border lc pal cb %g lw 2 fc pal cb %g; hex_id = hex_id + 1;", x,y,x,y,x,y,x,y,x,y,x,y,x,y,c,c)\r
+\r
+read_f(x, y, c) = (cmd=cmd.hex_cmd(x, y, c), y)\r
+\r
+set term unknown\r
+\r
+plot fn using 1:(read_f($1,$2,$3))\r
+\r
+set term pop\r
+\r
+print cmd\r
+eval cmd\r
+\r
+set size ratio -1\r
+set xr [GPVAL_X_MIN-A:GPVAL_X_MAX+A]\r
+set yr [GPVAL_Y_MIN-A:GPVAL_Y_MAX+A]\r
+\r
+set term svg\r
+#plot fn using 1:2:3 w d lc pal notit\r
+plot fn using 1:2:3 notitle lc pal w d\r
diff --git a/bundles/org.simantics.msvc.runtime.x86/.classpath b/bundles/org.simantics.msvc.runtime.x86/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.simantics.msvc.runtime.x86/.project b/bundles/org.simantics.msvc.runtime.x86/.project
new file mode 100644 (file)
index 0000000..050f09e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.msvc.runtime.x86</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/bundles/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..c537b63
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..864f441
--- /dev/null
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Microsoft Visual C++ Runtime x86 libraries
+Bundle-SymbolicName: org.simantics.msvc.runtime.x86
+Bundle-Version: 10.0.40219.qualifier
+Bundle-Vendor: Semantum Oy
+Fragment-Host: org.simantics.msvc.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86))
+Bundle-NativeCode: msvcr100.dll; msvcp100.dll; processor=x86
diff --git a/bundles/org.simantics.msvc.runtime.x86/build.properties b/bundles/org.simantics.msvc.runtime.x86/build.properties
new file mode 100644 (file)
index 0000000..47c6edf
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               msvcp100.dll,\
+               msvcr100.dll
diff --git a/bundles/org.simantics.msvc.runtime.x86/msvcp100.dll b/bundles/org.simantics.msvc.runtime.x86/msvcp100.dll
new file mode 100644 (file)
index 0000000..e9eae44
Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86/msvcp100.dll differ
diff --git a/bundles/org.simantics.msvc.runtime.x86/msvcr100.dll b/bundles/org.simantics.msvc.runtime.x86/msvcr100.dll
new file mode 100644 (file)
index 0000000..fd91c89
Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86/msvcr100.dll differ
diff --git a/bundles/org.simantics.msvc.runtime.x86/pom.xml b/bundles/org.simantics.msvc.runtime.x86/pom.xml
new file mode 100644 (file)
index 0000000..256c95c
--- /dev/null
@@ -0,0 +1,32 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <artifactId>org.simantics.msvc.runtime.x86</artifactId>
+       <packaging>eclipse-plugin</packaging>
+       <version>10.0.40219-SNAPSHOT</version>
+
+       <parent>
+               <groupId>org.simantics</groupId>
+               <artifactId>org.simantics.root.bundles</artifactId>
+               <version>1.0.0-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>target-platform-configuration</artifactId>
+                               <configuration>
+                                       <environments>
+                                               <environment>
+                                                       <os>win32</os>
+                                                       <arch>x86</arch>
+                                               </environment>
+                                       </environments>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+</project>
\ No newline at end of file
diff --git a/bundles/org.simantics.msvc.runtime.x86/src/.keep b/bundles/org.simantics.msvc.runtime.x86/src/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/.classpath b/bundles/org.simantics.msvc.runtime.x86_64/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/.project b/bundles/org.simantics.msvc.runtime.x86_64/.project
new file mode 100644 (file)
index 0000000..e11e718
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.msvc.runtime.x86_64</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86_64/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..c537b63
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86_64/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..df0f3ae
--- /dev/null
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Microsoft Visual C++ Runtime x86-64 libraries
+Bundle-SymbolicName: org.simantics.msvc.runtime.x86_64
+Bundle-Version: 10.0.40219.qualifier
+Bundle-Vendor: Semantum Oy
+Fragment-Host: org.simantics.msvc.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86_64))
+Bundle-NativeCode: msvcr100.dll; msvcp100.dll; processor=x86_64
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/build.properties b/bundles/org.simantics.msvc.runtime.x86_64/build.properties
new file mode 100644 (file)
index 0000000..47c6edf
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               msvcp100.dll,\
+               msvcr100.dll
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll b/bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll
new file mode 100644 (file)
index 0000000..6f0cdf1
Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll differ
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll b/bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll
new file mode 100644 (file)
index 0000000..b1c3a5e
Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll differ
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project
new file mode 100644 (file)
index 0000000..050f09e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.msvc.runtime.x86</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..c537b63
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..864f441
--- /dev/null
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Microsoft Visual C++ Runtime x86 libraries
+Bundle-SymbolicName: org.simantics.msvc.runtime.x86
+Bundle-Version: 10.0.40219.qualifier
+Bundle-Vendor: Semantum Oy
+Fragment-Host: org.simantics.msvc.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86))
+Bundle-NativeCode: msvcr100.dll; msvcp100.dll; processor=x86
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties
new file mode 100644 (file)
index 0000000..47c6edf
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               msvcp100.dll,\
+               msvcr100.dll
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll
new file mode 100644 (file)
index 0000000..e9eae44
Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll differ
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll
new file mode 100644 (file)
index 0000000..fd91c89
Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll differ
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project
new file mode 100644 (file)
index 0000000..5c92a7c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.msvc.runtime</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..c537b63
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..42eebe1
--- /dev/null
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Microsoft Visual C++ Runtimes
+Bundle-SymbolicName: org.simantics.msvc.runtime
+Bundle-Version: 10.0.40219.qualifier
+Bundle-Activator: org.simantics.msvc.runtime.Activator
+Bundle-Vendor: Semantum Oy
+Require-Bundle: org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.msvc.runtime
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java
new file mode 100644 (file)
index 0000000..b956a44
--- /dev/null
@@ -0,0 +1,31 @@
+package org.simantics.msvc.runtime;
+
+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;
+               Runtimes.initialize(Runtimes.VC_2010);
+       }
+
+       /*
+        * (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/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java
new file mode 100644 (file)
index 0000000..31702fd
--- /dev/null
@@ -0,0 +1,92 @@
+package org.simantics.msvc.runtime;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLDecoder;
+
+import org.eclipse.core.runtime.Path;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public final class Runtimes {
+
+    public static final String VC_2010 = "vc2010";
+
+    static boolean vc100Initialized = false;
+
+    public static void initialize(String vc) {
+        OSType os = OSType.calculate();
+        if (os == OSType.WINDOWS) {
+            if (VC_2010.equals(vc) && !vc100Initialized) {
+                initializeVC100();
+            }
+        }
+    }
+
+    static synchronized void initializeVC100() {
+        try {
+            // Works in OSGi environment.
+            System.loadLibrary("msvcr100");
+            System.loadLibrary("msvcp100");
+            vc100Initialized = true;
+        } catch (UnsatisfiedLinkError e) {
+            // Try to load from a workspace in POJO environment.
+            try {
+                String archStr = ARCHType.calculate().toString().toLowerCase();
+                URL url = Runtimes.class.getResource(".");
+                File dir = new File(URLDecoder.decode(url.getPath(), "UTF-8") + "../../../../../../org.simantics.msvc.runtime." + archStr);
+                dir = new Path(dir.getAbsolutePath()).toFile();
+                String vcr = new File(dir, "msvcr100.dll").getAbsolutePath();
+                String vcp = new File(dir, "msvcp100.dll").getAbsolutePath();
+                System.load(vcr);
+                System.load(vcp);
+                vc100Initialized = true;
+            } catch (UnsupportedEncodingException e1) {
+                throw new Error("UTF-8 not supported, impossible");
+            }
+        }
+    }
+
+    public enum ARCHType {
+        PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN;
+
+        public static ARCHType calculate() {
+            String osArch = System.getProperty("os.arch");
+            assert osArch != null;
+            osArch = osArch.toLowerCase();
+            if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))
+                return X86;
+            if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))
+                return X86_64;
+            if (osArch.equals("ppc"))
+                return PPC;
+            if (osArch.startsWith("ppc"))
+                return PPC_64;
+            if (osArch.startsWith("sparc"))
+                return SPARC;
+            return UNKNOWN;
+        }
+    }
+
+    public enum OSType {
+        APPLE, LINUX, SUN, WINDOWS, UNKNOWN;
+
+        public static OSType calculate() {
+            String osName = System.getProperty("os.name");
+            assert osName != null;
+            osName = osName.toLowerCase();
+            if (osName.startsWith("mac os x"))
+                return APPLE;
+            if (osName.startsWith("windows"))
+                return WINDOWS;
+            if (osName.startsWith("linux"))
+                return LINUX;
+            if (osName.startsWith("sun"))
+                return SUN;
+            return UNKNOWN;
+        }
+    }
+
+}
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/pom.xml b/bundles/org.simantics.msvc.runtime.x86_64/pom.xml
new file mode 100644 (file)
index 0000000..ca89cf8
--- /dev/null
@@ -0,0 +1,32 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <artifactId>org.simantics.msvc.runtime.x86_64</artifactId>
+       <packaging>eclipse-plugin</packaging>
+       <version>10.0.40219-SNAPSHOT</version>
+
+       <parent>
+               <groupId>org.simantics</groupId>
+               <artifactId>org.simantics.root.bundles</artifactId>
+               <version>1.0.0-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>target-platform-configuration</artifactId>
+                               <configuration>
+                                       <environments>
+                                               <environment>
+                                                       <os>win32</os>
+                                                       <arch>x86_64</arch>
+                                               </environment>
+                                       </environments>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+</project>
\ No newline at end of file
diff --git a/bundles/org.simantics.msvc.runtime.x86_64/src/.keep b/bundles/org.simantics.msvc.runtime.x86_64/src/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/bundles/org.simantics.msvc.runtime/.classpath b/bundles/org.simantics.msvc.runtime/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.simantics.msvc.runtime/.project b/bundles/org.simantics.msvc.runtime/.project
new file mode 100644 (file)
index 0000000..5c92a7c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.msvc.runtime</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/bundles/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..c537b63
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/org.simantics.msvc.runtime/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..42eebe1
--- /dev/null
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Microsoft Visual C++ Runtimes
+Bundle-SymbolicName: org.simantics.msvc.runtime
+Bundle-Version: 10.0.40219.qualifier
+Bundle-Activator: org.simantics.msvc.runtime.Activator
+Bundle-Vendor: Semantum Oy
+Require-Bundle: org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.msvc.runtime
diff --git a/bundles/org.simantics.msvc.runtime/build.properties b/bundles/org.simantics.msvc.runtime/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java b/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java
new file mode 100644 (file)
index 0000000..b956a44
--- /dev/null
@@ -0,0 +1,31 @@
+package org.simantics.msvc.runtime;
+
+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;
+               Runtimes.initialize(Runtimes.VC_2010);
+       }
+
+       /*
+        * (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/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java b/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java
new file mode 100644 (file)
index 0000000..31702fd
--- /dev/null
@@ -0,0 +1,92 @@
+package org.simantics.msvc.runtime;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLDecoder;
+
+import org.eclipse.core.runtime.Path;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public final class Runtimes {
+
+    public static final String VC_2010 = "vc2010";
+
+    static boolean vc100Initialized = false;
+
+    public static void initialize(String vc) {
+        OSType os = OSType.calculate();
+        if (os == OSType.WINDOWS) {
+            if (VC_2010.equals(vc) && !vc100Initialized) {
+                initializeVC100();
+            }
+        }
+    }
+
+    static synchronized void initializeVC100() {
+        try {
+            // Works in OSGi environment.
+            System.loadLibrary("msvcr100");
+            System.loadLibrary("msvcp100");
+            vc100Initialized = true;
+        } catch (UnsatisfiedLinkError e) {
+            // Try to load from a workspace in POJO environment.
+            try {
+                String archStr = ARCHType.calculate().toString().toLowerCase();
+                URL url = Runtimes.class.getResource(".");
+                File dir = new File(URLDecoder.decode(url.getPath(), "UTF-8") + "../../../../../../org.simantics.msvc.runtime." + archStr);
+                dir = new Path(dir.getAbsolutePath()).toFile();
+                String vcr = new File(dir, "msvcr100.dll").getAbsolutePath();
+                String vcp = new File(dir, "msvcp100.dll").getAbsolutePath();
+                System.load(vcr);
+                System.load(vcp);
+                vc100Initialized = true;
+            } catch (UnsupportedEncodingException e1) {
+                throw new Error("UTF-8 not supported, impossible");
+            }
+        }
+    }
+
+    public enum ARCHType {
+        PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN;
+
+        public static ARCHType calculate() {
+            String osArch = System.getProperty("os.arch");
+            assert osArch != null;
+            osArch = osArch.toLowerCase();
+            if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))
+                return X86;
+            if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))
+                return X86_64;
+            if (osArch.equals("ppc"))
+                return PPC;
+            if (osArch.startsWith("ppc"))
+                return PPC_64;
+            if (osArch.startsWith("sparc"))
+                return SPARC;
+            return UNKNOWN;
+        }
+    }
+
+    public enum OSType {
+        APPLE, LINUX, SUN, WINDOWS, UNKNOWN;
+
+        public static OSType calculate() {
+            String osName = System.getProperty("os.name");
+            assert osName != null;
+            osName = osName.toLowerCase();
+            if (osName.startsWith("mac os x"))
+                return APPLE;
+            if (osName.startsWith("windows"))
+                return WINDOWS;
+            if (osName.startsWith("linux"))
+                return LINUX;
+            if (osName.startsWith("sun"))
+                return SUN;
+            return UNKNOWN;
+        }
+    }
+
+}
index 3765819c5705bdfbad6019e473457b64e303bfad..bbc378243b66bab2235f9e7ebf267606540cecae 100644 (file)
         <module>org.simantics.graphfile.ontology</module>
         <module>org.simantics.graphviz</module>
         <module>org.simantics.graphviz.ui</module>
+        <module>org.simantics.gnuplot</module>
         <module>org.simantics.help.base</module>
         <module>org.simantics.help.core</module>
         <module>org.simantics.help.files</module>
         <module>org.simantics.modeling.template2d.ui</module>
         <module>org.simantics.modeling.ui</module>
         <module>org.simantics.modeling.ui.workbench</module>
+        <module>org.simantics.msvc.runtime</module>
+        <module>org.simantics.msvc.runtime.x86</module>
+        <module>org.simantics.msvc.runtime.x86_64</module>
         <module>org.simantics.nativemem</module>
         <module>org.simantics.objmap2</module>
         <module>org.simantics.platform.ui.ontology</module>
index 211e549d953ac9c7bb621776d172590ea844853d..1190496c14a5acd81ee788db4fa75f40792189eb 100644 (file)
          version="0.0.0"
          unpack="false"/>
 
+   <plugin
+         id="org.simantics.gnuplot"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.simantics.msvc.runtime"
+         os="win32"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.simantics.msvc.runtime.x86"
+         fragment="true"
+         os="win32"
+         arch="x86"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.simantics.msvc.runtime.x86_64"
+         fragment="true"
+         os="win32"
+         arch="x86_64"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
 </feature>