|
@@ -28,6 +28,7 @@ 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;
|
|
@@ -40,7 +41,10 @@ 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;
|
|
@@ -55,7 +59,7 @@ import java.net.URL;
|
|
|
import java.net.URLClassLoader;
|
|
|
import java.nio.file.Files;
|
|
|
import java.awt.FlowLayout;
|
|
|
-import com.scarekroow.exampleapi.*;
|
|
|
+import cpsAlgorithm.*;
|
|
|
|
|
|
|
|
|
* This Class represents the Menu, where you can edit stuff about the
|
|
@@ -96,14 +100,10 @@ public class SimulationMenu extends JMenuBar {
|
|
|
this.controller = cont;
|
|
|
|
|
|
|
|
|
- algoCombo.addItemListener(new ItemListener() {
|
|
|
-
|
|
|
+ algoCombo.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
- public void itemStateChanged(ItemEvent e) {
|
|
|
-
|
|
|
- setAlgorithm(algosHash.get(e.getItem()));
|
|
|
- controller.addTextToConsole("" + e.getItem());
|
|
|
-
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ setAlgorithm(algosHash.get(algoCombo.getSelectedItem()));
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -124,10 +124,9 @@ public class SimulationMenu extends JMenuBar {
|
|
|
if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
|
algoCombo.removeAllItems();
|
|
|
File[] files = fileChooser.getSelectedFile().listFiles();
|
|
|
-
|
|
|
+
|
|
|
root = new File(fileChooser.getCurrentDirectory().getPath());
|
|
|
- controller.addTextToConsole("roor Path" + root.getPath());
|
|
|
-
|
|
|
+
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
if (files[i].toString()
|
|
|
.endsWith(".java")
|
|
@@ -157,14 +156,15 @@ public class SimulationMenu extends JMenuBar {
|
|
|
menuPanel.setLayout(gblmenuPanel);
|
|
|
|
|
|
|
|
|
- simButton.addPropertyChangeListener(new PropertyChangeListener() {
|
|
|
+ simButton.addActionListener(new ActionListener() {
|
|
|
|
|
|
@Override
|
|
|
- public void propertyChange(PropertyChangeEvent evt) {
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
controller.setIsSimulation(simButton.isSelected());
|
|
|
controller.calculateStateForCurrentTimeStep();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
GridBagConstraints gbcsimButton = new GridBagConstraints();
|
|
|
gbcsimButton.anchor = GridBagConstraints.NORTHWEST;
|
|
|
gbcsimButton.insets = new Insets(0, 0, 0, 5);
|
|
@@ -218,7 +218,6 @@ public class SimulationMenu extends JMenuBar {
|
|
|
|
|
|
public void setAlgorithm(File file) {
|
|
|
try {
|
|
|
-
|
|
|
|
|
|
|
|
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
|
@@ -226,19 +225,18 @@ public class SimulationMenu extends JMenuBar {
|
|
|
compiler.run(null, null, null, file.getPath());
|
|
|
|
|
|
|
|
|
- controller.addTextToConsole(root.toString());
|
|
|
URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { root.toURI().toURL() });
|
|
|
+
|
|
|
Class<?> cls = Class.forName("projectPackage.APITest", true, classLoader);
|
|
|
|
|
|
Object t = cls.newInstance();
|
|
|
|
|
|
- controller.addTextToConsole(Languages.getLanguage()[87]);
|
|
|
+ controller.addTextToConsole("Selected Alogrithm" + cls.newInstance());
|
|
|
|
|
|
controller.setAlgorithm(t);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
- e.printStackTrace();
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|