summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-21 15:21:58 +0000
committerPaul Buetow <paul@buetow.org>2008-05-21 15:21:58 +0000
commit004458bb854fe4376fe35ec55d7f08853e08895b (patch)
tree3d1bb023e7a5560bb968d4d532de5bf0a2303a44
parent47f50635ca3fa3665f2b0bfb3cc29b2e9b88e88e (diff)
JTable editor better now.
-rw-r--r--sources/prefs/VSDefaultPrefs.java8
-rw-r--r--sources/prefs/editors/VSBetterEditor.java9
-rw-r--r--sources/prefs/editors/VSEditor.java21
-rw-r--r--sources/prefs/editors/VSEditorTable.java53
-rw-r--r--sources/simulator/VSSimulation.java18
5 files changed, 79 insertions, 30 deletions
diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java
index 6511b0f..b17c29f 100644
--- a/sources/prefs/VSDefaultPrefs.java
+++ b/sources/prefs/VSDefaultPrefs.java
@@ -80,13 +80,13 @@ 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 später 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!", "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.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\" oder \"OK\" Knopfes übernommen!");
+ 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 \"OK\" Knopfes übernommen!");
+ initString("lang.prefs.protocol.info!", "Änderungen werden erst nach Betätigen des \"Übernehmen\" oder Knopfes übernommen!");
initString("lang.process", "Prozess");
initString("lang.process.id", "PID");
initString("lang.process.new", "Neuer Prozess");
@@ -166,7 +166,7 @@ public class VSDefaultPrefs extends VSPrefs {
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.ysize", 600, "Y-Grösse des Einstellungsfensters", 640, 2400, "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");
diff --git a/sources/prefs/editors/VSBetterEditor.java b/sources/prefs/editors/VSBetterEditor.java
index b280edc..217b13b 100644
--- a/sources/prefs/editors/VSBetterEditor.java
+++ b/sources/prefs/editors/VSBetterEditor.java
@@ -34,6 +34,7 @@ public abstract class VSBetterEditor extends VSEditor {
}
public Container getContentPane() {
+ contentPane.setBackground(Color.WHITE);
return contentPane;
}
@@ -45,10 +46,10 @@ public abstract class VSBetterEditor extends VSEditor {
JPanel editPanel = super.editPanel;
JPanel buttonPanel = createButtonPanel();
- JScrollPane scrollPane = new JScrollPane(editPanel);
- panel.add(infoArea, BorderLayout.NORTH);
- panel.add(scrollPane, BorderLayout.CENTER);
- panel.add(buttonPanel, BorderLayout.SOUTH);
+ //JScrollPane scrollPane = new JScrollPane(editPanel);
+ panel.add(infoArea);
+ panel.add(editPanel);
+ panel.add(buttonPanel);
return panel;
}
diff --git a/sources/prefs/editors/VSEditor.java b/sources/prefs/editors/VSEditor.java
index 40c02ba..6e554b2 100644
--- a/sources/prefs/editors/VSEditor.java
+++ b/sources/prefs/editors/VSEditor.java
@@ -15,6 +15,7 @@ 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 MIN_UNIT_LENGTH = 5;
protected int prefsCategory;
private HashMap<String,JComboBox> integerFields;
private HashMap<String,JTextField> colorFields;
@@ -148,12 +149,16 @@ public abstract class VSEditor implements ActionListener {
private JPanel createUnitPanel(Component comp, String key) {
JPanel unitPanel = new JPanel(new GridBagLayout());
unitPanel.setBackground(Color.WHITE);
+ unitPanel.setBorder(null);
String unitText = prefs.getUnit(key);
if (unitText == null)
unitText = "";
- JLabel unitLabel = new JLabel(" " + unitText);
+ unitText = " " + unitText;
+ while (unitText.length() < MIN_UNIT_LENGTH)
+ unitText = unitText + " ";
+ JLabel unitLabel = new JLabel(unitText);
unitPanel.setLayout(new BoxLayout(unitPanel, BoxLayout.X_AXIS));
unitPanel.add(comp);
@@ -166,11 +171,12 @@ 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);
- editPanel.add(editTable);
-
- addToEditPanelFront(editPanel);
+ JScrollPane scrollPane = new JScrollPane(editTable);
+ //scrollPane.setBackground(Color.WHITE);
+ editPanel.add(scrollPane);
for (String key : integerKeys) {
String fullKey = VSPrefs.INTEGER_PREFIX + key;
@@ -197,6 +203,7 @@ public abstract class VSEditor implements ActionListener {
//valComboBox.repaint();
integerFields.put(key, valComboBox);
+ valComboBox.setBorder(null);
editTable.addVariable(label, createUnitPanel(valComboBox, fullKey));
}
@@ -208,6 +215,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);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
@@ -225,6 +233,7 @@ public abstract class VSEditor implements ActionListener {
});
valField.setText(""+prefsToEdit.getLong(key));
longFields.put(key, valField);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
@@ -243,6 +252,7 @@ public abstract class VSEditor implements ActionListener {
});
valField.setText(""+prefsToEdit.getFloat(key));
floatFields.put(key, valField);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
@@ -277,6 +287,7 @@ public abstract class VSEditor implements ActionListener {
}
});
colorFields.put(key, valField);
+ valField.setBorder(null);
editTable.addVariable(label, valField);
}
@@ -294,10 +305,12 @@ public abstract class VSEditor implements ActionListener {
});
valField.setText(prefsToEdit.getString(key));
stringFields.put(key, valField);
+ valField.setBorder(null);
editTable.addVariable(label, createUnitPanel(valField, fullKey));
}
addToEditPanelLast(editPanel);
+
return editPanel;
}
diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java
index 874abaa..ef4488f 100644
--- a/sources/prefs/editors/VSEditorTable.java
+++ b/sources/prefs/editors/VSEditorTable.java
@@ -10,6 +10,7 @@ import javax.swing.table.*;
import prefs.*;
public class VSEditorTable extends JTable {
+ private static final int MIN_ROWS = 20;
private VSPrefs prefs;
private ArrayList<VSNode> nodes;
private VSEditorTableModel model;
@@ -30,17 +31,18 @@ public class VSEditorTable extends JTable {
public Component getComponent() {
return comp;
}
+
+ public Component getRendererComponent() {
+ return comp;
+ }
}
- private class VSEditorTableModel extends AbstractTableModel {
+ private class VSEditorTableModel extends AbstractTableModel implements TableCellRenderer {
public VSEditorTableModel() {
}
public String getColumnName(int col) {
- if (col == 0)
- return prefs.getString("lang.variable");
-
- return prefs.getString("lang.value");
+ return "";
}
public int getRowCount() {
@@ -69,13 +71,54 @@ public class VSEditorTable extends JTable {
public void setValueAt(Object value, int row, int col) {
}
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object object, boolean isSelected, boolean hasFocus, int
+ row, int col) {
+
+ 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;
+ }
+
+ return node.getRendererComponent();
+ }
+ }
+
+ private class VSTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ 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 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);
+ setBackground(Color.WHITE);
+ getTableHeader().setVisible(false);
+ TableColumn col = getColumnModel().getColumn(1);
+ col.setMaxWidth(90);
+ col.setResizable(false);
+
+ col = getColumnModel().getColumn(0);
+ col.sizeWidthToFit();
}
public void addVariable(String key, Component comp) {
diff --git a/sources/simulator/VSSimulation.java b/sources/simulator/VSSimulation.java
index 31bc536..f5a3e3b 100644
--- a/sources/simulator/VSSimulation.java
+++ b/sources/simulator/VSSimulation.java
@@ -46,8 +46,6 @@ public class VSSimulation extends JPanel {
private VSTaskManager taskManager;
private VSMenuItemStates menuItemStates;
private JTabbedPane tabbedPane;
- private JPanel variablesPanel;
- private JPanel globalVariablesPanel;
public class VSMenuItemStates {
private volatile boolean pause;
@@ -288,6 +286,7 @@ 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();
@@ -333,25 +332,18 @@ public class VSSimulation extends JPanel {
}
if (processNum != simulationCanvas.getNumProcesses()) {
- variablesPanel.removeAll();
VSProcess process = getSelectedProcess();
VSProcessEditor editor = new VSProcessEditor(prefs, process);
- variablesPanel.add(new JScrollPane(editor.getContentPane()));
+ tabbedPane.setComponentAt(1, editor.getContentPane());
}
}
});
- variablesPanel = new JPanel();
- globalVariablesPanel = new JPanel();
-
- variablesPanel.setLayout(new BoxLayout(variablesPanel, BoxLayout.Y_AXIS));
- globalVariablesPanel.setLayout(new BoxLayout(globalVariablesPanel, BoxLayout.Y_AXIS));
-
- tabbedPane.add(prefs.getString("lang.variables"), variablesPanel);
- tabbedPane.add(prefs.getString("lang.variables.global"), globalVariablesPanel);
+ tabbedPane.add(prefs.getString("lang.variables"), null);
+ tabbedPane.add(prefs.getString("lang.variables.global"), null);
VSSimulationEditor editor = new VSSimulationEditor(prefs, simulatorFrame);
- globalVariablesPanel.add(new JScrollPane(editor.getContentPane()));
+ tabbedPane.setComponentAt(2, editor.getContentPane());
editPanel.add(processesComboBox);
editPanel.add(tabbedPane);