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/28 14:19:44 UTC
svn commit: r1028273 - in /pivot/trunk:
demos/src/org/apache/pivot/demos/roweditor/
wtk/src/org/apache/pivot/wtk/content/
Author: gbrown
Date: Thu Oct 28 12:19:43 2010
New Revision: 1028273
URL: http://svn.apache.org/viewvc?rev=1028273&view=rev
Log:
Provide access to edit data in list view, table view, and tree view editors.
Modified:
pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/row_editor_demo.bxml
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.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/demos/src/org/apache/pivot/demos/roweditor/row_editor_demo.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/row_editor_demo.bxml?rev=1028273&r1=1028272&r2=1028273&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/row_editor_demo.bxml (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/row_editor_demo.bxml Thu Oct 28 12:19:43 2010
@@ -21,26 +21,6 @@ limitations under the License.
xmlns:content="org.apache.pivot.wtk.content"
xmlns:demo="org.apache.pivot.demos.roweditor"
xmlns="org.apache.pivot.wtk">
- <bxml:define>
- <Spinner bxml:id="dateSpinner" selectedItemKey="date">
- <spinnerData>
- <content:CalendarDateSpinnerData/>
- </spinnerData>
- </Spinner>
-
- <ListButton bxml:id="typeListButton" listData="['Hotel', 'Miscellaneous', 'Meals', 'Parking', 'Travel']"
- selectedItemKey="type"/>
-
- <TextInput bxml:id="amountTextInput" strictValidation="true" textKey="amount">
- <validator>
- <demo:CurrencyValidator/>
- </validator>
- <textBindMapping>
- <demo:AmountBindMapping/>
- </textBindMapping>
- </TextInput>
- </bxml:define>
-
<Border styles="{color:7}">
<ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
<TableView bxml:id="tableView" selectMode="multi">
@@ -57,7 +37,35 @@ limitations under the License.
<rowEditor>
<content:TableViewRowEditor editEffect="horizontal_slide">
- <cellEditors date="$dateSpinner" type="$typeListButton" amount="$amountTextInput"/>
+ <cellEditors>
+ <date>
+ <Spinner selectedItemKey="date">
+ <spinnerData>
+ <content:CalendarDateSpinnerData/>
+ </spinnerData>
+ </Spinner>
+ </date>
+
+ <type>
+ <ListButton listData="['Hotel', 'Miscellaneous', 'Meals', 'Parking', 'Travel']"
+ selectedItemKey="type"/>
+ </type>
+
+ <amount>
+ <TextInput strictValidation="true" textKey="amount">
+ <validator>
+ <demo:CurrencyValidator/>
+ </validator>
+ <textBindMapping>
+ <demo:AmountBindMapping/>
+ </textBindMapping>
+ </TextInput>
+ </amount>
+
+ <description>
+ <TextInput textKey="description"/>
+ </description>
+ </cellEditors>
</content:TableViewRowEditor>
</rowEditor>
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=1028273&r1=1028272&r2=1028273&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 28 12:19:43 2010
@@ -67,6 +67,18 @@ public class ListViewItemEditor extends
setContent(textInput);
}
+ public ListView getListView() {
+ return listView;
+ }
+
+ public int getItemIndex() {
+ return itemIndex;
+ }
+
+ public TextInput getTextInput() {
+ return textInput;
+ }
+
@Override
public void edit(ListView listView, int itemIndex) {
this.listView = listView;
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=1028273&r1=1028272&r2=1028273&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 28 12:19:43 2010
@@ -21,6 +21,7 @@ import java.awt.Graphics2D;
import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.collections.HashMap;
import org.apache.pivot.collections.List;
+import org.apache.pivot.wtk.BindType;
import org.apache.pivot.wtk.Bounds;
import org.apache.pivot.wtk.CardPane;
import org.apache.pivot.wtk.CardPaneListener;
@@ -141,16 +142,12 @@ public class TableViewRowEditor extends
tablePane.getRows().add(editorRow);
}
- @Override
- public void edit(TableView tableView, int rowIndex, int columnIndex) {
- this.tableView = tableView;
- this.rowIndex = rowIndex;
- this.columnIndex = columnIndex;
-
- Container tableViewParent = tableView.getParent();
- tableViewScrollPane = (tableViewParent instanceof ScrollPane) ? (ScrollPane)tableViewParent : null;
+ public TableView getTableView() {
+ return tableView;
+ }
- open(tableView.getWindow());
+ public int getRowIndex() {
+ return rowIndex;
}
/**
@@ -173,6 +170,18 @@ public class TableViewRowEditor extends
return cellEditors;
}
+ @Override
+ public void edit(TableView tableView, int rowIndex, int columnIndex) {
+ this.tableView = tableView;
+ this.rowIndex = rowIndex;
+ this.columnIndex = columnIndex;
+
+ Container tableViewParent = tableView.getParent();
+ tableViewScrollPane = (tableViewParent instanceof ScrollPane) ? (ScrollPane)tableViewParent : null;
+
+ open(tableView.getWindow());
+ }
+
/**
* Gets the effect that this editor uses when changing from a read-only
* row to an editable row. By default, this editor uses no effect.
@@ -269,10 +278,12 @@ public class TableViewRowEditor extends
editorComponent = cellEditors.get(columnName);
}
- // Default to a text input editor
+ // Default to a read-only text input editor
if (editorComponent == null) {
TextInput editorTextInput = new TextInput();
editorTextInput.setTextKey(columnName);
+ editorTextInput.setEnabled(false);
+ editorTextInput.setTextBindType(BindType.LOAD);
editorComponent = editorTextInput;
}
@@ -313,65 +324,49 @@ public class TableViewRowEditor extends
@SuppressWarnings("unchecked")
public void close(boolean result) {
- boolean valid = true;
-
if (result) {
- // Preview the changes
- HashMap previewTableRow = new HashMap<String, Object>();
- tablePane.store(previewTableRow);
-
- valid = validate(previewTableRow, rowIndex);
-
- if (valid) {
- // Update the row data
- List<Object> tableData = (List<Object>)tableView.getTableData();
- Object tableRow = tableData.get(rowIndex);
- tablePane.store(tableRow);
+ // Update the row data
+ List<Object> tableData = (List<Object>)tableView.getTableData();
+ Object tableRow = tableData.get(rowIndex);
+ tablePane.store(tableRow);
- if (tableData.getComparator() == null) {
- tableData.update(rowIndex, tableRow);
- } else {
- tableData.remove(rowIndex, 1);
- tableData.add(tableRow);
+ if (tableData.getComparator() == null) {
+ tableData.update(rowIndex, tableRow);
+ } else {
+ tableData.remove(rowIndex, 1);
+ tableData.add(tableRow);
- // Re-select the item, and make sure it's visible
- rowIndex = tableData.indexOf(tableRow);
- tableView.setSelectedIndex(rowIndex);
- tableView.scrollAreaToVisible(tableView.getRowBounds(rowIndex));
- }
+ // Re-select the item, and make sure it's visible
+ rowIndex = tableData.indexOf(tableRow);
+ tableView.setSelectedIndex(rowIndex);
+ tableView.scrollAreaToVisible(tableView.getRowBounds(rowIndex));
}
}
- if (valid) {
- if (cardPane.getSelectedIndex() == EDITOR_CARD_INDEX) {
- cardPane.setSelectedIndex(IMAGE_CARD_INDEX);
- } else {
- getOwner().moveToFront();
- tableView.requestFocus();
-
- Display display = getDisplay();
- display.getContainerMouseListeners().remove(displayMouseHandler);
-
- super.close();
-
- // Clear the editor components
- TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns();
- tablePaneColumns.remove(0, tablePaneColumns.getLength());
- editorRow.remove(0, editorRow.getLength());
+ if (cardPane.getSelectedIndex() == EDITOR_CARD_INDEX) {
+ cardPane.setSelectedIndex(IMAGE_CARD_INDEX);
+ } else {
+ getOwner().moveToFront();
+ tableView.requestFocus();
+
+ Display display = getDisplay();
+ display.getContainerMouseListeners().remove(displayMouseHandler);
+
+ super.close();
+
+ // Clear the editor components
+ TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns();
+ tablePaneColumns.remove(0, tablePaneColumns.getLength());
+ editorRow.remove(0, editorRow.getLength());
+
+ tableView = null;
+ rowIndex = -1;
+ columnIndex = -1;
- tableView = null;
- rowIndex = -1;
- columnIndex = -1;
-
- tableViewScrollPane = null;
- }
+ tableViewScrollPane = null;
}
}
- protected boolean validate(Object tableRow, int rowIndex) {
- return true;
- }
-
@Override
public boolean keyPressed(int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
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=1028273&r1=1028272&r2=1028273&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 28 12:19:43 2010
@@ -69,6 +69,18 @@ public class TreeViewNodeEditor extends
setContent(textInput);
}
+ public TreeView getTreeView() {
+ return treeView;
+ }
+
+ public Path getPath() {
+ return path;
+ }
+
+ public TextInput getTextInput() {
+ return textInput;
+ }
+
@Override
public void edit(TreeView treeView, Path path) {
this.treeView = treeView;