[Mongobrowser-commit] SF.net SVN: mongobrowser:[133] trunk/mongobrowser/src/com/mebigfatguy/ mongob
Status: Pre-Alpha
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-06-24 06:10:20
|
Revision: 133
http://mongobrowser.svn.sourceforge.net/mongobrowser/?rev=133&view=rev
Author: dbrosius
Date: 2011-06-24 06:10:13 +0000 (Fri, 24 Jun 2011)
Log Message:
-----------
add support for editing existing property values
Modified Paths:
--------------
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/MongoBundle.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoDataPanel.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoTreeNode.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/resources/resource.properties
Added Paths:
-----------
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/actions/EditKeyValueAction.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/DateDocument.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexDescription.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexField.java
trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexFieldList.java
Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/MongoBundle.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/MongoBundle.java 2011-06-23 03:53:16 UTC (rev 132)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/MongoBundle.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -44,6 +44,7 @@
ManageIndices("mongo.manageindices"),
NewObject("mongo.newobject"),
NewKeyValue("mongo.newkeyvalue"),
+ EditKeyValue("mongo.editkeyvalue"),
RemoveIndex("mongo.removeindex"),
AddIndex("mongo.addindex"),
Key("mongo.key"),
@@ -52,11 +53,15 @@
Double("mongo.double"),
Float("mongo.float"),
String("mongo.string"),
+ Date("mongo.date"),
Object("mongo.object"),
Delete("mongo.delete"),
IndexName("mongo.indexname"),
IndexFields("mongo.indexfields"),
- IndexPrefix("mongo.indexprefix");
+ IndexPrefix("mongo.indexprefix"),
+ DateRegex("mongo.dateregex"),
+ MonthValues("mongo.monthvalues"),
+ DateFormat("mongo.dateformat");
private String id;
Added: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/actions/EditKeyValueAction.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/actions/EditKeyValueAction.java (rev 0)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/actions/EditKeyValueAction.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -0,0 +1,83 @@
+/*
+ * mongobrowser - a webstart gui application for viewing,
+ * editing and administering a Mongo Database
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.mongobrowser.actions;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JTree;
+
+import com.mebigfatguy.mongobrowser.MongoBundle;
+import com.mebigfatguy.mongobrowser.MongoContext;
+import com.mebigfatguy.mongobrowser.TreeUtils;
+import com.mebigfatguy.mongobrowser.dialogs.KeyValueDialog;
+import com.mebigfatguy.mongobrowser.dialogs.MongoTreeNode;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+
+/**
+ * an action for editing a mongo object's key value pair
+ */
+public class EditKeyValueAction extends AbstractAction {
+
+ private final MongoContext context;
+
+ /**
+ * constructs an action to handle editing a new key/value pair
+ *
+ * @param ctxt
+ * the state context
+ */
+ public EditKeyValueAction(MongoContext ctxt) {
+ super(MongoBundle.getString(MongoBundle.Key.EditKeyValue));
+ context = ctxt;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JTree tree = context.getTree();
+ MongoTreeNode[] selectedNodes = TreeUtils.getSelectedNodes(tree);
+
+ if (selectedNodes.length == 1) {
+
+ DBObject dbObject = (DBObject) ((MongoTreeNode) selectedNodes[0].getParent()).getUserObject();
+ MongoTreeNode.KV keyValue = ((MongoTreeNode.KV) selectedNodes[0].getUserObject());
+
+ String key = keyValue.getKey();
+ Object value = keyValue.getValue();
+
+ KeyValueDialog dialog = new KeyValueDialog(key, value);
+ dialog.setLocationRelativeTo(tree);
+ dialog.setModal(true);
+ dialog.setVisible(true);
+
+ if (dialog.isOK()) {
+ key = dialog.getKey();
+ value = dialog.getValue();
+
+ dbObject.put(key, value);
+ keyValue.setValue(value);
+
+ MongoTreeNode collectionNode = TreeUtils.findCollectionNode(selectedNodes[0]);
+ DBCollection collection = (DBCollection) collectionNode.getUserObject();
+ collection.save(dbObject);
+ }
+ }
+ }
+}
Property changes on: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/actions/EditKeyValueAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/DateDocument.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/DateDocument.java (rev 0)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/DateDocument.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -0,0 +1,58 @@
+/*
+ * mongobrowser - a webstart gui application for viewing,
+ * editing and administering a Mongo Database
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.mongobrowser.dialogs;
+
+import java.awt.Toolkit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+
+import com.mebigfatguy.mongobrowser.MongoBundle;
+
+public class DateDocument extends PlainDocument {
+
+ private static Pattern DATE_PATTERN = Pattern.compile(MongoBundle.getString(MongoBundle.Key.DateRegex));
+
+ /**
+ * intercepts string insertions to make sure that the values to be put into
+ * a text component is only a date value
+ *
+ * @param pos
+ * where the text is being inserted
+ * @param insertStr
+ * the new text that was typed
+ * @param atts
+ * the attributes for the text (unused)
+ */
+ @Override
+ public void insertString(int pos, String insertStr, AttributeSet atts) throws BadLocationException {
+ StringBuilder text = new StringBuilder(getText(0, getLength()));
+ text.insert(pos, insertStr);
+
+ Matcher m = DATE_PATTERN.matcher(text.toString());
+ if (m.matches() || m.hitEnd()) {
+ super.insertString(pos, insertStr, atts);
+ } else {
+ Toolkit.getDefaultToolkit().beep();
+ }
+ }
+}
Property changes on: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/DateDocument.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2011-06-23 03:53:16 UTC (rev 132)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/KeyValueDialog.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -1,3 +1,21 @@
+/*
+ * mongobrowser - a webstart gui application for viewing,
+ * editing and administering a Mongo Database
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
package com.mebigfatguy.mongobrowser.dialogs;
import java.awt.BorderLayout;
@@ -6,6 +24,11 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -44,9 +67,23 @@
* constructs a dialog to collect a key value for a mongo object's property
*/
public KeyValueDialog() {
+ this(null, null);
+ }
+
+ /**
+ * constructs a dialog to collect a key value for a mongo object's property
+ */
+ public KeyValueDialog(String key, Object value) {
setTitle(MongoBundle.getString(MongoBundle.Key.NewKeyValue));
initComponents();
initListeners();
+
+ if (key != null) {
+ keyField.setText(key);
+ keyField.setEnabled(false);
+ installValue(value);
+ }
+
pack();
}
@@ -90,6 +127,7 @@
model.addElement(new DoubleValueType());
model.addElement(new FloatValueType());
model.addElement(new StringValueType());
+ model.addElement(new DateValueType());
model.addElement(new ObjectValueType());
valueTypeBox.setSelectedIndex(3);
p.add(valueTypeBox, cc.xy(6, 4));
@@ -184,6 +222,47 @@
}
/**
+ * updates the key value dialog based on the value, this is kind of crufty,
+ * would be nicer to handle the popup a better way
+ *
+ * @param value
+ * the value to set
+ */
+ private void installValue(Object value) {
+ if (value != null) {
+ DefaultComboBoxModel model = (DefaultComboBoxModel) valueTypeBox.getModel();
+
+ if (value instanceof Integer) {
+ valueTypeBox.setSelectedIndex(0);
+ ValueType vt = (ValueType) model.getElementAt(0);
+ vt.installDocument(valueField);
+ valueField.setText(String.valueOf(value));
+ } else if (value instanceof Double) {
+ valueTypeBox.setSelectedIndex(1);
+ ValueType vt = (ValueType) model.getElementAt(1);
+ vt.installDocument(valueField);
+ valueField.setText(String.valueOf(value));
+ } else if (value instanceof Float) {
+ valueTypeBox.setSelectedIndex(2);
+ ValueType vt = (ValueType) model.getElementAt(2);
+ vt.installDocument(valueField);
+ valueField.setText(String.valueOf(value));
+ } else if (value instanceof String) {
+ valueTypeBox.setSelectedIndex(3);
+ ValueType vt = (ValueType) model.getElementAt(3);
+ vt.installDocument(valueField);
+ valueField.setText((String) value);
+ } else if (value instanceof Date) {
+ valueTypeBox.setSelectedIndex(4);
+ ValueType vt = (ValueType) model.getElementAt(4);
+ vt.installDocument(valueField);
+ SimpleDateFormat sdf = new SimpleDateFormat(MongoBundle.getString(MongoBundle.Key.DateFormat));
+ valueField.setText(sdf.format((Date) value));
+ }
+ }
+ }
+
+ /**
* interface for items that are put into the Value type combobox
*/
interface ValueType {
@@ -390,6 +469,91 @@
}
/**
+ * a value type representing a Date object
+ */
+ static class DateValueType 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 {
+ String val = field.getText();
+ field.setText("");
+ field.setDocument(new DateDocument());
+ field.getDocument().insertString(0, val, null);
+ field.setEnabled(true);
+ } catch (BadLocationException ble) {
+ }
+ }
+
+ /**
+ * get the field's values as an String
+ *
+ * @param field
+ * the component that holds the string value
+ * @return an Date that is the value of the text field
+ */
+ @Override
+ public Object getValue(JTextField field) {
+ Pattern p = Pattern.compile(MongoBundle.getString(MongoBundle.Key.DateRegex));
+
+ Calendar c = Calendar.getInstance();
+
+ Matcher m = p.matcher(field.getText());
+ if (m.matches() || m.hitEnd()) {
+ c.clear();
+
+ int groupCounts = m.groupCount();
+ if (groupCounts > 0) {
+ String[] monthVals = MongoBundle.getString(MongoBundle.Key.MonthValues).split(",");
+ String month = m.group(1);
+ for (String mv : monthVals) {
+ if (month.startsWith(mv)) {
+ c.set(Calendar.MONTH, Integer.parseInt(mv.split(":")[1]));
+ }
+ }
+ if (groupCounts > 1) {
+ c.set(Calendar.DAY_OF_MONTH, Integer.parseInt(m.group(2)));
+ if (groupCounts > 2) {
+ c.set(Calendar.YEAR, Integer.parseInt(m.group(3)));
+ if (groupCounts > 3) {
+ String[] time = m.group(4).split(":");
+
+ if (time.length > 0) {
+ c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time[0]));
+ if (time.length > 1) {
+ c.set(Calendar.MINUTE, Integer.parseInt(time[1]));
+ if (time.length > 2) {
+ c.set(Calendar.SECOND, Integer.parseInt(time[2]));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return c.getTime();
+ }
+
+ /**
+ * returns the display value shown in the combo box
+ *
+ * @return the string 'String'
+ */
+ @Override
+ public String toString() {
+ return MongoBundle.getString(MongoBundle.Key.Date);
+ }
+ }
+
+ /**
* a value type representing an BasicDBObject object
*/
static class ObjectValueType implements ValueType {
Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoDataPanel.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoDataPanel.java 2011-06-23 03:53:16 UTC (rev 132)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoDataPanel.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -40,6 +40,7 @@
import com.mebigfatguy.mongobrowser.MongoContext;
import com.mebigfatguy.mongobrowser.TreeUtils;
import com.mebigfatguy.mongobrowser.actions.DeleteAction;
+import com.mebigfatguy.mongobrowser.actions.EditKeyValueAction;
import com.mebigfatguy.mongobrowser.actions.ManageIndicesAction;
import com.mebigfatguy.mongobrowser.actions.NewCollectionAction;
import com.mebigfatguy.mongobrowser.actions.NewKeyValueAction;
@@ -61,6 +62,7 @@
private JMenuItem newCollectionItem;
private JMenuItem newObjectItem;
private JMenuItem newKeyValueItem;
+ private JMenuItem editKeyValueItem;
private JMenuItem deleteItem;
/**
@@ -131,6 +133,7 @@
manageIndicesItem = new JMenuItem(new ManageIndicesAction(context));
newObjectItem = new JMenuItem(new NewObjectAction(context));
newKeyValueItem = new JMenuItem(new NewKeyValueAction(context));
+ editKeyValueItem = new JMenuItem(new EditKeyValueAction(context));
deleteItem = new JMenuItem(new DeleteAction(context));
}
@@ -190,6 +193,9 @@
if (value instanceof DBObject) {
menu.add(newKeyValueItem);
needsSeparator = true;
+ } else {
+ menu.add(editKeyValueItem);
+ needsSeparator = true;
}
if (!kv.getKey().startsWith("_")) {
Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoTreeNode.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoTreeNode.java 2011-06-23 03:53:16 UTC (rev 132)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/dialogs/MongoTreeNode.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -41,7 +41,7 @@
* holds the key value of a mongo object property
*/
public static class KV {
- private String key;
+ private final String key;
private Object value;
public KV(String k, Object v) {
@@ -57,6 +57,10 @@
return value;
}
+ public void setValue(Object o) {
+ value = o;
+ }
+
@Override
public String toString() {
return key + " : " + value;
Added: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexDescription.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexDescription.java (rev 0)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexDescription.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -0,0 +1,76 @@
+/*
+ * mongobrowser - a webstart gui application for viewing,
+ * editing and administering a Mongo Database
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.mongobrowser.model;
+
+import java.io.Serializable;
+
+public class IndexDescription implements Comparable<IndexDescription>, Serializable {
+
+ private static final long serialVersionUID = 1616892606319350318L;
+
+ private String indexName;
+ private IndexFieldList indexFields;
+
+ public IndexDescription(String name, IndexFieldList fields) {
+ indexName = name;
+ indexFields = fields;
+ }
+
+ public String getIndexName() {
+ return indexName;
+ }
+
+ public void setIndexName(String name) {
+ indexName = name;
+ }
+
+ public IndexFieldList getIndexFieldList() {
+ return indexFields;
+ }
+
+ public void setIndexFieldList(IndexFieldList fieldList) {
+ indexFields = fieldList;
+ }
+
+ @Override
+ public int hashCode() {
+ return indexName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof IndexDescription) {
+ IndexDescription that = (IndexDescription) o;
+
+ return indexName.equals(that.indexName);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int compareTo(IndexDescription o) {
+ return indexName.compareTo(o.indexName);
+ }
+
+ @Override
+ public String toString() {
+ return indexName + "==> " + indexFields.toString();
+ }
+}
Property changes on: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexDescription.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexField.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexField.java (rev 0)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexField.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -0,0 +1,59 @@
+/*
+ * mongobrowser - a webstart gui application for viewing,
+ * editing and administering a Mongo Database
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.mongobrowser.model;
+
+public class IndexField {
+
+ private final String fieldName;
+ private final boolean ascending;
+
+ public IndexField(String name, boolean asc) {
+
+ fieldName = name;
+ ascending = asc;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public boolean isAscending() {
+ return ascending;
+ }
+
+ @Override
+ public int hashCode() {
+ return fieldName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof IndexField) {
+ IndexField that = (IndexField) o;
+ return fieldName.equals(that.fieldName);
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return fieldName + (ascending ? ": ASC" : ": DESC");
+ }
+}
Property changes on: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexField.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexFieldList.java
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexFieldList.java (rev 0)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexFieldList.java 2011-06-24 06:10:13 UTC (rev 133)
@@ -0,0 +1,66 @@
+/*
+ * mongobrowser - a webstart gui application for viewing,
+ * editing and administering a Mongo Database
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.mongobrowser.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+public class IndexFieldList implements Iterable<IndexField>, Serializable {
+
+ private static final long serialVersionUID = -2452588491740324146L;
+ private final List<IndexField> indexFields = new ArrayList<IndexField>();
+
+ public IndexFieldList() {
+ }
+
+ public IndexFieldList(Collection<IndexField> fields) {
+ indexFields.addAll(fields);
+ }
+
+ public void add(String fieldName, boolean ascending) {
+ IndexField indexField = new IndexField(fieldName, ascending);
+ int index = indexFields.indexOf(indexField);
+ if (index < 0) {
+ indexFields.add(indexField);
+ } else {
+ indexFields.set(index, indexField);
+ }
+ }
+
+ @Override
+ public Iterator<IndexField> iterator() {
+ return indexFields.iterator();
+ }
+
+ public int size() {
+ return indexFields.size();
+ }
+
+ public IndexField get(int index) {
+ return indexFields.get(index);
+ }
+
+ @Override
+ public String toString() {
+ return indexFields.toString();
+ }
+}
Property changes on: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/model/IndexFieldList.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/resources/resource.properties
===================================================================
--- trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/resources/resource.properties 2011-06-23 03:53:16 UTC (rev 132)
+++ trunk/mongobrowser/src/com/mebigfatguy/mongobrowser/resources/resource.properties 2011-06-24 06:10:13 UTC (rev 133)
@@ -32,6 +32,7 @@
mongo.manageindices = Manage Indices...
mongo.newobject = New Object
mongo.newkeyvalue = New Key/Value...
+mongo.editkeyvalue = Edit Key/Value...
mongo.removeindex = Remove Index
mongo.addindex = Add Index
mongo.key = Key
@@ -40,8 +41,12 @@
mongo.double = Double
mongo.float = Float
mongo.string = String
+mongo.date = Date
mongo.object = Object
mongo.delete = Delete
mongo.indexname = Index Name
mongo.indexfields = Index Fields
mongo.indexprefix = index_
+mongo.dateregex=(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\\s+([0-9]{1,2})(?:\\,)?\\s+([0-9]{4})\\s+([0-3][0-9](?::[0-6][0-9]){1,2})?
+mongo.monthvalues=Jan:1,Feb:2,Mar:3,Apr:4,May:5,Jun:6,Jul:7,Aug:8,Sep:9,Oct:10,Nov:11,Dec:12
+mongo.dateformat=MMM d, yyyy HH:mm:ss
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|