--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
--- /dev/null
+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
--- /dev/null
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
--- /dev/null
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
--- /dev/null
+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: .
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
--- /dev/null
+<?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>
--- /dev/null
+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;
+ }
+ }
+
+}
--- /dev/null
+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);
+ }
+ }
+
+}
--- /dev/null
+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
--- /dev/null
+/**
+ * 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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ msvcp100.dll,\
+ msvcr100.dll
--- /dev/null
+<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
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ msvcp100.dll,\
+ msvcr100.dll
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ msvcp100.dll,\
+ msvcr100.dll
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
--- /dev/null
+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;
+ }
+
+}
--- /dev/null
+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;
+ }
+ }
+
+}
--- /dev/null
+<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
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
--- /dev/null
+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;
+ }
+
+}
--- /dev/null
+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;
+ }
+ }
+
+}
<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>
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>