[Mongobrowser-commit] SF.net SVN: mongobrowser:[102] trunk/mongobrowser/src/com/mebigfatguy/ mongo
Status: Pre-Alpha
Brought to you by:
dbrosius
|
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.
|