Skip to content
Browse files

Resolve PIVOT-651.

git-svn-id: https://svn.apache.org/repos/asf/pivot/branches/1.5.x@1022492 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent ef1633c commit 6c5deca466dcf6e836a2231ce9fd9f014b02b7ea Gregory K. Brown committed
View
5 wtk/src/org/apache/pivot/wtk/Editor.java
@@ -29,8 +29,11 @@
* 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
View
11 wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java
@@ -153,11 +153,12 @@ public boolean mouseDown(Container container, Mouse.Button button, int x, int y)
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
@@ -261,7 +262,7 @@ public boolean isEditing() {
*/
@SuppressWarnings("unchecked")
@Override
- public void saveChanges() {
+ public boolean saveChanges() {
if (!isEditing()) {
throw new IllegalStateException();
}
@@ -274,6 +275,7 @@ public void saveChanges() {
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);
@@ -295,9 +297,12 @@ public void saveChanges() {
}
itemEditorListeners.changesSaved(this, listView, index);
+ saved = true;
} else if (vote == Vote.DENY) {
itemEditorListeners.saveChangesVetoed(this, vote);
}
+
+ return saved;
}
/**
View
11 wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java
@@ -172,11 +172,12 @@ public boolean mouseDown(Container container, Mouse.Button button, int x, int y)
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
@@ -281,7 +282,7 @@ public boolean isEditing() {
*/
@SuppressWarnings("unchecked")
@Override
- public void saveChanges() {
+ public boolean saveChanges() {
if (!isEditing()) {
throw new IllegalStateException();
}
@@ -301,6 +302,7 @@ public void saveChanges() {
Vote vote = rowEditorListeners.previewSaveChanges(this, tableView, rowIndex,
columnIndex, changes);
+ boolean saved = false;
if (vote == Vote.APPROVE) {
List<Object> tableData = (List<Object>)tableView.getTableData();
@@ -330,9 +332,12 @@ public void saveChanges() {
}
rowEditorListeners.changesSaved(this, tableView, rowIndex, columnIndex);
+ saved = true;
} else if (vote == Vote.DENY) {
rowEditorListeners.saveChangesVetoed(this, vote);
}
+
+ return saved;
}
/**
View
14 wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
@@ -337,7 +337,7 @@ public void editRow() {
}
@SuppressWarnings("unchecked")
- public void saveChanges() {
+ public boolean saveChanges() {
// Preview the changes
HashMap<String, Object> changes = new HashMap<String, Object>();
tablePane.store(changes);
@@ -376,6 +376,8 @@ public void saveChanges() {
saving = false;
rowEditorListeners.saveChangesVetoed(TableViewRowEditor.this, vote);
}
+
+ return saving;
}
public void cancelEdit() {
@@ -428,6 +430,8 @@ public boolean mouseMove(Container container, int x, int y) {
@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
@@ -436,11 +440,11 @@ public boolean mouseDown(Container container, Mouse.Button button, int x, int y)
if (window != this &&
(window == null || !isOwner(window))) {
- saveChanges();
+ consumed = !saveChanges();
}
}
- return opening;
+ return consumed;
}
@Override
@@ -750,12 +754,12 @@ public boolean isEditing() {
* {@inheritDoc}
*/
@Override
- public void saveChanges() {
+ public boolean saveChanges() {
if (editorPopup == null) {
throw new IllegalStateException("No edit in progress.");
}
- editorPopup.saveChanges();
+ return editorPopup.saveChanges();
}
/**
View
11 wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java
@@ -135,11 +135,12 @@ public boolean mouseDown(Container container, Mouse.Button button, int x, int y)
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
@@ -292,7 +293,7 @@ public boolean isEditing() {
*/
@SuppressWarnings("unchecked")
@Override
- public void saveChanges() {
+ public boolean saveChanges() {
if (!isEditing()) {
throw new IllegalStateException();
}
@@ -305,6 +306,7 @@ public void saveChanges() {
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();
@@ -337,9 +339,12 @@ public void saveChanges() {
}
nodeEditorListeners.changesSaved(this, treeView, path);
+ saved = true;
} else if (vote == Vote.DENY) {
nodeEditorListeners.saveChangesVetoed(this, vote);
}
+
+ return saved;
}
/**

0 comments on commit 6c5deca

Please sign in to comment.
Something went wrong with that request. Please try again.