From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: More code cleanup: Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class --- .../tabs/outcome/form/field/ArrayEditField.java | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) mode change 100755 => 100644 source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java (limited to 'source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java') diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java old mode 100755 new mode 100644 index e7dc8bc..742d1b4 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java @@ -25,7 +25,7 @@ import com.c2kernel.utils.Language; **************************************************************************/ public class ArrayEditField extends StringEditField implements ActionListener { - + Box arrayBox; Box expandBox; Box editBox; @@ -34,20 +34,20 @@ public class ArrayEditField extends StringEditField implements ActionListener { JButton expandButton; JButton contractButton; JButton addButton; - JButton removeButton; + JButton removeButton; ArrayTableModel arrayModel; JLabel arrayLabel = new JLabel("Array"); boolean panelShown = false; boolean readOnly = false; - + public ArrayEditField(SimpleType type) { - arrayBox = Box.createVerticalBox(); + arrayBox = Box.createVerticalBox(); arrayBox.add(arrayLabel); arrayButton = new JButton(Language.translate("Show")); arrayButton.addActionListener(this); arrayButton.setActionCommand("toggle"); arrayBox.add(arrayButton); - + expandBox = Box.createHorizontalBox(); expandButton = new JButton(">>"); expandButton.setToolTipText("Increase the number of columns displaying this array"); @@ -58,15 +58,15 @@ public class ArrayEditField extends StringEditField implements ActionListener { contractButton.setToolTipText("Decrease the number of columns displaying this array"); contractButton.addActionListener(this); contractButton.setActionCommand("contract"); - + expandBox.add(contractButton); expandBox.add(Box.createHorizontalGlue()); expandBox.add(expandButton); - + arrayModel = new ArrayTableModel(type); if (arrayModel.getColumnCount() < 2) contractButton.setEnabled(false); arrayView = new JScrollPane(new JTable(arrayModel)); - + editBox = Box.createHorizontalBox(); addButton = new JButton("+"); addButton.setToolTipText("Add a field to the end of this array"); @@ -75,7 +75,7 @@ public class ArrayEditField extends StringEditField implements ActionListener { removeButton = new JButton("-"); removeButton.setToolTipText("Remove the last field from this array"); removeButton.addActionListener(this); - removeButton.setActionCommand("remove"); + removeButton.setActionCommand("remove"); editBox.add(addButton); editBox.add(Box.createHorizontalGlue()); editBox.add(removeButton); @@ -83,32 +83,37 @@ public class ArrayEditField extends StringEditField implements ActionListener { /** * */ - public String getDefaultValue() { + @Override + public String getDefaultValue() { return ""; } /** * */ - public String getText() { + @Override + public String getText() { return arrayModel.getData(); } /** * */ - public void setText(String text) { + @Override + public void setText(String text) { arrayModel.setData(text); arrayLabel.setText("Array ("+arrayModel.getArrayLength()+" values)"); } /** * */ - public Component getControl() { + @Override + public Component getControl() { return arrayBox; } /** * */ - public void actionPerformed(ActionEvent e) { + @Override + public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("toggle")) { arrayBox.removeAll(); if (panelShown) { @@ -122,7 +127,7 @@ public class ArrayEditField extends StringEditField implements ActionListener { arrayBox.add(Box.createVerticalStrut(7)); arrayBox.add(arrayButton); arrayBox.add(Box.createVerticalStrut(7)); - arrayBox.add(expandBox); + arrayBox.add(expandBox); arrayBox.add(Box.createVerticalStrut(7)); arrayBox.add(arrayView); if (!readOnly) arrayBox.add(editBox); @@ -138,7 +143,7 @@ public class ArrayEditField extends StringEditField implements ActionListener { else if (e.getActionCommand().equals("remove")) { arrayModel.removeField(); arrayLabel.setText("Array ("+arrayModel.getArrayLength()+" values)"); - } + } else { int currentCols = arrayModel.getColumnCount(); if (e.getActionCommand().equals("extend")) @@ -154,10 +159,12 @@ public class ArrayEditField extends StringEditField implements ActionListener { /** * */ - public JTextComponent makeTextField() { + @Override + public JTextComponent makeTextField() { // not used by array return null; } + @Override public void setEditable(boolean editable) { readOnly = !editable; arrayModel.setReadOnly(!readOnly); -- cgit v1.2.3