diff options
Diffstat (limited to 'sources/prefs')
| -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 |
7 files changed, 180 insertions, 79 deletions
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!")); |
