|
@@ -11,55 +11,23 @@ import javax.swing.JRadioButton;
|
|
|
import javax.swing.JTextField;
|
|
|
import javax.swing.event.CaretEvent;
|
|
|
import javax.swing.event.CaretListener;
|
|
|
-import javax.swing.event.ChangeEvent;
|
|
|
-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 classes.AbstractCpsObject;
|
|
|
-import classes.HolonObject;
|
|
|
-import classes.HolonSwitch;
|
|
|
-import classes.HolonTransformer;
|
|
|
-import jdk.nashorn.api.scripting.URLReader;
|
|
|
-import sun.rmi.runtime.NewThreadAction;
|
|
|
import ui.controller.Control;
|
|
|
import ui.model.Model;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
import java.awt.GridBagLayout;
|
|
|
-import java.awt.Color;
|
|
|
-import java.awt.Cursor;
|
|
|
import java.awt.Dimension;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.Insets;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
-import java.awt.event.ComponentEvent;
|
|
|
-import java.awt.event.ComponentListener;
|
|
|
-import java.awt.event.ItemEvent;
|
|
|
-import java.awt.event.ItemListener;
|
|
|
-import java.awt.event.MouseAdapter;
|
|
|
-import java.awt.event.MouseEvent;
|
|
|
-import java.beans.PropertyChangeEvent;
|
|
|
-import java.beans.PropertyChangeListener;
|
|
|
+import java.io.BufferedReader;
|
|
|
import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.net.MalformedURLException;
|
|
|
+import java.io.FileReader;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLClassLoader;
|
|
|
-import java.nio.file.Files;
|
|
|
-import java.awt.FlowLayout;
|
|
|
-import cpsAlgorithm.*;
|
|
|
|
|
|
/**
|
|
|
* This Class represents the Menu, where you can edit stuff about the
|
|
@@ -103,7 +71,7 @@ public class SimulationMenu extends JMenuBar {
|
|
|
algoCombo.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- setAlgorithm(algosHash.get(algoCombo.getSelectedItem()));
|
|
|
+ setAlgorithm(algosHash.get(algoCombo.getSelectedItem()), algoCombo.getSelectedItem() + "");
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -210,16 +178,31 @@ public class SimulationMenu extends JMenuBar {
|
|
|
gbcAlgoCombo.gridx = 4;
|
|
|
gbcAlgoCombo.gridy = 0;
|
|
|
menuPanel.add(algoCombo, gbcAlgoCombo);
|
|
|
- algoCombo.addItem(Languages.getLanguage()[86]);
|
|
|
+ // algoCombo.addItem(Languages.getLanguage()[86]);
|
|
|
|
|
|
// Add Panel to SimulationMenu
|
|
|
this.add(menuPanel);
|
|
|
}
|
|
|
|
|
|
- public void setAlgorithm(File file) {
|
|
|
+ public void setAlgorithm(File file, String name) {
|
|
|
try {
|
|
|
- // Compile source file.
|
|
|
+ BufferedReader br = new BufferedReader(new FileReader(file.getPath()));
|
|
|
+ String line = br.readLine();
|
|
|
+ // Package Name
|
|
|
+ String packageName = "";
|
|
|
+
|
|
|
+ while (line != null) {
|
|
|
+ line = line.trim();
|
|
|
+ if (!line.isEmpty()) {
|
|
|
+ controller.addTextToConsole(line);
|
|
|
+ }
|
|
|
+
|
|
|
+ line = br.readLine();
|
|
|
+ }
|
|
|
+
|
|
|
+ controller.addTextToConsole("name" + packageName);
|
|
|
|
|
|
+ // Compile source file.
|
|
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
|
|
|
|
|
compiler.run(null, null, null, file.getPath());
|
|
@@ -227,15 +210,14 @@ public class SimulationMenu extends JMenuBar {
|
|
|
// Load and instantiate compiled class.
|
|
|
URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { root.toURI().toURL() });
|
|
|
|
|
|
- Class<?> cls = Class.forName("projectPackage.APITest", true, classLoader);
|
|
|
+ Class<?> cls = Class.forName("projectPackage." + name, true, classLoader);
|
|
|
|
|
|
Object t = cls.newInstance();
|
|
|
|
|
|
- controller.addTextToConsole("Selected Alogrithm" + cls.newInstance());
|
|
|
-
|
|
|
controller.setAlgorithm(t);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
}
|