|
@@ -13,6 +13,13 @@ import javax.swing.event.CaretEvent;
|
|
import javax.swing.event.CaretListener;
|
|
import javax.swing.event.CaretListener;
|
|
import javax.swing.event.ChangeEvent;
|
|
import javax.swing.event.ChangeEvent;
|
|
import javax.swing.event.ChangeListener;
|
|
import javax.swing.event.ChangeListener;
|
|
|
|
+import javax.tools.Diagnostic;
|
|
|
|
+import javax.tools.DiagnosticCollector;
|
|
|
|
+import javax.tools.JavaCompiler;
|
|
|
|
+import javax.tools.JavaFileObject;
|
|
|
|
+import javax.tools.StandardJavaFileManager;
|
|
|
|
+import javax.tools.StandardLocation;
|
|
|
|
+import javax.tools.ToolProvider;
|
|
|
|
|
|
import com.sun.crypto.provider.JceKeyStore;
|
|
import com.sun.crypto.provider.JceKeyStore;
|
|
|
|
|
|
@@ -23,7 +30,9 @@ import classes.HolonTransformer;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Color;
|
|
import java.awt.Cursor;
|
|
import java.awt.Cursor;
|
|
@@ -36,7 +45,13 @@ import java.awt.event.MouseEvent;
|
|
import java.beans.PropertyChangeEvent;
|
|
import java.beans.PropertyChangeEvent;
|
|
import java.beans.PropertyChangeListener;
|
|
import java.beans.PropertyChangeListener;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.net.MalformedURLException;
|
|
|
|
+import java.net.URL;
|
|
|
|
+import java.net.URLClassLoader;
|
|
|
|
+import java.nio.file.Files;
|
|
import java.awt.FlowLayout;
|
|
import java.awt.FlowLayout;
|
|
|
|
+import com.scarekroow.exampleapi.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* This Class represents the Menu, where you can edit stuff about the
|
|
* This Class represents the Menu, where you can edit stuff about the
|
|
@@ -91,12 +106,37 @@ public class SimulationMenu extends JMenuBar {
|
|
algoCombo.removeAllItems();
|
|
algoCombo.removeAllItems();
|
|
File[] files = fileChooser.getSelectedFile().listFiles();
|
|
File[] files = fileChooser.getSelectedFile().listFiles();
|
|
for (int i = 0; i < files.length; i++) {
|
|
for (int i = 0; i < files.length; i++) {
|
|
- if (files[i].toString().endsWith(".java") || files[i].toString().endsWith(".class")) {
|
|
|
|
|
|
+ if ( files[i].toString().endsWith(".java") /*|| files[i].toString().endsWith(".class")*/) {
|
|
String name = files[i].getName();
|
|
String name = files[i].getName();
|
|
int tmpB = name.lastIndexOf('.');
|
|
int tmpB = name.lastIndexOf('.');
|
|
name = name.substring(0, tmpB);
|
|
name = name.substring(0, tmpB);
|
|
algosHash.put(name, files[i]);
|
|
algosHash.put(name, files[i]);
|
|
algoCombo.addItem(name);
|
|
algoCombo.addItem(name);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ // Save source in .java file.
|
|
|
|
+ File root = new File(fileChooser.getCurrentDirectory().getPath());
|
|
|
|
+ // Compile source file.
|
|
|
|
+
|
|
|
|
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
|
|
|
+
|
|
|
|
+ compiler.run(null, null, null, files[i].getPath());
|
|
|
|
+
|
|
|
|
+ // Load and instantiate compiled class.
|
|
|
|
+ URLClassLoader classLoader = URLClassLoader
|
|
|
|
+ .newInstance(new URL[] { root.toURI().toURL() });
|
|
|
|
+ Class<?> cls = Class.forName("projectPackage.APITest", true, classLoader);
|
|
|
|
+
|
|
|
|
+ Object t = cls.newInstance();
|
|
|
|
+
|
|
|
|
+ controller.addTextToConsole(((interfaceTest)t).outPrintTest());
|
|
|
|
+
|
|
|
|
+ controller.addTextToConsole(classLoader.getClass().getPackage()+"");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|