|
@@ -1,5 +1,7 @@
|
|
package ui.view;
|
|
package ui.view;
|
|
|
|
|
|
|
|
+import java.awt.Color;
|
|
|
|
+import java.awt.Component;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.ActionListener;
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
@@ -9,6 +11,7 @@ import java.net.URL;
|
|
import java.net.URLClassLoader;
|
|
import java.net.URLClassLoader;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
+import javax.swing.Action;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.JFileChooser;
|
|
@@ -16,28 +19,29 @@ import javax.swing.JFrame;
|
|
import javax.swing.JMenu;
|
|
import javax.swing.JMenu;
|
|
import javax.swing.JMenuBar;
|
|
import javax.swing.JMenuBar;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JMenuItem;
|
|
-import javax.swing.JPanel;
|
|
|
|
|
|
+import javax.swing.border.LineBorder;
|
|
import javax.tools.JavaCompiler;
|
|
import javax.tools.JavaCompiler;
|
|
import javax.tools.ToolProvider;
|
|
import javax.tools.ToolProvider;
|
|
|
|
|
|
|
|
+import javafx.scene.control.MenuItem;
|
|
|
|
+import sun.security.provider.NativePRNG.NonBlocking;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * This Class represents the Menu, where you can edit stuff about the
|
|
|
|
- * Simulation.
|
|
|
|
|
|
+ * This Class represents the Menu, where you can select the Algorithms.
|
|
*
|
|
*
|
|
* @author Gruppe14
|
|
* @author Gruppe14
|
|
*/
|
|
*/
|
|
-public class AlgorithmMenu extends JPanel{
|
|
|
|
|
|
+public class AlgorithmMenu extends JMenu {
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
- private JComboBox<Object> algoCombo = new JComboBox<>();
|
|
|
|
- JButton algoFolderButton = new JButton(Languages.getLanguage()[85]);
|
|
|
|
|
|
+ JMenuItem algoFolderButton = new JMenuItem("Selecte Algorithm Folder");
|
|
|
|
+ private JMenu mnSelectAlgorithm = new JMenu("Select Algorithm");
|
|
private HashMap<String, File> algosHash = new HashMap<>();
|
|
private HashMap<String, File> algosHash = new HashMap<>();
|
|
- private JPanel menuPanel = new JPanel();
|
|
|
|
-
|
|
|
|
|
|
+ private JMenuItem noneItem= new JMenuItem("none");
|
|
|
|
+
|
|
// root Directory
|
|
// root Directory
|
|
File root = null;
|
|
File root = null;
|
|
|
|
|
|
@@ -57,20 +61,8 @@ public class AlgorithmMenu extends JPanel{
|
|
// Init Stuff
|
|
// Init Stuff
|
|
this.model = mod;
|
|
this.model = mod;
|
|
this.controller = cont;
|
|
this.controller = cont;
|
|
-
|
|
|
|
- algoCombo.addItem("None");
|
|
|
|
|
|
+ this.setText("Algorithm");
|
|
|
|
|
|
- // Algorithm ComboBox Action
|
|
|
|
- algoCombo.addActionListener(new ActionListener() {
|
|
|
|
- @Override
|
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
|
- if (algoCombo.getSelectedIndex() != 0) {
|
|
|
|
- setAlgorithm(algosHash.get(algoCombo.getSelectedItem()), algoCombo.getSelectedItem() + "");
|
|
|
|
- }else{
|
|
|
|
- setAlgorithm(null, "non Chosen");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
|
|
// algoFolderButton Action
|
|
// algoFolderButton Action
|
|
algoFolderButton.addActionListener(new ActionListener() {
|
|
algoFolderButton.addActionListener(new ActionListener() {
|
|
@@ -87,8 +79,12 @@ public class AlgorithmMenu extends JPanel{
|
|
fileChooser.setAcceptAllFileFilterUsed(false);
|
|
fileChooser.setAcceptAllFileFilterUsed(false);
|
|
|
|
|
|
if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
- algoCombo.removeAllItems();
|
|
|
|
- algoCombo.addItem("non chosen");
|
|
|
|
|
|
+ //empty everything and reset the selected algorithm
|
|
|
|
+ controller.setAlgorithm(null);
|
|
|
|
+ mnSelectAlgorithm.removeAll();
|
|
|
|
+ mnSelectAlgorithm.add(noneItem);
|
|
|
|
+ noneItem.doClick();
|
|
|
|
+
|
|
File[] files = fileChooser.getSelectedFile().listFiles();
|
|
File[] files = fileChooser.getSelectedFile().listFiles();
|
|
// Set Root Folder Path
|
|
// Set Root Folder Path
|
|
root = new File(fileChooser.getCurrentDirectory().getPath());
|
|
root = new File(fileChooser.getCurrentDirectory().getPath());
|
|
@@ -103,8 +99,15 @@ public class AlgorithmMenu extends JPanel{
|
|
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);
|
|
|
|
-
|
|
|
|
|
|
+ JMenuItem tempItem = new JMenuItem(name);
|
|
|
|
+ tempItem.addActionListener(new ActionListener() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
+ setAlgorithm(algosHash.get(tempItem.getText()), tempItem.getText());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ mnSelectAlgorithm.add(tempItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,8 +118,14 @@ public class AlgorithmMenu extends JPanel{
|
|
|
|
|
|
// Add to Panel
|
|
// Add to Panel
|
|
this.add(algoFolderButton);
|
|
this.add(algoFolderButton);
|
|
-
|
|
|
|
- this.add(algoCombo);
|
|
|
|
|
|
+ this.add(mnSelectAlgorithm);
|
|
|
|
+ mnSelectAlgorithm.add(noneItem);
|
|
|
|
+ noneItem.addActionListener(new ActionListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
+ controller.setAlgorithm(null);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
public void setAlgorithm(File file, String name) {
|
|
public void setAlgorithm(File file, String name) {
|