Thread: [Mongobrowser-commit] SF.net SVN: mongobrowser:[65] trunk/mongobrowser/src/com/mebigfatguy/ mongob
Status: Pre-Alpha
Brought to you by:
dbrosius
From: <dbr...@us...> - 2010-01-01 01:56:18
|
Revision: 65 http://mongobrowser.svn.sourceforge.net/mongobrowser/?rev=65&view=rev Author: dbrosius Date: 2010-01-01 01:56:11 +0000 (Fri, 01 Jan 2010) Log Message: ----------- stub in dialog for creating a new key/value pair Added Paths: ----------- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java Added: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java =================================================================== --- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java (rev 0) +++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-01 01:56:11 UTC (rev 65) @@ -0,0 +1,151 @@ +package com.mebigfatguy.mongobrowser.dialogs; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; +import com.mebigfatguy.mongobrowser.MongoBundle; + +public class KeyValueDialog extends JDialog { + + private static final long serialVersionUID = 4909101478144542212L; + + private JTextField keyName; + private JComboBox valueTypeBox; + private JTextField valueField; + private JButton okButton; + private JButton cancelButton; + private boolean ok = false; + + public KeyValueDialog() { + setTitle(MongoBundle.getString(MongoBundle.Key.NewKeyValue)); + initComponents(); + initListeners(); + pack(); + } + + private void initComponents() { + Container cp = getContentPane(); + cp.setLayout(new BorderLayout(4, 4)); + cp.add(createFormPanel(), BorderLayout.CENTER); + cp.add(createCtrlPanel(), BorderLayout.SOUTH); + } + + private JPanel createFormPanel() { + JPanel p = new JPanel(); + p.setLayout(new FormLayout("6dlu, pref, 5dlu, 200px, 5dlu, pref, 6dlu", "6dlu, pref, 2dlu, pref, 6dlu")); + CellConstraints cc = new CellConstraints(); + + JLabel keyLabel = new JLabel(MongoBundle.getString(MongoBundle.Key.Key)); + p.add(keyLabel, cc.xy(2, 2)); + + keyName = new JTextField(); + p.add(keyName, cc.xy(4, 2)); + + keyLabel.setLabelFor(keyName); + + JLabel valueLabel = new JLabel(MongoBundle.getString(MongoBundle.Key.Value)); + p.add(valueLabel, cc.xy(2, 4)); + + valueField = new JTextField(); + p.add(valueField, cc.xy(4, 4)); + + valueTypeBox = new JComboBox(); + DefaultComboBoxModel model = (DefaultComboBoxModel)valueTypeBox.getModel(); + model.addElement(new IntegerValueType()); + model.addElement(new DoubleValueType()); + model.addElement(new StringValueType()); + model.addElement(new ObjectValueType()); + p.add(valueTypeBox, cc.xy(6, 4)); + + valueLabel.setLabelFor(valueField); + + return p; + } + + private JPanel createCtrlPanel() { + JPanel p = new JPanel(); + p.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.add(Box.createHorizontalGlue()); + + okButton = new JButton(MongoBundle.getString(MongoBundle.Key.OK)); + p.add(okButton); + p.add(Box.createHorizontalStrut(10)); + + cancelButton = new JButton(MongoBundle.getString(MongoBundle.Key.Cancel)); + p.add(cancelButton); + p.add(Box.createHorizontalStrut(10)); + + return p; + } + + private void initListeners() { + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + ok = true; + dispose(); + } + }); + + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + dispose(); + } + }); + } + + public boolean isOK() { + return ok; + } + + interface ValueType { + + } + + class IntegerValueType implements ValueType { + + @Override + public String toString() { + return MongoBundle.getString(MongoBundle.Key.Integer); + } + } + + class DoubleValueType implements ValueType { + + @Override + public String toString() { + return MongoBundle.getString(MongoBundle.Key.Double); + } + } + + class StringValueType implements ValueType { + + @Override + public String toString() { + return MongoBundle.getString(MongoBundle.Key.String); + } + } + + class ObjectValueType implements ValueType { + + @Override + public String toString() { + return MongoBundle.getString(MongoBundle.Key.Object); + } + } +} Property changes on: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-01-01 02:54:01
|
Revision: 72 http://mongobrowser.svn.sourceforge.net/mongobrowser/?rev=72&view=rev Author: dbrosius Date: 2010-01-01 02:53:52 +0000 (Fri, 01 Jan 2010) Log Message: ----------- DoubleValue should use DoubleDocument Modified Paths: -------------- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java =================================================================== --- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-01 02:48:10 UTC (rev 71) +++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-01 02:53:52 UTC (rev 72) @@ -175,7 +175,7 @@ try { String val = field.getText(); field.setText(""); - field.setDocument(new IntegerDocument()); + field.setDocument(new DoubleDocument()); field.getDocument().insertString(0, val, null); field.setEnabled(true); } catch (BadLocationException ble) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-01-01 06:01:52
|
Revision: 75 http://mongobrowser.svn.sourceforge.net/mongobrowser/?rev=75&view=rev Author: dbrosius Date: 2010-01-01 06:01:39 +0000 (Fri, 01 Jan 2010) Log Message: ----------- SIC Modified Paths: -------------- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java =================================================================== --- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-01 03:00:52 UTC (rev 74) +++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-01 06:01:39 UTC (rev 75) @@ -143,7 +143,7 @@ Object getValue(JTextField field); } - class IntegerValueType implements ValueType { + static class IntegerValueType implements ValueType { @Override public void installDocument(JTextField field) { @@ -168,7 +168,7 @@ } } - class DoubleValueType implements ValueType { + static class DoubleValueType implements ValueType { @Override public void installDocument(JTextField field) { @@ -192,7 +192,7 @@ } } - class StringValueType implements ValueType { + static class StringValueType implements ValueType { @Override public void installDocument(JTextField field) { @@ -217,7 +217,7 @@ } } - class ObjectValueType implements ValueType { + static class ObjectValueType implements ValueType { @Override public void installDocument(JTextField field) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2010-01-03 02:54:54
|
Revision: 102 http://mongobrowser.svn.sourceforge.net/mongobrowser/?rev=102&view=rev Author: dbrosius Date: 2010-01-03 02:54:47 +0000 (Sun, 03 Jan 2010) Log Message: ----------- javadoc Modified Paths: -------------- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java =================================================================== --- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-03 02:48:30 UTC (rev 101) +++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2010-01-03 02:54:47 UTC (rev 102) @@ -25,6 +25,9 @@ import com.mebigfatguy.mongobrowser.MongoBundle; import com.mongodb.BasicDBObject; +/** + * a dialog for collecting key/value pairs for a mongo object property + */ public class KeyValueDialog extends JDialog { private static final long serialVersionUID = 4909101478144542212L; @@ -36,6 +39,9 @@ private JButton cancelButton; private boolean ok = false; + /** + * constructs a dialog to collect a key value for a mongo object's property + */ public KeyValueDialog() { setTitle(MongoBundle.getString(MongoBundle.Key.NewKeyValue)); initComponents(); @@ -43,6 +49,9 @@ pack(); } + /** + * adds and lays out the components in the dialog + */ private void initComponents() { Container cp = getContentPane(); cp.setLayout(new BorderLayout(4, 4)); @@ -50,6 +59,11 @@ cp.add(createCtrlPanel(), BorderLayout.SOUTH); } + /** + * creates the panel for collecting the key and value + * + * @return a panel holding the input fields + */ private JPanel createFormPanel() { JPanel p = new JPanel(); p.setLayout(new FormLayout("6dlu, pref, 5dlu, 200px, 5dlu, pref, 6dlu", "6dlu, pref, 2dlu, pref, 6dlu")); @@ -83,6 +97,11 @@ return p; } + /** + * creates a panel holding the ok and cancel buttons + * + * @return the ok/cancel button panel + */ private JPanel createCtrlPanel() { JPanel p = new JPanel(); p.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); @@ -100,6 +119,9 @@ return p; } + /** + * installs the listeners + */ private void initListeners() { okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { @@ -126,25 +148,62 @@ }); } + /** + * did the user click ok + * + * @return if the user clicked ok + */ public boolean isOK() { return ok; } + /** + * gets the key value from the form + * + * @return the key value + */ public String getKey() { return keyField.getText(); } + /** + * gets the typed value from the dialog + * + * @return the typed value + */ public Object getValue() { return ((ValueType)valueTypeBox.getSelectedItem()).getValue(valueField); } + /** + * interface for items that are put into the Value type combobox + */ interface ValueType { + /** + * switch the JTextField's model based on the type of value + * + * @param field the component who's document should be modified + */ void installDocument(JTextField field); + /** + * get the value object of the field, based on the type of this value + * + * @param field the component to get the value from + * @return a value object + */ Object getValue(JTextField field); } + /** + * a value type representing an Integer object + */ static class IntegerValueType implements ValueType { + /** + * installs an IntegerDocument as the field's model + * + * @param field the text edit field to install the model + */ @Override public void installDocument(JTextField field) { try { @@ -157,19 +216,38 @@ } } + /** + * get the field's values as an Integer + * + * @param field the component that holds the integer value + * @return an Integer that is the value of the text field + */ @Override public Object getValue(JTextField field) { return Integer.valueOf(field.getText()); } + /** + * returns the display value shown in the combo box + * + * @return the string 'Integer' + */ @Override public String toString() { return MongoBundle.getString(MongoBundle.Key.Integer); } } + /** + * a value type representing an Double object + */ static class DoubleValueType implements ValueType { + /** + * installs an DoubleDocument as the field's model + * + * @param field the text edit field to install the model + */ @Override public void installDocument(JTextField field) { try { @@ -182,18 +260,38 @@ } } + /** + * get the field's values as an Double + * + * @param field the component that holds the double value + * @return an Double that is the value of the text field + */ @Override public Object getValue(JTextField field) { return Double.valueOf(field.getText()); } + + /** + * returns the display value shown in the combo box + * + * @return the string 'Double' + */ @Override public String toString() { return MongoBundle.getString(MongoBundle.Key.Double); } } + /** + * a value type representing an String object + */ static class StringValueType implements ValueType { + /** + * installs an PlainDocument as the field's model + * + * @param field the text edit field to install the model + */ @Override public void installDocument(JTextField field) { try { @@ -206,19 +304,39 @@ } } + /** + * get the field's values as an String + * + * @param field the component that holds the string value + * @return an String that is the value of the text field + */ @Override public Object getValue(JTextField field) { return field.getText(); } + /** + * returns the display value shown in the combo box + * + * @return the string 'String' + */ @Override public String toString() { return MongoBundle.getString(MongoBundle.Key.String); } } + /** + * a value type representing an BasicDBObject object + */ static class ObjectValueType implements ValueType { + /** + * installs an PlainDocument as the field's model + * and disables the field + * + * @param field the text edit field to install the model + */ @Override public void installDocument(JTextField field) { field.setText(""); @@ -226,11 +344,22 @@ field.setEnabled(false); } + /** + * get the field's values as an BasicDBObject + * + * @param field the component that holds the string value + * @return an String that is the value of the text field + */ @Override public Object getValue(JTextField field) { return new BasicDBObject(); } + /** + * returns the display value shown in the combo box + * + * @return the string 'Object' + */ @Override public String toString() { return MongoBundle.getString(MongoBundle.Key.Object); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |