summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-21 19:01:48 +0000
committerPaul Buetow <paul@buetow.org>2008-05-21 19:01:48 +0000
commitdb4ae1c41883f6f78d8107429f7f4871c45f47d5 (patch)
treed84d754176060afddc89b00d6cf7d4b97d3d049f
parent004458bb854fe4376fe35ec55d7f08853e08895b (diff)
Ok inline editor seems to work.
-rw-r--r--sources/prefs/VSDefaultPrefs.java7
-rw-r--r--sources/prefs/editors/VSBetterEditor.java40
-rw-r--r--sources/prefs/editors/VSEditor.java113
-rw-r--r--sources/prefs/editors/VSEditorFrame.java143
-rw-r--r--sources/prefs/editors/VSEditorTable.java46
-rw-r--r--sources/prefs/editors/VSProcessEditor.java64
-rw-r--r--sources/prefs/editors/VSSimulationEditor.java48
-rw-r--r--sources/simulator/VSSimulation.java27
-rw-r--r--sources/simulator/VSSimulationCanvas.java25
-rw-r--r--sources/simulator/VSSimulatorFrame.java4
10 files changed, 161 insertions, 356 deletions
diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java
index b17c29f..5ee4f2f 100644
--- a/sources/prefs/VSDefaultPrefs.java
+++ b/sources/prefs/VSDefaultPrefs.java
@@ -80,13 +80,12 @@ public class VSDefaultPrefs extends VSPrefs {
initString("lang.variables.global", "Globale Variablen");
initString("lang.prefs", "Einstellungen");
initString("lang.prefs.ext", "Erweiterte Einstellungen");
- initString("lang.prefs.info!", "Prozesseinstellungen können für jeden Prozess einzelnd eingestellt werden. Die folgenden Werte sind lediglich die globalen Defaultwerte, die für neue Prozesse verwendet werden!");
+ initString("lang.prefs.info!", "Prozessvariablen können für jeden Prozess einzelnd eingestellt werden. Die hier gezeigen Prozessvariablen sind lediglich die globalen Defaultwerte, die für neue Prozesse verwendet werden!");
initString("lang.prefs.more", "Mehr Einstellungen");
initString("lang.prefs.process", "Prozesseinstellungen");
initString("lang.prefs.process.ext", "Erweiterte Prozesseinstellungen");
initString("lang.prefs.process.info!", "Änderungen werden erst nach Betätigen des \"Übernehmen\" Knopfes übernommen!");
- initString("lang.prefs.protocol", "Protokolleinstellungen");
- initString("lang.prefs.protocol.info!", "Änderungen werden erst nach Betätigen des \"Übernehmen\" oder Knopfes übernommen!");
+ //initString("lang.prefs.protocol", "Protokolleinstellungen");
initString("lang.process", "Prozess");
initString("lang.process.id", "PID");
initString("lang.process.new", "Neuer Prozess");
@@ -165,7 +164,7 @@ public class VSDefaultPrefs extends VSPrefs {
initInteger("keyevent.start", KeyEvent.VK_S, null, 0, 100);
initInteger("keyevent.stop", KeyEvent.VK_P, null, 0, 100);
- initIntegerUnit("window.prefs.xsize", 350, "X-Grösse des Einstellungsfensters", 550, 3200, "px");
+ initIntegerUnit("window.prefs.xsize", 400, "X-Grösse des Einstellungsfensters", 550, 3200, "px");
initIntegerUnit("window.prefs.ysize", 400, "Y-Grösse des Einstellungsfensters", 640, 2400, "px");
initIntegerUnit("window.loggsize", 300, "Y-Grösse des Loggingfensters", 100, 1000, "px");
initIntegerUnit("window.splitsize", 320, null, 100, 1000, "px");
diff --git a/sources/prefs/editors/VSBetterEditor.java b/sources/prefs/editors/VSBetterEditor.java
index 217b13b..da0a069 100644
--- a/sources/prefs/editors/VSBetterEditor.java
+++ b/sources/prefs/editors/VSBetterEditor.java
@@ -14,7 +14,7 @@ import utils.*;
public abstract class VSBetterEditor extends VSEditor {
private Container contentPane;
- protected VSInfoArea infoArea;
+ private VSInfoArea infoArea;
private String title;
public VSBetterEditor(VSPrefs prefs, VSPrefs prefsToEdit, String title) {
@@ -23,18 +23,12 @@ public abstract class VSBetterEditor extends VSEditor {
this.contentPane = createContentPane();
}
- public VSBetterEditor(VSPrefs prefs, VSPrefs prefsToEdit, String title, int prefsCategory) {
- super(prefs, prefsToEdit, prefsCategory);
- this.title = title;
- this.contentPane = createContentPane();
- }
-
public String getTitle() {
return title;
}
public Container getContentPane() {
- contentPane.setBackground(Color.WHITE);
+ contentPane.setBackground(Color.WHITE);
return contentPane;
}
@@ -43,32 +37,22 @@ public abstract class VSBetterEditor extends VSEditor {
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
infoArea = new VSInfoArea();
- JPanel editPanel = super.editPanel;
- JPanel buttonPanel = createButtonPanel();
+ JPanel editPanel = getEditPanel();
+ JPanel buttonPanel = getButtonPanel();
- //JScrollPane scrollPane = new JScrollPane(editPanel);
- panel.add(infoArea);
+ JScrollPane scrollPane = new JScrollPane(editPanel);
panel.add(editPanel);
+ //panel.add(infoArea);
panel.add(buttonPanel);
return panel;
}
- protected void addToEditPanelFront(JPanel editPanel) { }
-
- protected void addToEditPanelLast(JPanel editPanel) { }
+ protected void addToButtonPanelFront(JPanel buttonPanel) { }
+ protected void addToButtonPanelLast(JPanel buttonPanel) { }
- private JPanel createButtonPanel() {
- JPanel buttonPanel = super.buttonPanel;
-
- JButton cancelButton = new JButton(
- prefs.getString("lang.cancel"));
- cancelButton.setMnemonic(prefs.getInteger("keyevent.cancel"));
- cancelButton.addActionListener(this);
- buttonPanel.add(cancelButton);
-
- return buttonPanel;
- }
+ protected void addToEditPanelFront(JPanel editPanel, VSEditorTable editTable) { }
+ protected void addToEditPanelLast(JPanel editPanel, VSEditorTable editTable) { }
public void actionPerformed(ActionEvent e) {
//String actionCommand = e.getActionCommand();
@@ -77,5 +61,7 @@ public abstract class VSBetterEditor extends VSEditor {
super.actionPerformed(e);
}
- public void newVSEditorInstance(VSPrefs prefs, VSPrefs prefsToEdit, int prefsCategory) { };
+ protected VSInfoArea getInfoArea() {
+ return infoArea;
+ }
}
diff --git a/sources/prefs/editors/VSEditor.java b/sources/prefs/editors/VSEditor.java
index 6e554b2..d3d33e8 100644
--- a/sources/prefs/editors/VSEditor.java
+++ b/sources/prefs/editors/VSEditor.java
@@ -16,7 +16,6 @@ public abstract class VSEditor implements ActionListener {
protected static final int LABEL_FIELD_COLS = 18;
protected static final int VALUE_FIELD_COLS = 7;
protected static final int MIN_UNIT_LENGTH = 5;
- protected int prefsCategory;
private HashMap<String,JComboBox> integerFields;
private HashMap<String,JTextField> colorFields;
private HashMap<String,JTextField> floatFields;
@@ -29,8 +28,8 @@ public abstract class VSEditor implements ActionListener {
private Vector<String> longKeys;
private Vector<String> booleanKeys;
private Vector<String> stringKeys;
- protected JPanel buttonPanel;
- protected JPanel editPanel;
+ private JPanel buttonPanel;
+ private JPanel editPanel;
protected VSPrefs prefs;
protected VSPrefs prefsToEdit;
public static final int ALL_PREFERENCES = 0;
@@ -39,15 +38,7 @@ public abstract class VSEditor implements ActionListener {
protected VSEditorTable editTable;
public VSEditor(VSPrefs prefs, VSPrefs prefsToEdit) {
- init(prefs, prefsToEdit, SIMULATION_PREFERENCES);
- }
-
- public VSEditor(VSPrefs prefs, VSPrefs prefsToEdit, int prefsCategory) {
- init(prefs, prefsToEdit, prefsCategory);
- }
-
- public int getPrefsCategory() {
- return prefsCategory;
+ init(prefs, prefsToEdit);
}
public void setPrefs(VSPrefs prefs) {
@@ -71,21 +62,20 @@ public abstract class VSEditor implements ActionListener {
frame.dispose();
}
- private void init(VSPrefs prefs, VSPrefs prefsToEdit, int prefsCategory) {
+ protected void disposeFrameWithParentIfExists() {
+ if (frame != null)
+ frame.disposeWithParent();
+ }
+
+ private void init(VSPrefs prefs, VSPrefs prefsToEdit) {
this.prefs = prefs;
this.prefsToEdit = prefsToEdit;
- this.prefsCategory = prefsCategory;
+
+ editPanel = createEditPanel();
+ buttonPanel = createButtonPanel();
final String keyStartsWith = "sim.";
- boolean reversed;
-
- switch (prefsCategory) {
- case SIMULATION_PREFERENCES:
- reversed = false;
- break;
- default:
- reversed = true;
- }
+ boolean reversed = false;
colorKeys = setToSortedVector(prefsToEdit.getColorKeySet(), keyStartsWith, reversed);
floatKeys = setToSortedVector(prefsToEdit.getFloatKeySet(), keyStartsWith, reversed);
@@ -93,7 +83,6 @@ public abstract class VSEditor implements ActionListener {
longKeys = setToSortedVector(prefsToEdit.getLongKeySet(), keyStartsWith, reversed);
booleanKeys = setToSortedVector(prefsToEdit.getBooleanKeySet(), keyStartsWith, reversed);
stringKeys = setToSortedVector(prefsToEdit.getStringKeySet(), keyStartsWith, reversed);
-
colorFields = new HashMap<String,JTextField>();
floatFields = new HashMap<String,JTextField>();
integerFields = new HashMap<String,JComboBox>();
@@ -101,8 +90,9 @@ public abstract class VSEditor implements ActionListener {
booleanFields = new HashMap<String,JCheckBox>();
stringFields = new HashMap<String,JTextField>();
- editPanel = createEditPanel();
- buttonPanel = createButtonPanel();
+ addToEditPanelFront(editPanel, editTable);
+ fillEditPanel(editPanel, editTable);
+ addToEditPanelLast(editPanel, editTable);
}
private Vector<String> setToSortedVector(Set<String> set, String startsWith, boolean reversed) {
@@ -123,15 +113,13 @@ public abstract class VSEditor implements ActionListener {
return vector;
}
+ abstract protected void addToButtonPanelFront(JPanel buttonPanel);
+ abstract protected void addToButtonPanelLast(JPanel buttonPanel);
+
private JPanel createButtonPanel() {
JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.WHITE);
-
- JButton saveButton = new JButton(
- prefs.getString("lang.ok"));
- saveButton.setMnemonic(prefs.getInteger("keyevent.ok"));
- saveButton.addActionListener(this);
- buttonPanel.add(saveButton);
+ addToButtonPanelFront(buttonPanel);
JButton resetButton = new JButton(
prefs.getString("lang.reset"));
@@ -139,25 +127,26 @@ public abstract class VSEditor implements ActionListener {
resetButton.addActionListener(this);
buttonPanel.add(resetButton);
+ addToButtonPanelLast(buttonPanel);
+
return buttonPanel;
}
- abstract protected void addToEditPanelFront(JPanel editPanel);
-
- abstract protected void addToEditPanelLast(JPanel editPanel);
+ abstract protected void addToEditPanelFront(JPanel editPanel, VSEditorTable editTable);
+ abstract protected void addToEditPanelLast(JPanel editPanel, VSEditorTable editTable);
private JPanel createUnitPanel(Component comp, String key) {
JPanel unitPanel = new JPanel(new GridBagLayout());
unitPanel.setBackground(Color.WHITE);
- unitPanel.setBorder(null);
+ unitPanel.setBorder(null);
String unitText = prefs.getUnit(key);
if (unitText == null)
unitText = "";
- unitText = " " + unitText;
- while (unitText.length() < MIN_UNIT_LENGTH)
- unitText = unitText + " ";
+ unitText = " " + unitText;
+ while (unitText.length() < MIN_UNIT_LENGTH)
+ unitText = unitText + " ";
JLabel unitLabel = new JLabel(unitText);
unitPanel.setLayout(new BoxLayout(unitPanel, BoxLayout.X_AXIS));
@@ -171,13 +160,15 @@ public abstract class VSEditor implements ActionListener {
JPanel editPanel = new JPanel();
editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.Y_AXIS));
editPanel.setBackground(Color.WHITE);
- addToEditPanelFront(editPanel);
editTable = new VSEditorTable(prefs);
- JScrollPane scrollPane = new JScrollPane(editTable);
- //scrollPane.setBackground(Color.WHITE);
+ JScrollPane scrollPane = new JScrollPane(editTable);
editPanel.add(scrollPane);
+ return editPanel;
+ }
+
+ private void fillEditPanel(JPanel editPanel, VSEditorTable editTable) {
for (String key : integerKeys) {
String fullKey = VSPrefs.INTEGER_PREFIX + key;
String descr = prefsToEdit.getDescription(fullKey);
@@ -201,9 +192,8 @@ public abstract class VSEditor implements ActionListener {
for (int i = minValue; i <= maxValue; ++i)
valComboBox.addItem(new Integer(i));
- //valComboBox.repaint();
integerFields.put(key, valComboBox);
- valComboBox.setBorder(null);
+ valComboBox.setBorder(null);
editTable.addVariable(label, createUnitPanel(valComboBox, fullKey));
}
@@ -215,7 +205,7 @@ public abstract class VSEditor implements ActionListener {
JCheckBox valField = new JCheckBox(activated, prefsToEdit.getBoolean(key));
valField.setBackground(Color.WHITE);
booleanFields.put(key, valField);
- valField.setBorder(null);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
@@ -233,7 +223,7 @@ public abstract class VSEditor implements ActionListener {
});
valField.setText(""+prefsToEdit.getLong(key));
longFields.put(key, valField);
- valField.setBorder(null);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
@@ -252,7 +242,7 @@ public abstract class VSEditor implements ActionListener {
});
valField.setText(""+prefsToEdit.getFloat(key));
floatFields.put(key, valField);
- valField.setBorder(null);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
@@ -287,7 +277,7 @@ public abstract class VSEditor implements ActionListener {
}
});
colorFields.put(key, valField);
- valField.setBorder(null);
+ valField.setBorder(null);
editTable.addVariable(label, valField);
}
@@ -305,13 +295,9 @@ public abstract class VSEditor implements ActionListener {
});
valField.setText(prefsToEdit.getString(key));
stringFields.put(key, valField);
- valField.setBorder(null);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
-
- addToEditPanelLast(editPanel);
-
- return editPanel;
}
protected void resetEditPanel() {
@@ -348,20 +334,16 @@ public abstract class VSEditor implements ActionListener {
protected void savePrefs() {
int i = 0;
- System.out.println("FOO" + ++i);
for (String key : integerKeys) {
JComboBox valComboBox = integerFields.get(key);
- System.out.println(valComboBox == null);
prefsToEdit.setInteger(key, (Integer) valComboBox.getSelectedItem());
}
- System.out.println("FOO" + ++i);
for (String key : booleanKeys) {
JCheckBox valField = booleanFields.get(key);
prefsToEdit.setBoolean(key, valField.isSelected());
}
- System.out.println("FOO" + ++i);
for (String key : floatKeys) {
JTextField valField = floatFields.get(key);
@@ -374,7 +356,6 @@ public abstract class VSEditor implements ActionListener {
}
}
- System.out.println("FOO" + ++i);
for (String key : longKeys) {
JTextField valField = longFields.get(key);
@@ -387,13 +368,11 @@ public abstract class VSEditor implements ActionListener {
}
}
- System.out.println("FOO" + ++i);
for (String key : colorKeys) {
JTextField valField = colorFields.get(key);
prefsToEdit.setColor(key, valField.getBackground());
}
- System.out.println("FOO" + ++i);
for (String key : stringKeys) {
JTextField valField = stringFields.get(key);
prefsToEdit.setString(key, valField.getText());
@@ -403,19 +382,11 @@ public abstract class VSEditor implements ActionListener {
public void actionPerformed(ActionEvent e) {
String actionCommand = e.getActionCommand();
- if (actionCommand.equals(prefs.getString("lang.ok"))) {
- savePrefs();
-
- } else if (actionCommand.equals(prefs.getString("lang.save"))) {
+ if (actionCommand.equals(prefs.getString("lang.takeover"))) {
savePrefs();
- prefs.saveFile();
} else if (actionCommand.equals(prefs.getString("lang.reset"))) {
resetEditPanel();
-
- } else if (actionCommand.equals(prefs.getString("lang.default"))) {
- prefs.fillWithDefaults();
- resetEditPanel();
}
}
@@ -423,6 +394,10 @@ public abstract class VSEditor implements ActionListener {
return editPanel;
}
+ public VSEditorTable getEditTable() {
+ return editTable;
+ }
+
public JPanel getButtonPanel() {
return buttonPanel;
}
diff --git a/sources/prefs/editors/VSEditorFrame.java b/sources/prefs/editors/VSEditorFrame.java
index 918b307..11ced6a 100644
--- a/sources/prefs/editors/VSEditorFrame.java
+++ b/sources/prefs/editors/VSEditorFrame.java
@@ -25,7 +25,7 @@ public class VSEditorFrame extends VSFrame implements ActionListener {
private void init() {
editor.setFrame(this);
- setJMenuBar(createJMenuBar());
+ fillButtonPanel(editor.getButtonPanel());
setContentPane(editor.getContentPane());
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(prefs.getInteger("window.prefs.xsize"),
@@ -34,142 +34,31 @@ public class VSEditorFrame extends VSFrame implements ActionListener {
setVisible(true);
}
- private JMenuBar createJMenuBar() {
- /* File menu */
- JMenu menuFile = new JMenu(
- prefs.getString("lang.file"));
- menuFile.setMnemonic(prefs.getInteger("keyevent.file"));
- JMenuItem menuItem;
-
- menuItem = new JMenuItem(
- prefs.getString("lang.save"));
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.save"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- menuFile.add(menuItem);
-
- if (!(editor instanceof VSSimulationEditor))
- menuItem.setEnabled(false);
-
- menuItem = new JMenuItem(
- prefs.getString("lang.saveas"));
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.saveas"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- menuFile.add(menuItem);
-
- if (!(editor instanceof VSSimulationEditor))
- menuItem.setEnabled(false);
-
- menuItem = new JMenuItem(
- prefs.getString("lang.open"));
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.open"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- menuFile.add(menuItem);
-
- if (!(editor instanceof VSSimulationEditor))
- menuItem.setEnabled(false);
-
- menuFile.addSeparator();
-
- menuItem = new JMenuItem(
- prefs.getString("lang.close"));
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.close"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- menuFile.add(menuItem);
-
- /* Edit menu */
- JMenu menuEdit = new JMenu(
- prefs.getString("lang.edit"));
- menuEdit.setMnemonic(prefs.getInteger("keyevent.edit"));
-
- menuItem = new JMenuItem(
- prefs.getString("lang.default"));
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.default"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- menuEdit.add(menuItem);
-
- if (!(editor instanceof VSSimulationEditor))
- menuItem.setEnabled(false);
-
- menuEdit.addSeparator();
-
- menuItem = new JMenuItem(prefs.getString("lang.prefs"));
- /*
- if (editor.getOrefsCategory() == ALL_PREFERENCES) {
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.prefs"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- }
- */
- menuItem.setEnabled(false);
- menuEdit.add(menuItem);
-
- menuItem = new JMenuItem(prefs.getString("lang.prefs.ext"));
- if (editor.getPrefsCategory() == VSEditor.SIMULATION_PREFERENCES) {
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- prefs.getInteger("keyevent.prefs.ext"),
- ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- } else {
- menuItem.setEnabled(false);
- }
- menuEdit.add(menuItem);
-
- JMenuBar mainMenuBar = new JMenuBar();
- mainMenuBar.add(menuFile);
- mainMenuBar.add(menuEdit);
-
- return mainMenuBar;
+ private void fillButtonPanel(JPanel buttonPanel) {
+ JButton okButton = new JButton(
+ prefs.getString("lang.ok"));
+ okButton.setMnemonic(prefs.getInteger("keyevent.ok"));
+ okButton.addActionListener(this);
+ buttonPanel.add(okButton, 0);
+
+ JButton cancelButton = new JButton(
+ prefs.getString("lang.cancel"));
+ cancelButton.setMnemonic(prefs.getInteger("keyevent.cancel"));
+ cancelButton.addActionListener(this);
+ buttonPanel.add(cancelButton, 1);
+ buttonPanel.repaint();
}
public void actionPerformed(ActionEvent e) {
String actionCommand = e.getActionCommand();
- if (actionCommand.equals(prefs.getString("lang.close"))) {
+ if (actionCommand.equals(prefs.getString("lang.ok"))) {
+ editor.actionPerformed(e);
dispose();
- } else if (actionCommand.equals(prefs.getString("lang.saveas"))) {
- JFileChooser fileChooser = new JFileChooser();
- int ret = fileChooser.showSaveDialog(this);
-
- if (ret == JFileChooser.APPROVE_OPTION) {
- File file = fileChooser.getSelectedFile();
- editor.savePrefs();
- prefs.saveFile(file.getName());
- }
-
- } else if (actionCommand.equals(prefs.getString("lang.open"))) {
- JFileChooser fileChooser = new JFileChooser();
- fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
- int ret = fileChooser.showOpenDialog(this);
-
- if (ret == JFileChooser.APPROVE_OPTION) {
- File file = fileChooser.getSelectedFile();
- VSPrefs newPrefs = VSDefaultPrefs.init(file.getName());
- editor.setPrefs(newPrefs);
- editor.setPrefsToEdit(newPrefs);
- editor.resetEditPanel();
- }
-
} else if (actionCommand.equals(prefs.getString("lang.cancel"))) {
dispose();
- } else if (actionCommand.equals(prefs.getString("lang.prefs"))) {
- editor.newVSEditorInstance(prefs, prefs, VSEditor.SIMULATION_PREFERENCES);
-
- } else if (actionCommand.equals(prefs.getString("lang.prefs.ext"))) {
- editor.newVSEditorInstance(prefs, prefs, VSEditor.ALL_PREFERENCES);
-
} else {
editor.actionPerformed(e);
}
diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java
index ef4488f..8d5de52 100644
--- a/sources/prefs/editors/VSEditorTable.java
+++ b/sources/prefs/editors/VSEditorTable.java
@@ -10,7 +10,7 @@ import javax.swing.table.*;
import prefs.*;
public class VSEditorTable extends JTable {
- private static final int MIN_ROWS = 20;
+ private static final int MIN_ROWS = 20;
private VSPrefs prefs;
private ArrayList<VSNode> nodes;
private VSEditorTableModel model;
@@ -32,9 +32,9 @@ public class VSEditorTable extends JTable {
return comp;
}
- public Component getRendererComponent() {
- return comp;
- }
+ public Component getRendererComponent() {
+ return comp;
+ }
}
private class VSEditorTableModel extends AbstractTableModel implements TableCellRenderer {
@@ -78,41 +78,41 @@ public class VSEditorTable extends JTable {
VSNode node = nodes.get(row);
- if (col == 0) {
- JTextField field = new JTextField(" "+node.getKey()+":");
- field.setBorder(null);
- field.setEditable(false);
- field.setBackground(Color.WHITE);
- return field;
- }
+ if (col == 0) {
+ JTextField field = new JTextField(" "+node.getKey()+":");
+ field.setBorder(null);
+ field.setEditable(false);
+ field.setBackground(Color.WHITE);
+ return field;
+ }
return node.getRendererComponent();
}
}
- private class VSTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+ private class VSTableCellEditor extends AbstractCellEditor implements TableCellEditor {
- public Component getTableCellEditorComponent(JTable table, Object object,
- boolean isSelected, int row, int col) {
+ public Component getTableCellEditorComponent(JTable table, Object object,
+ boolean isSelected, int row, int col) {
return nodes.get(row).getComponent();
- }
+ }
- public Object getCellEditorValue() {
- return new String("");
+ public Object getCellEditorValue() {
+ return new String("");
+ }
}
- }
public VSEditorTable(VSPrefs prefs) {
this.prefs = prefs;
this.nodes = new ArrayList<VSNode>();
this.model = new VSEditorTableModel();
setModel(model);
- setDefaultRenderer(Object.class, model);
- setDefaultEditor(Object.class, new VSTableCellEditor());
- setIntercellSpacing(new Dimension(5, 5));
- setRowHeight(25);
+ setDefaultRenderer(Object.class, model);
+ setDefaultEditor(Object.class, new VSTableCellEditor());
+ setIntercellSpacing(new Dimension(5, 5));
+ setRowHeight(25);
setBackground(Color.WHITE);
- getTableHeader().setVisible(false);
+ getTableHeader().setVisible(false);
TableColumn col = getColumnModel().getColumn(1);
col.setMaxWidth(90);
col.setResizable(false);
diff --git a/sources/prefs/editors/VSProcessEditor.java b/sources/prefs/editors/VSProcessEditor.java
index 1632ff1..c8c1339 100644
--- a/sources/prefs/editors/VSProcessEditor.java
+++ b/sources/prefs/editors/VSProcessEditor.java
@@ -18,60 +18,20 @@ import prefs.VSPrefs;
public class VSProcessEditor extends VSBetterEditor {
private VSProcess process;
- private String title;
-
+ public static boolean TAKEOVER_BUTTON;
public VSProcessEditor(VSPrefs prefs, VSProcess process) {
super(prefs, process, prefs.getString("name") + " - " + prefs.getString("lang.prefs.process"));;
this.process = process;
- init();
- }
-
- public VSProcessEditor(VSPrefs prefs, VSProcess process, int prefsCategory) {
- super(prefs, process, prefs.getString("name") + " - " + prefs.getString("lang.prefs.process"
- + (prefsCategory == ALL_PREFERENCES ? ".ext" : "")), prefsCategory);
-
- this.process = process;
- init();
- }
-
- private void init() {
- infoArea.setText(prefs.getString("lang.prefs.process.info!"));
- VSFrame frame = getFrame();
- if (frame != null)
- frame.disposeWithParent();
- createButtonPanel();
- }
-
- public String getTitle() {
- return title;
- }
-
- protected void addToEditPanelFront(JPanel editPanel) {
- super.addToEditPanelFront(editPanel);
-
- if (prefsCategory != SIMULATION_PREFERENCES)
- return;
-
- }
-
- protected void resetEditPanel() {
- super.resetEditPanel();
- }
-
- protected void savePrefs() {
- super.savePrefs();
+ disposeFrameWithParentIfExists();
+ getInfoArea().setText(prefs.getString("lang.prefs.process.info!"));
}
- private JPanel createButtonPanel() {
- JPanel buttonPanel = super.buttonPanel;
-
- JButton cancelButton = new JButton(
+ protected void addToButtonPanelFront(JPanel buttonPanel) {
+ JButton takeoverButton = new JButton(
prefs.getString("lang.takeover"));
- cancelButton.setMnemonic(prefs.getInteger("keyevent.takeover"));
- cancelButton.addActionListener(this);
- buttonPanel.add(cancelButton);
-
- return buttonPanel;
+ takeoverButton.setMnemonic(prefs.getInteger("keyevent.takeover"));
+ takeoverButton.addActionListener(this);
+ buttonPanel.add(takeoverButton);
}
public void actionPerformed(ActionEvent e) {
@@ -80,7 +40,6 @@ public class VSProcessEditor extends VSBetterEditor {
if (actionCommand.equals(prefs.getString("lang.ok"))) {
savePrefs();
process.updateFromVSPrefs();
- disposeFrameIfExists();
} else if (actionCommand.equals(prefs.getString("lang.takeover"))) {
savePrefs();
@@ -90,11 +49,4 @@ public class VSProcessEditor extends VSBetterEditor {
super.actionPerformed(e);
}
}
-
- public void newVSEditorInstance(VSPrefs prefs, VSPrefs prefsToEdit, int prefsCategory) {
- if (prefsToEdit instanceof VSProcess) {
- VSProcess process = (VSProcess) prefsToEdit;
- new VSEditorFrame(prefs, getFrame(), new VSProcessEditor(prefs, process, prefsCategory));
- }
- }
}
diff --git a/sources/prefs/editors/VSSimulationEditor.java b/sources/prefs/editors/VSSimulationEditor.java
index b4566ef..dc81c67 100644
--- a/sources/prefs/editors/VSSimulationEditor.java
+++ b/sources/prefs/editors/VSSimulationEditor.java
@@ -13,54 +13,40 @@ import utils.*;
import prefs.*;
public class VSSimulationEditor extends VSBetterEditor {
- private boolean startNewSimulation;
private VSSimulatorFrame simulatorFrame;
+ public static boolean TAKEOVER_BUTTON;
public VSSimulationEditor(VSPrefs prefs, VSSimulatorFrame simulatorFrame) {
super(prefs, prefs, prefs.getString("name")
+ " - " + prefs.getString("lang.prefs"));
this.simulatorFrame = simulatorFrame;
-
- startNewSimulation = true;
- init();
- }
-
- public VSSimulationEditor(VSPrefs prefs, int prefsCategory) {
- super(prefs, prefs, prefs.getString("name")
- + " - " + prefs.getString("lang.prefs"
- + (prefsCategory == ALL_PREFERENCES ? ".ext" : "")),
- prefsCategory);
-
- startNewSimulation = false;
- init();
+ getInfoArea().setText(prefs.getString("lang.prefs.info!"));
}
- private void init() {
- infoArea.setText(prefs.getString("lang.prefs.info!"));
+ protected void addToButtonPanelFront(JPanel buttonPanel) {
+ if (TAKEOVER_BUTTON) {
+ TAKEOVER_BUTTON = false;
+ JButton takeoverButton = new JButton(
+ prefs.getString("lang.takeover"));
+ takeoverButton.setMnemonic(prefs.getInteger("keyevent.takeover"));
+ takeoverButton.addActionListener(this);
+ buttonPanel.add(takeoverButton);
+ }
}
public void actionPerformed(ActionEvent e) {
String actionCommand = e.getActionCommand();
- if (actionCommand.equals(prefs.getString("lang.ok"))) {
- super.actionPerformed(e);
- prefsToEdit.saveFile();
-
- VSFrame frame = getFrame();
- if (frame != null)
- frame.dispose();
+ if (actionCommand.equals(prefs.getString("lang.takeover"))) {
+ savePrefs();
+ simulatorFrame.getCurrentSimulation().updateFromPrefs();
- if (startNewSimulation)
- simulatorFrame.addSimulation(
- new VSSimulation(prefs, simulatorFrame));
+ } else if (actionCommand.equals(prefs.getString("lang.ok"))) {
+ savePrefs();
+ simulatorFrame.addSimulation(new VSSimulation(prefsToEdit, simulatorFrame));
} else {
super.actionPerformed(e);
}
}
-
- public void newVSEditorInstance(VSPrefs prefs, VSPrefs prefsToEdit, int prefsCategory) {
- VSPrefs newPrefs = VSDefaultPrefs.init();
- new VSEditorFrame(newPrefs, getFrame(), new VSSimulationEditor(prefs, prefsCategory));
- }
}
diff --git a/sources/simulator/VSSimulation.java b/sources/simulator/VSSimulation.java
index f5a3e3b..9c9bf81 100644
--- a/sources/simulator/VSSimulation.java
+++ b/sources/simulator/VSSimulation.java
@@ -36,6 +36,7 @@ public class VSSimulation extends JPanel {
private ArrayList<VSCreateTask> createTasks;
private JSplitPane splitPaneH;
private JSplitPane splitPaneV;
+ private JSplitPane splitPane1;
private Thread thread;
private VSLogging logging;
private VSPrefs prefs;
@@ -104,6 +105,7 @@ public class VSSimulation extends JPanel {
logging.logg(prefs.getString("lang.simulation.new"));
fillContentPane();
+ updateFromPrefs();
int numProcesses = simulationCanvas.getNumProcesses();
@@ -124,18 +126,12 @@ public class VSSimulation extends JPanel {
JTextArea loggingArea = logging.getLoggingArea();
splitPaneH = new JSplitPane();
- splitPaneH.setDividerLocation(
- prefs.getInteger("window.splitsize"));
splitPaneV = new JSplitPane();
- splitPaneV.setDividerLocation(
- prefs.getInteger("window.ysize")
- - prefs.getInteger("window.loggsize"));
simulationCanvas = new VSSimulationCanvas(prefs, this, logging);
taskManager = simulationCanvas.getTaskManager();
logging.setSimulationCanvas(simulationCanvas);
- simulationCanvas.setBackground(prefs.getColor("paintarea.background"));
JPanel canvasPanel = new JPanel();
canvasPanel.setLayout(new GridLayout(1, 1, 3, 3));
@@ -286,7 +282,6 @@ public class VSSimulation extends JPanel {
globalPIDComboBox.addItem(prefs.getString("lang.all"));
tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT);
- //tabbedPane.setBackground(Color.WHITE);
tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
JTabbedPane pane = (JTabbedPane) ce.getSource();
@@ -298,11 +293,10 @@ public class VSSimulation extends JPanel {
JPanel localPanel = createTaskLabel(VSTaskManagerTableModel.LOCAL);
JPanel globalPanel = createTaskLabel(VSTaskManagerTableModel.GLOBAL);
- JSplitPane splitPane1 = new JSplitPane();
+ splitPane1 = new JSplitPane();
splitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane1.setTopComponent(localPanel);
splitPane1.setBottomComponent(globalPanel);
- splitPane1.setDividerLocation((int) (getPaintSize()/2) - 20);
splitPane1.setOneTouchExpandable(true);
tabbedPane.addTab(prefs.getString("lang.events"), splitPane1);
@@ -342,6 +336,7 @@ public class VSSimulation extends JPanel {
tabbedPane.add(prefs.getString("lang.variables"), null);
tabbedPane.add(prefs.getString("lang.variables.global"), null);
+ VSSimulationEditor.TAKEOVER_BUTTON = true;
VSSimulationEditor editor = new VSSimulationEditor(prefs, simulatorFrame);
tabbedPane.setComponentAt(2, editor.getContentPane());
@@ -856,4 +851,18 @@ public class VSSimulation extends JPanel {
public VSFrame getSimulatorFrame() {
return simulatorFrame;
}
+
+ public void updateFromPrefs() {
+ splitPaneH.setDividerLocation(
+ prefs.getInteger("window.splitsize"));
+
+ splitPaneV.setDividerLocation(
+ prefs.getInteger("window.ysize")
+ - prefs.getInteger("window.loggsize"));
+
+ splitPane1.setDividerLocation((int) (getPaintSize()/2) - 20);
+
+ simulationCanvas.setBackground(prefs.getColor("paintarea.background"));
+ simulationCanvas.updateFromPrefs();
+ }
}
diff --git a/sources/simulator/VSSimulationCanvas.java b/sources/simulator/VSSimulationCanvas.java
index 3fb6add..bf3ec1c 100644
--- a/sources/simulator/VSSimulationCanvas.java
+++ b/sources/simulator/VSSimulationCanvas.java
@@ -162,16 +162,7 @@ public class VSSimulationCanvas extends Canvas implements Runnable, MouseMotionL
this.processes = new LinkedList<VSProcess>();
numProcesses = prefs.getInteger("sim.process.num");
- untilTime = prefs.getInteger("sim.seconds") * 1000;
- recalcOnWindowChanged();
-
- secondsSpaceing = (int) untilTime / 15000;
- if (secondsSpaceing == 0)
- secondsSpaceing = 1;
-
- threadSleep = (int) untilTime / 7500;
- if (threadSleep == 0)
- threadSleep = 1;
+ updateFromPrefs();
VSProcess.resetProcessCounter();
for (int i = 0; i < numProcesses; ++i)
@@ -808,4 +799,18 @@ public class VSSimulationCanvas extends Canvas implements Runnable, MouseMotionL
return arr;
}
+
+ public void updateFromPrefs() {
+ untilTime = prefs.getInteger("sim.seconds") * 1000;
+
+ secondsSpaceing = (int) untilTime / 15000;
+ if (secondsSpaceing == 0)
+ secondsSpaceing = 1;
+
+ threadSleep = (int) untilTime / 7500;
+ if (threadSleep == 0)
+ threadSleep = 1;
+
+ recalcOnWindowChanged();
+ }
}
diff --git a/sources/simulator/VSSimulatorFrame.java b/sources/simulator/VSSimulatorFrame.java
index 37c0900..b455969 100644
--- a/sources/simulator/VSSimulatorFrame.java
+++ b/sources/simulator/VSSimulatorFrame.java
@@ -274,4 +274,8 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
tabbedPane.remove(simulationToRemove);
simulationToRemove.getSimulationCanvas().stopThread();
}
+
+ public VSSimulation getCurrentSimulation() {
+ return currentSimulation;
+ }
}