diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-21 21:24:42 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-21 21:24:42 +0000 |
| commit | 6fd1d5c225c70677ef40ec7d76111b849e5d7d75 (patch) | |
| tree | d58f8bb0913c0d0329e1b240628ac2af0c972d6c | |
| parent | db4ae1c41883f6f78d8107429f7f4871c45f47d5 (diff) | |
JTable editor done?!? :)
| -rw-r--r-- | sources/core/VSProcess.java | 62 | ||||
| -rw-r--r-- | sources/prefs/VSDefaultPrefs.java | 57 | ||||
| -rw-r--r-- | sources/prefs/editors/VSBetterEditor.java | 3 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditor.java | 147 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditorFrame.java | 4 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditorTable.java | 44 | ||||
| -rw-r--r-- | sources/prefs/editors/VSProcessEditor.java | 2 | ||||
| -rw-r--r-- | sources/prefs/editors/VSSimulationEditor.java | 2 | ||||
| -rw-r--r-- | sources/simulator/VSAbout.java | 2 | ||||
| -rw-r--r-- | sources/simulator/VSSimulation.java | 8 | ||||
| -rw-r--r-- | sources/simulator/VSSimulationCanvas.java | 12 | ||||
| -rw-r--r-- | sources/simulator/VSSimulatorFrame.java | 6 |
12 files changed, 225 insertions, 124 deletions
diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java index 0d0f3d2..e4f3332 100644 --- a/sources/core/VSProcess.java +++ b/sources/core/VSProcess.java @@ -44,8 +44,8 @@ public final class VSProcess extends VSPrefs { * up in the extended prefs menu! */ private static final String DEFAULT_INTEGER_VALUE_KEYS[] = { - "sim.process.prob.crash", - "sim.message.prob.outage", + "process.prob.crash", + "message.prob.outage", }; /* This array contains all Long prefs of the process which should show @@ -53,8 +53,8 @@ public final class VSProcess extends VSPrefs { * up in the extended prefs menu! */ private static final String DEFAULT_LONG_VALUE_KEYS[] = { - "sim.message.sendingtime.min", - "sim.message.sendingtime.max", + "message.sendingtime.min", + "message.sendingtime.max", }; /* This array contains all Float prefs of the process which should show @@ -62,7 +62,7 @@ public final class VSProcess extends VSPrefs { * up in the extended prefs menu! */ private static final String DEFAULT_FLOAT_VALUE_KEYS[] = { - "sim.process.clock.variance", + "process.clock.variance", }; /* This array contains all Color prefs of the process which should show @@ -70,11 +70,11 @@ public final class VSProcess extends VSPrefs { * up in the extended prefs menu! */ private static final String DEFAULT_COLOR_VALUE_KEYS[] = { - "process.default", - "process.running", - "process.stopped", - "process.highlight", - "process.crashed", + "col.process.default", + "col.process.running", + "col.process.stopped", + "col.process.highlight", + "col.process.crashed", }; /* This array contains all String prefs of the process which should show @@ -100,15 +100,15 @@ public final class VSProcess extends VSPrefs { fillWithDefaults(); /* Make local copys in order to have more performance */ - clockVariance = getFloat("sim.process.clock.variance"); - currentColor = getColor("process.default"); + clockVariance = getFloat("process.clock.variance"); + currentColor = getColor("col.process.default"); /* Make additional process settings editable through GUI */ - initInteger("sim.process.id", processID, + initInteger("process.id", processID, prefs.getString("lang.process.id"), 1, processID + 10); - setLongIfUnset("sim.process.localtime", localTime, prefs.getString("lang.process.time.local")); + setLongIfUnset("process.localtime", localTime, prefs.getString("lang.process.time.local")); - crashedColor = getColor("process.crashed"); + crashedColor = getColor("col.process.crashed"); createRandomCrashTask(); } @@ -143,10 +143,10 @@ public final class VSProcess extends VSPrefs { * Called from the VSProcessEditor, after finishing editing! */ public synchronized void updateFromVSPrefs() { - setClockVariance(getFloat("sim.process.clock.variance")); - setProcessID(getInteger("sim.process.id")); - setLocalTime(getLong("sim.process.localtime")); - crashedColor = getColor("process.crashed"); + setClockVariance(getFloat("process.clock.variance")); + setProcessID(getInteger("process.id")); + setLocalTime(getLong("process.localtime")); + crashedColor = getColor("col.process.crashed"); simulationCanvas.repaint(); createRandomCrashTask(); } @@ -155,9 +155,9 @@ public final class VSProcess extends VSPrefs { * Called from the VSProcessEditor, before starting editing! */ public synchronized void updatePrefs() { - setFloat("sim.process.clock.variance", getClockVariance()); - setInteger("sim.process.id", getProcessID()); - setLong("sim.process.localtime", getTime()); + setFloat("process.clock.variance", getClockVariance()); + setInteger("process.id", getProcessID()); + setLong("process.localtime", getTime()); } public synchronized void syncTime(final long globalTime) { @@ -190,7 +190,7 @@ public final class VSProcess extends VSPrefs { public synchronized void highlightOn() { tmpColor = currentColor; - currentColor = getColor("process.highlight"); + currentColor = getColor("col.process.highlight"); isHighlighted = true; } @@ -210,7 +210,7 @@ public final class VSProcess extends VSPrefs { for (VSProtocol protocol : protocolsToReset) protocol.reset(); - setCurrentColor(getColor("process.default")); + setCurrentColor(getColor("col.process.default")); createRandomCrashTask(); resetTimeFormats(); } @@ -241,17 +241,17 @@ public final class VSProcess extends VSPrefs { public synchronized void play() { isPaused = false; - setCurrentColor(getColor("process.running")); + setCurrentColor(getColor("col.process.running")); } public synchronized void pause() { isPaused = true; - setCurrentColor(getColor("process.stopped")); + setCurrentColor(getColor("col.process.stopped")); } public synchronized void finish() { isPaused = true; - setCurrentColor(getColor("process.default")); + setCurrentColor(getColor("col.process.default")); } public synchronized int getProcessID() { @@ -339,8 +339,8 @@ public final class VSProcess extends VSPrefs { } public synchronized long getDurationTime() { - final long maxDurationTime = getLong("sim.message.sendingtime.max"); - final long minDurationTime = getLong("sim.message.sendingtime.min"); + final long maxDurationTime = getLong("message.sendingtime.max"); + final long minDurationTime = getLong("message.sendingtime.min"); if (maxDurationTime <= minDurationTime) return minDurationTime; @@ -356,7 +356,7 @@ public final class VSProcess extends VSPrefs { public synchronized long getARandomMessageOutageTime(final long durationTime) { /* Check if the message will have an outage or not */ - if (random.nextInt(100) <= getInteger("sim.message.prob.outage")) { + if (random.nextInt(100) <= getInteger("message.prob.outage")) { /* Calculate the random outage time! */ final long outageTime = globalTime + random.nextLong(durationTime+1) % simulationCanvas.getUntilTime(); return outageTime; @@ -368,7 +368,7 @@ public final class VSProcess extends VSPrefs { private long getARandomCrashTime() { /* Check if the process will crash or not */ - if (random.nextInt(100) <= getInteger("sim.process.prob.crash")) { + if (random.nextInt(100) <= getInteger("process.prob.crash")) { /* Calculate the random crash time! */ final long crashTime = random.nextLong(simulationCanvas.getUntilTime()+1) % simulationCanvas.getUntilTime(); return crashTime; diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java index 5ee4f2f..e7334f0 100644 --- a/sources/prefs/VSDefaultPrefs.java +++ b/sources/prefs/VSDefaultPrefs.java @@ -130,14 +130,19 @@ public class VSDefaultPrefs extends VSPrefs { initString("lang.type", "Typ"); initString("lang.window.close", "Fenster schliessen"); initString("lang.window.new", "Neues Fenster"); - initString("name", "Verteilte Systeme v0.2-devel"); + initString("lang.name", "VS-Simulator v0.2-devel"); + initString("lang.prefs.simulation", "Simulationseinstellungen"); + initString("lang.prefs.process", "Prozessstandardeinstellungen"); + initString("lang.prefs.message", "Nachrichteneinstellungen"); + initString("lang.prefs.diverse", "Diverse Einstellungen"); + initString("lang.prefs.color", "Farbeinstellungen"); } public void fillDefaultIntegers() { /* Simulation prefs */ initInteger("sim.process.num", 3, "Anzahl der Prozesse", 1, 6); - initIntegerUnit("sim.message.prob.outage", 0, "Nachrichtenverlustw'keit", 0, 100, "%"); - initIntegerUnit("sim.process.prob.crash", 0, "Prozessausfallw'keit", 0, 100, "%"); + initIntegerUnit("message.prob.outage", 0, "Nachrichtenverlustw'keit", 0, 100, "%"); + initIntegerUnit("process.prob.crash", 0, "Prozessausfallw'keit", 0, 100, "%"); initIntegerUnit("sim.seconds", 30, "Simulationsdauer", 5, 120, "s"); /* Internal prefs */ @@ -164,43 +169,43 @@ 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", 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"); - initIntegerUnit("window.xsize", 1024, "X-Grösse des Hauptfensters", 800, 3200, "px"); - initIntegerUnit("window.ysize", 768, "Y-Grösse des Hauptfensters", 600, 2400, "px"); + initIntegerUnit("div.window.prefs.xsize", 400, "Einstellungsfenster X-Achse", 550, 3200, "px"); + initIntegerUnit("div.window.prefs.ysize", 400, "Einstellungsfenster Y-Achse", 640, 2400, "px"); + initIntegerUnit("div.window.loggsize", 300, "Loggfenster Y-Achse", 100, 1000, "px"); + initIntegerUnit("div.window.splitsize", 320, "Toolbar X-Achse", 100, 1000, "px"); + initIntegerUnit("div.window.xsize", 1024, "Hauptfenster X-Achse", 800, 3200, "px"); + initIntegerUnit("div.window.ysize", 768, "Hauptfenster Y-Achse", 600, 2400, "px"); } public void fillDefaultFloats() { /* Simulation prefs */ - initFloat("sim.process.clock.variance", 0, "Uhrabweichung"); + initFloat("process.clock.variance", 0, "Uhrabweichung"); } public void fillDefaultLongs() { /* Simulation prefs */ - initLongUnit("sim.message.sendingtime.min", 1000, "Min. Übertragung", "ms"); - initLongUnit("sim.message.sendingtime.max", 5000, "Max. Übertragung", "ms"); + initLongUnit("message.sendingtime.min", 1000, "Min. Übertragungszeit", "ms"); + initLongUnit("message.sendingtime.max", 5000, "Max. Übertragungszeit", "ms"); } public void fillDefaultColors() { /* Internal prefs */ - initColor("paintarea.background", new Color(0xFF, 0xFF, 0xFF)); - initColor("process.default", new Color(0x00, 0x00, 0x00)); - initColor("process.running", new Color(0x0D, 0xD8, 0x09)); - initColor("process.crashed", new Color(0xff, 0x00, 0x00)); - initColor("process.highlight", new Color(0xff, 0xA5, 0x00)); - initColor("process.line", new Color(0x00, 0x00, 0x00)); - initColor("process.secondline", new Color(0xAA, 0xAA, 0xAA)); - initColor("process.sepline", new Color(0xff, 0x00, 0x00)); - initColor("process.stopped", new Color(0x00, 0x00, 0x00)); - initColor("message.arrived", new Color(0x00, 0x85, 0xD2)); - initColor("message.sending", new Color(0x0D, 0xD8, 0x09)); - initColor("message.lost", new Color(0xFF, 0x00, 0x00)); + initColor("col.background", new Color(0xFF, 0xFF, 0xFF)); + initColor("col.process.default", new Color(0x00, 0x00, 0x00)); + initColor("col.process.running", new Color(0x0D, 0xD8, 0x09)); + initColor("col.process.crashed", new Color(0xff, 0x00, 0x00)); + initColor("col.process.highlight", new Color(0xff, 0xA5, 0x00)); + initColor("col.process.line", new Color(0x00, 0x00, 0x00)); + initColor("col.process.secondline", new Color(0xAA, 0xAA, 0xAA)); + initColor("col.process.sepline", new Color(0xff, 0x00, 0x00)); + initColor("col.process.stopped", new Color(0x00, 0x00, 0x00)); + initColor("col.message.arrived", new Color(0x00, 0x85, 0xD2)); + initColor("col.message.sending", new Color(0x0D, 0xD8, 0x09)); + initColor("col.message.lost", new Color(0xFF, 0x00, 0x00)); } public void fillDefaultBooleans() { - //initBoolean("sim.message.broadcast", false, "Nachrichten sind immer Broadcasts"); - initBoolean("sim.message.own.recv", false, "Proz. empfangen eigene Nachrichten"); + //initBoolean("message.broadcast", false, "Nachrichten sind immer Broadcasts"); + initBoolean("sim.message.own.recv", false, "Eigene Nachrichten empfangen"); } } diff --git a/sources/prefs/editors/VSBetterEditor.java b/sources/prefs/editors/VSBetterEditor.java index da0a069..2ecf099 100644 --- a/sources/prefs/editors/VSBetterEditor.java +++ b/sources/prefs/editors/VSBetterEditor.java @@ -51,9 +51,6 @@ public abstract class VSBetterEditor extends VSEditor { protected void addToButtonPanelFront(JPanel buttonPanel) { } protected void addToButtonPanelLast(JPanel buttonPanel) { } - protected void addToEditPanelFront(JPanel editPanel, VSEditorTable editTable) { } - protected void addToEditPanelLast(JPanel editPanel, VSEditorTable editTable) { } - public void actionPerformed(ActionEvent e) { //String actionCommand = e.getActionCommand(); diff --git a/sources/prefs/editors/VSEditor.java b/sources/prefs/editors/VSEditor.java index d3d33e8..0d00bab 100644 --- a/sources/prefs/editors/VSEditor.java +++ b/sources/prefs/editors/VSEditor.java @@ -13,8 +13,7 @@ import utils.*; import prefs.VSPrefs; 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 VALUE_FIELD_COLS = 9; protected static final int MIN_UNIT_LENGTH = 5; private HashMap<String,JComboBox> integerFields; private HashMap<String,JTextField> colorFields; @@ -22,12 +21,12 @@ public abstract class VSEditor implements ActionListener { private HashMap<String,JTextField> longFields; private HashMap<String,JCheckBox> booleanFields; private HashMap<String,JTextField> stringFields; - private Vector<String> colorKeys; - private Vector<String> floatKeys; - private Vector<String> integerKeys; - private Vector<String> longKeys; - private Vector<String> booleanKeys; - private Vector<String> stringKeys; + private ArrayList<String> colorKeys; + private ArrayList<String> floatKeys; + private ArrayList<String> integerKeys; + private ArrayList<String> longKeys; + private ArrayList<String> booleanKeys; + private ArrayList<String> stringKeys; private JPanel buttonPanel; private JPanel editPanel; protected VSPrefs prefs; @@ -74,15 +73,12 @@ public abstract class VSEditor implements ActionListener { editPanel = createEditPanel(); buttonPanel = createButtonPanel(); - final String keyStartsWith = "sim."; - boolean reversed = false; - - colorKeys = setToSortedVector(prefsToEdit.getColorKeySet(), keyStartsWith, reversed); - floatKeys = setToSortedVector(prefsToEdit.getFloatKeySet(), keyStartsWith, reversed); - integerKeys = setToSortedVector(prefsToEdit.getIntegerKeySet(), keyStartsWith, reversed); - longKeys = setToSortedVector(prefsToEdit.getLongKeySet(), keyStartsWith, reversed); - booleanKeys = setToSortedVector(prefsToEdit.getBooleanKeySet(), keyStartsWith, reversed); - stringKeys = setToSortedVector(prefsToEdit.getStringKeySet(), keyStartsWith, reversed); + colorKeys = filterKeys(prefsToEdit.getColorKeySet()); + floatKeys = filterKeys(prefsToEdit.getFloatKeySet()); + integerKeys = filterKeys(prefsToEdit.getIntegerKeySet()); + longKeys = filterKeys(prefsToEdit.getLongKeySet()); + booleanKeys = filterKeys(prefsToEdit.getBooleanKeySet()); + stringKeys = filterKeys(prefsToEdit.getStringKeySet()); colorFields = new HashMap<String,JTextField>(); floatFields = new HashMap<String,JTextField>(); integerFields = new HashMap<String,JComboBox>(); @@ -90,27 +86,17 @@ public abstract class VSEditor implements ActionListener { booleanFields = new HashMap<String,JCheckBox>(); stringFields = new HashMap<String,JTextField>(); - addToEditPanelFront(editPanel, editTable); fillEditPanel(editPanel, editTable); - addToEditPanelLast(editPanel, editTable); } - private Vector<String> setToSortedVector(Set<String> set, String startsWith, boolean reversed) { - Vector<String> vector = new Vector<String>(); - - if (reversed) { - for (String elem : set) - if (!elem.startsWith(startsWith) && !elem.endsWith("!") && !elem.startsWith("keyevent")) - vector.add(elem); - } else { - for (String elem : set) - if (elem.startsWith(startsWith) && !elem.endsWith("!") && !elem.startsWith("keyevent")) - vector.add(elem); - } + private ArrayList<String> filterKeys(Set<String> set) { + ArrayList<String> filtered = new ArrayList<String>(); - Collections.sort(vector); + for (String elem : set) + if (!elem.startsWith("lang.") && !elem.startsWith("keyevent")) + filtered.add(elem); - return vector; + return filtered; } abstract protected void addToButtonPanelFront(JPanel buttonPanel); @@ -132,9 +118,6 @@ public abstract class VSEditor implements ActionListener { return buttonPanel; } - 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); @@ -169,6 +152,9 @@ public abstract class VSEditor implements ActionListener { } private void fillEditPanel(JPanel editPanel, VSEditorTable editTable) { + HashMap<String,Component> components = new HashMap<String,Component>(); + HashMap<String,String> labels = new HashMap<String,String>(); + for (String key : integerKeys) { String fullKey = VSPrefs.INTEGER_PREFIX + key; String descr = prefsToEdit.getDescription(fullKey); @@ -194,7 +180,9 @@ public abstract class VSEditor implements ActionListener { integerFields.put(key, valComboBox); valComboBox.setBorder(null); - editTable.addVariable(label, createUnitPanel(valComboBox, fullKey)); + + labels.put(fullKey, label); + components.put(fullKey, createUnitPanel(valComboBox, fullKey)); } final String activated = prefs.getString("lang.activated"); @@ -206,7 +194,9 @@ public abstract class VSEditor implements ActionListener { valField.setBackground(Color.WHITE); booleanFields.put(key, valField); valField.setBorder(null); - editTable.addVariable(label, createUnitPanel(valField, fullKey)); + + labels.put(fullKey, label); + components.put(fullKey, createUnitPanel(valField, fullKey)); } for (String key : longKeys) { @@ -224,7 +214,9 @@ public abstract class VSEditor implements ActionListener { valField.setText(""+prefsToEdit.getLong(key)); longFields.put(key, valField); valField.setBorder(null); - editTable.addVariable(label, createUnitPanel(valField, fullKey)); + + labels.put(fullKey, label); + components.put(fullKey, createUnitPanel(valField, fullKey)); } @@ -243,7 +235,8 @@ public abstract class VSEditor implements ActionListener { valField.setText(""+prefsToEdit.getFloat(key)); floatFields.put(key, valField); valField.setBorder(null); - editTable.addVariable(label, createUnitPanel(valField, fullKey)); + labels.put(fullKey, label); + components.put(fullKey, createUnitPanel(valField, fullKey)); } @@ -263,7 +256,7 @@ public abstract class VSEditor implements ActionListener { public void mouseClicked(MouseEvent e) { JFrame parentFrame = getFrame(); JFrame frame = new VSFrame( - prefs.getString("name") + " - " + + prefs.getString("lang.name") + " - " + prefs.getString( "lang.colorchooser"),parentFrame); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); @@ -278,7 +271,8 @@ public abstract class VSEditor implements ActionListener { }); colorFields.put(key, valField); valField.setBorder(null); - editTable.addVariable(label, valField); + labels.put(fullKey, label); + components.put(fullKey, valField); } for (String key : stringKeys) { @@ -296,8 +290,75 @@ public abstract class VSEditor implements ActionListener { valField.setText(prefsToEdit.getString(key)); stringFields.put(key, valField); valField.setBorder(null); - editTable.addVariable(label, createUnitPanel(valField, fullKey)); + labels.put(fullKey, label); + components.put(fullKey, createUnitPanel(valField, fullKey)); + } + + ArrayList<String> fullKeys = new ArrayList<String>(); + fullKeys.addAll(components.keySet()); + Collections.sort(fullKeys); + + boolean flag = false; + for (String fullKey : fullKeys) { + String key = fullKey.substring(fullKey.indexOf(' ')+1); + if (key.startsWith("sim.")) { + if (!flag) { + flag = true; + editTable.addSeparator(prefs.getString("lang.prefs.simulation")); + } + editTable.addVariable(labels.get(fullKey), components.get(fullKey)); + } + } + + flag = false; + for (String fullKey : fullKeys) { + String key = fullKey.substring(fullKey.indexOf(' ')+1); + if (key.startsWith("process.")) { + if (!flag) { + flag = true; + editTable.addSeparator(prefs.getString("lang.prefs.process")); + } + editTable.addVariable(labels.get(fullKey), components.get(fullKey)); + } + } + + flag = false; + for (String fullKey : fullKeys) { + String key = fullKey.substring(fullKey.indexOf(' ')+1); + if (key.startsWith("message.")) { + if (!flag) { + flag = true; + editTable.addSeparator(prefs.getString("lang.prefs.message")); + } + editTable.addVariable(labels.get(fullKey), components.get(fullKey)); + } + } + + flag = false; + for (String fullKey : fullKeys) { + String key = fullKey.substring(fullKey.indexOf(' ')+1); + if (key.startsWith("col.")) { + if (!flag) { + flag = true; + editTable.addSeparator(prefs.getString("lang.prefs.color")); + } + editTable.addVariable(labels.get(fullKey), components.get(fullKey)); + } } + + flag = false; + for (String fullKey : fullKeys) { + String key = fullKey.substring(fullKey.indexOf(' ')+1); + if (key.startsWith("div.")) { + if (!flag) { + flag = true; + editTable.addSeparator(prefs.getString("lang.prefs.diverse")); + } + editTable.addVariable(labels.get(fullKey), components.get(fullKey)); + } + } + + editTable.fireTableDataChanged(); } protected void resetEditPanel() { diff --git a/sources/prefs/editors/VSEditorFrame.java b/sources/prefs/editors/VSEditorFrame.java index 11ced6a..db76313 100644 --- a/sources/prefs/editors/VSEditorFrame.java +++ b/sources/prefs/editors/VSEditorFrame.java @@ -28,8 +28,8 @@ public class VSEditorFrame extends VSFrame implements ActionListener { fillButtonPanel(editor.getButtonPanel()); setContentPane(editor.getContentPane()); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setSize(prefs.getInteger("window.prefs.xsize"), - prefs.getInteger("window.prefs.ysize")); + setSize(prefs.getInteger("div.window.prefs.xsize"), + prefs.getInteger("div.window.prefs.ysize")); setResizable(false); setVisible(true); } diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java index 8d5de52..bc35b57 100644 --- a/sources/prefs/editors/VSEditorTable.java +++ b/sources/prefs/editors/VSEditorTable.java @@ -6,6 +6,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; +import javax.swing.text.*; import prefs.*; @@ -19,6 +20,10 @@ public class VSEditorTable extends JTable { private String key; private Component comp; + public VSNode(String key) { + this.key = key; + } + public VSNode(String key, Component comp) { this.key = key; this.comp = comp; @@ -35,6 +40,10 @@ public class VSEditorTable extends JTable { public Component getRendererComponent() { return comp; } + + public boolean isSeparator() { + return comp == null; + } } private class VSEditorTableModel extends AbstractTableModel implements TableCellRenderer { @@ -56,16 +65,26 @@ public class VSEditorTable extends JTable { public Object getValueAt(int row, int col) { VSNode node = nodes.get(row); + if (node.isSeparator()) { + if (col == 1) + return ""; + + return node.getKey(); + } + if (col == 0) return node.getKey(); - else - return node.getComponent(); + + return node.getComponent(); } public boolean isCellEditable(int row, int col) { if (col == 0) return false; + if (nodes.get(row).isSeparator()) + return false; + return true; } @@ -78,6 +97,17 @@ public class VSEditorTable extends JTable { VSNode node = nodes.get(row); + if (node.isSeparator()) { + JTextPane pane = new JTextPane(); + if (col == 0) { + pane.setText(node.getKey()); + Style style = pane.addStyle("Bold", null); + StyleConstants.setBold(style, true); + } + pane.setBackground(new Color(0xCF, 0xCF, 0XCF)); + return pane; + } + if (col == 0) { JTextField field = new JTextField(" "+node.getKey()+":"); field.setBorder(null); @@ -114,7 +144,8 @@ public class VSEditorTable extends JTable { setBackground(Color.WHITE); getTableHeader().setVisible(false); TableColumn col = getColumnModel().getColumn(1); - col.setMaxWidth(90); + col.setMinWidth(100); + col.setMaxWidth(100); col.setResizable(false); col = getColumnModel().getColumn(0); @@ -123,6 +154,13 @@ public class VSEditorTable extends JTable { public void addVariable(String key, Component comp) { nodes.add(new VSNode(key, comp)); + } + + public void addSeparator(String text) { + nodes.add(new VSNode(text)); + } + + public void fireTableDataChanged() { model.fireTableDataChanged(); } } diff --git a/sources/prefs/editors/VSProcessEditor.java b/sources/prefs/editors/VSProcessEditor.java index c8c1339..891b597 100644 --- a/sources/prefs/editors/VSProcessEditor.java +++ b/sources/prefs/editors/VSProcessEditor.java @@ -20,7 +20,7 @@ public class VSProcessEditor extends VSBetterEditor { private VSProcess process; public static boolean TAKEOVER_BUTTON; public VSProcessEditor(VSPrefs prefs, VSProcess process) { - super(prefs, process, prefs.getString("name") + " - " + prefs.getString("lang.prefs.process"));; + super(prefs, process, prefs.getString("lang.name") + " - " + prefs.getString("lang.prefs.process"));; this.process = process; disposeFrameWithParentIfExists(); getInfoArea().setText(prefs.getString("lang.prefs.process.info!")); diff --git a/sources/prefs/editors/VSSimulationEditor.java b/sources/prefs/editors/VSSimulationEditor.java index dc81c67..8d3a010 100644 --- a/sources/prefs/editors/VSSimulationEditor.java +++ b/sources/prefs/editors/VSSimulationEditor.java @@ -17,7 +17,7 @@ public class VSSimulationEditor extends VSBetterEditor { public static boolean TAKEOVER_BUTTON; public VSSimulationEditor(VSPrefs prefs, VSSimulatorFrame simulatorFrame) { - super(prefs, prefs, prefs.getString("name") + super(prefs, prefs, prefs.getString("lang.name") + " - " + prefs.getString("lang.prefs")); this.simulatorFrame = simulatorFrame; getInfoArea().setText(prefs.getString("lang.prefs.info!")); diff --git a/sources/simulator/VSAbout.java b/sources/simulator/VSAbout.java index 4b68598..4d09160 100644 --- a/sources/simulator/VSAbout.java +++ b/sources/simulator/VSAbout.java @@ -15,7 +15,7 @@ public class VSAbout extends VSFrame implements ActionListener { private VSPrefs prefs; public VSAbout(VSPrefs prefs, Component relativeTo) { - super(prefs.getString("name") + " - " + super(prefs.getString("lang.name") + " - " + prefs.getString("lang.about"), relativeTo); this.prefs = prefs; diff --git a/sources/simulator/VSSimulation.java b/sources/simulator/VSSimulation.java index 9c9bf81..d2cc070 100644 --- a/sources/simulator/VSSimulation.java +++ b/sources/simulator/VSSimulation.java @@ -854,15 +854,15 @@ public class VSSimulation extends JPanel { public void updateFromPrefs() { splitPaneH.setDividerLocation( - prefs.getInteger("window.splitsize")); + prefs.getInteger("div.window.splitsize")); splitPaneV.setDividerLocation( - prefs.getInteger("window.ysize") - - prefs.getInteger("window.loggsize")); + prefs.getInteger("div.window.ysize") + - prefs.getInteger("div.window.loggsize")); splitPane1.setDividerLocation((int) (getPaintSize()/2) - 20); - simulationCanvas.setBackground(prefs.getColor("paintarea.background")); + simulationCanvas.setBackground(prefs.getColor("col.background")); simulationCanvas.updateFromPrefs(); } } diff --git a/sources/simulator/VSSimulationCanvas.java b/sources/simulator/VSSimulationCanvas.java index bf3ec1c..91d5232 100644 --- a/sources/simulator/VSSimulationCanvas.java +++ b/sources/simulator/VSSimulationCanvas.java @@ -190,12 +190,12 @@ public class VSSimulationCanvas extends Canvas implements Runnable, MouseMotionL /* This method contains very ugly code. But this has to be in order to gain performance! */ private void recalcOnWindowChanged() { - processlineColor = prefs.getColor("process.line"); - processSecondlineColor = prefs.getColor("process.secondline"); - processSeplineColor = prefs.getColor("process.sepline"); - messageArrivedColor = prefs.getColor("message.arrived"); - messageSendingColor = prefs.getColor("message.sending"); - messageLostColor = prefs.getColor("message.lost"); + processlineColor = prefs.getColor("col.process.line"); + processSecondlineColor = prefs.getColor("col.process.secondline"); + processSeplineColor = prefs.getColor("col.process.sepline"); + messageArrivedColor = prefs.getColor("col.message.arrived"); + messageSendingColor = prefs.getColor("col.message.sending"); + messageLostColor = prefs.getColor("col.message.lost"); paintSize = simulation.getPaintSize(); xPaintSize = simulation.getWidth() - (3 * XOFFSET + simulation.getSplitSize()); diff --git a/sources/simulator/VSSimulatorFrame.java b/sources/simulator/VSSimulatorFrame.java index b455969..f0a0fea 100644 --- a/sources/simulator/VSSimulatorFrame.java +++ b/sources/simulator/VSSimulatorFrame.java @@ -28,14 +28,14 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener { private JTabbedPane tabbedPane; public VSSimulatorFrame(VSPrefs prefs, Component relativeTo) { - super(prefs.getString("name"), relativeTo); + super(prefs.getString("lang.name"), relativeTo); this.prefs = prefs; this.simulations = new Vector<VSSimulation>(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setSize(prefs.getInteger("window.xsize")+100, - prefs.getInteger("window.ysize")); + setSize(prefs.getInteger("div.window.xsize")+100, + prefs.getInteger("div.window.ysize")); setJMenuBar(createJMenuBar()); setContentPane(createContentPane()); setVisible(true); |
