You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/10/14 14:36:32 UTC

svn commit: r1022489 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk: Editor.java content/ListViewItemEditor.java content/TableViewCellEditor.java content/TableViewRowEditor.java content/TreeViewNodeEditor.java

Author: gbrown
Date: Thu Oct 14 12:36:32 2010
New Revision: 1022489

URL: http://svn.apache.org/viewvc?rev=1022489&view=rev
Log:
Resolve PIVOT-651.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Editor.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Editor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Editor.java?rev=1022489&r1=1022488&r2=1022489&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Editor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Editor.java Thu Oct 14 12:36:32 2010
@@ -29,8 +29,11 @@ public interface Editor {
      * Saves an edit that is in progress by updating the appropriate data
      * object. It is up to implementations to define the behavior when
      * <tt>isEditing() == false</tt>.
+     *
+     * @return
+     * <tt>true</tt> if the changes were successfully saved; <tt>false</tt> otherwise.
      */
-    public void saveChanges();
+    public boolean saveChanges();
 
     /**
      * Cancels an edit that is in progress by reverting any edits the user has

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java?rev=1022489&r1=1022488&r2=1022489&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java Thu Oct 14 12:36:32 2010
@@ -158,11 +158,12 @@ public class ListViewItemEditor implemen
             Display display = (Display)container;
             Window window = (Window)display.getComponentAt(x, y);
 
+            boolean consumed = false;
             if (popup != window) {
-                saveChanges();
+                consumed = !saveChanges();
             }
 
-            return false;
+            return consumed;
         }
 
         @Override
@@ -266,7 +267,7 @@ public class ListViewItemEditor implemen
      */
     @SuppressWarnings("unchecked")
     @Override
-    public void saveChanges() {
+    public boolean saveChanges() {
         if (!isEditing()) {
             throw new IllegalStateException();
         }
@@ -279,6 +280,7 @@ public class ListViewItemEditor implemen
         String text = textInput.getText();
         Vote vote = itemEditorListeners.previewSaveChanges(this, listView, index, text);
 
+        boolean saved = false;
         if (vote == Vote.APPROVE) {
             List<Object> listData = (List<Object>)listView.getListData();
             ListItem listItem = (ListItem)listData.get(index);
@@ -300,9 +302,12 @@ public class ListViewItemEditor implemen
             }
 
             itemEditorListeners.changesSaved(this, listView, index);
+            saved = true;
         } else if (vote == Vote.DENY) {
             itemEditorListeners.saveChangesVetoed(this, vote);
         }
+
+        return saved;
     }
 
     /**

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java?rev=1022489&r1=1022488&r2=1022489&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java Thu Oct 14 12:36:32 2010
@@ -177,11 +177,12 @@ public class TableViewCellEditor impleme
             Display display = (Display)container;
             Window window = (Window)display.getComponentAt(x, y);
 
+            boolean consumed = false;
             if (popup != window) {
-                saveChanges();
+                consumed = !saveChanges();
             }
 
-            return false;
+            return consumed;
         }
 
         @Override
@@ -286,7 +287,7 @@ public class TableViewCellEditor impleme
      */
     @SuppressWarnings("unchecked")
     @Override
-    public void saveChanges() {
+    public boolean saveChanges() {
         if (!isEditing()) {
             throw new IllegalStateException();
         }
@@ -306,6 +307,7 @@ public class TableViewCellEditor impleme
         Vote vote = rowEditorListeners.previewSaveChanges(this, tableView, rowIndex,
             columnIndex, changes);
 
+        boolean saved = false;
         if (vote == Vote.APPROVE) {
             List<Object> tableData = (List<Object>)tableView.getTableData();
 
@@ -335,9 +337,12 @@ public class TableViewCellEditor impleme
             }
 
             rowEditorListeners.changesSaved(this, tableView, rowIndex, columnIndex);
+            saved = true;
         } else if (vote == Vote.DENY) {
             rowEditorListeners.saveChangesVetoed(this, vote);
         }
+
+        return saved;
     }
 
     /**

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java?rev=1022489&r1=1022488&r2=1022489&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java Thu Oct 14 12:36:32 2010
@@ -114,6 +114,8 @@ public class TableViewRowEditor implemen
         private ContainerMouseListener displayContainerMouseListener = new ContainerMouseListener.Adapter() {
             @Override
             public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
+                boolean consumed = opening;
+
                 if (!opening
                     && !closing) {
                     // If the event occurred outside the popup, close the popup
@@ -122,11 +124,11 @@ public class TableViewRowEditor implemen
 
                     if (window != EditorPopup.this &&
                         (window == null || !isOwner(window))) {
-                        saveChanges();
+                        consumed = !saveChanges();
                     }
                 }
 
-                return opening;
+                return consumed;
             }
 
             @Override
@@ -433,7 +435,7 @@ public class TableViewRowEditor implemen
         }
 
         @SuppressWarnings("unchecked")
-        public void saveChanges() {
+        public boolean saveChanges() {
             // Preview the changes
             HashMap<String, Object> changes = new HashMap<String, Object>();
             tablePane.store(changes);
@@ -472,6 +474,8 @@ public class TableViewRowEditor implemen
                 saving = false;
                 rowEditorListeners.saveChangesVetoed(TableViewRowEditor.this, vote);
             }
+
+            return saving;
         }
 
         public void cancelEdit() {
@@ -645,12 +649,12 @@ public class TableViewRowEditor implemen
      * {@inheritDoc}
      */
     @Override
-    public void saveChanges() {
+    public boolean saveChanges() {
         if (editorPopup == null) {
             throw new IllegalStateException("No edit in progress.");
         }
 
-        editorPopup.saveChanges();
+        return editorPopup.saveChanges();
     }
 
     /**

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java?rev=1022489&r1=1022488&r2=1022489&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java Thu Oct 14 12:36:32 2010
@@ -138,11 +138,12 @@ public class TreeViewNodeEditor implemen
             Display display = (Display)container;
             Window window = (Window)display.getComponentAt(x, y);
 
+            boolean consumed = false;
             if (popup != window) {
-                saveChanges();
+                consumed = !saveChanges();
             }
 
-            return false;
+            return consumed;
         }
 
         @Override
@@ -295,7 +296,7 @@ public class TreeViewNodeEditor implemen
      */
     @SuppressWarnings("unchecked")
     @Override
-    public void saveChanges() {
+    public boolean saveChanges() {
         if (!isEditing()) {
             throw new IllegalStateException();
         }
@@ -308,6 +309,7 @@ public class TreeViewNodeEditor implemen
         String text = textInput.getText();
         Vote vote = nodeEditorListeners.previewSaveChanges(this, treeView, path, text);
 
+        boolean saved = false;
         if (vote == Vote.APPROVE) {
             // Update the node data
             List<?> treeData = treeView.getTreeData();
@@ -340,9 +342,12 @@ public class TreeViewNodeEditor implemen
             }
 
             nodeEditorListeners.changesSaved(this, treeView, path);
+            saved = true;
         } else if (vote == Vote.DENY) {
             nodeEditorListeners.saveChangesVetoed(this, vote);
         }
+
+        return saved;
     }
 
     /**