pivot-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbr...@apache.org
Subject svn commit: r921842 - in /pivot/trunk: tests/src/org/apache/pivot/tests/ wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/skin/
Date Thu, 11 Mar 2010 13:31:06 GMT
Author: gbrown
Date: Thu Mar 11 13:31:05 2010
New Revision: 921842

URL: http://svn.apache.org/viewvc?rev=921842&view=rev
Log:
Add support for BindType to Label, TextInput, and TextArea; add support for binding to checked
state in ListView.

Modified:
    pivot/trunk/tests/src/org/apache/pivot/tests/DataBindingTest.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/LabelListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ListViewListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/DataBindingTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/DataBindingTest.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/DataBindingTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/DataBindingTest.java Thu Mar 11 13:31:05
2010
@@ -83,7 +83,7 @@ public class DataBindingTest implements 
         }
     }
 
-    public static class TestBindMapping implements ListView.SelectedItemBindMapping, Spinner.SelectedItemBindMapping
{
+    public static class TestBindMapping implements ListView.ItemBindMapping, Spinner.ItemBindMapping
{
         @SuppressWarnings("unchecked")
         public int indexOf(List<?> list, Object value) {
             int i = 0;

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java Thu Mar
11 13:31:05 2010
@@ -1093,7 +1093,7 @@ public class TerraListViewSkin extends C
 
     @Override
     public void selectedItemBindMappingChanged(ListView listView,
-        ListView.SelectedItemBindMapping previousSelectedItemBindMapping) {
+        ListView.ItemBindMapping previousSelectedItemBindMapping) {
         // No-op
     }
 
@@ -1109,7 +1109,23 @@ public class TerraListViewSkin extends C
 
     @Override
     public void selectedItemsBindMappingChanged(ListView listView,
-        ListView.SelectedItemBindMapping previousSelectedItemsBindMapping) {
+        ListView.ItemBindMapping previousSelectedItemsBindMapping) {
+        // No-op
+    }
+
+    @Override
+    public void checkedItemsKeyChanged(ListView listView, String previousCheckedItemsKey)
{
+        // No-op
+    }
+
+    @Override
+    public void checkedItemsBindTypeChanged(ListView listView, BindType previousCheckedItemsBindType)
{
+        // No-op
+    }
+
+    @Override
+    public void checkedItemsBindMappingChanged(ListView listView,
+        ListView.ItemBindMapping previousCheckedItemsBindMapping) {
         // No-op
     }
 

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java Thu Mar
11 13:31:05 2010
@@ -861,7 +861,7 @@ public class TerraSpinnerSkin extends Co
     }
 
     @Override
-    public void selectedItemBindMappingChanged(Spinner spinner, Spinner.SelectedItemBindMapping
previousSelectedItemBindMapping) {
+    public void selectedItemBindMappingChanged(Spinner spinner, Spinner.ItemBindMapping previousSelectedItemBindMapping)
{
         // No-op
     }
 

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Thu
Mar 11 13:31:05 2010
@@ -34,6 +34,7 @@ import java.text.StringCharacterIterator
 
 import org.apache.pivot.collections.Dictionary;
 import org.apache.pivot.wtk.ApplicationContext;
+import org.apache.pivot.wtk.BindType;
 import org.apache.pivot.wtk.Bounds;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.Cursor;
@@ -1356,6 +1357,11 @@ public class TerraTextInputSkin extends 
     }
 
     @Override
+    public void textBindTypeChanged(TextInput textInput, BindType previousTextBindType) {
+        // No-op
+    }
+
+    @Override
     public void textBindMappingChanged(TextInput textInput, TextInput.TextBindMapping previousTextBindMapping)
{
         // No-op
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java Thu Mar 11 13:31:05 2010
@@ -72,14 +72,16 @@ public abstract class Button extends Com
      */
     public interface SelectedBindMapping {
         /**
-         * Converts a context value to a selection state.
+         * Converts a context value to a selection state during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param value
          */
         public boolean isSelected(Object value);
 
         /**
-         * Converts a selection state to a context value.
+         * Converts a selection state to a context value during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param selected
          */
@@ -91,14 +93,16 @@ public abstract class Button extends Com
      */
     public interface StateBindMapping {
         /**
-         * Converts a context value to a button state.
+         * Converts a context value to a button state during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param value
          */
         public State toState(Object value);
 
         /**
-         * Converts a button state to a context value.
+         * Converts a button state to a context value during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param state
          */

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java Thu Mar 11 13:31:05 2010
@@ -29,14 +29,16 @@ public class Label extends Component {
      */
     public interface TextBindMapping {
         /**
-         * Converts a value from the bind context to a text representation.
+         * Converts a value from the bind context to a text representation during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param value
          */
         public String toString(Object value);
 
         /**
-         * Converts a text string to a value to be stored in the bind context.
+         * Converts a text string to a value to be stored in the bind context during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param text
          */
@@ -60,6 +62,13 @@ public class Label extends Component {
         }
 
         @Override
+        public void textBindTypeChanged(Label label, BindType previousTextBindType) {
+            for (LabelListener listener : this) {
+                listener.textBindTypeChanged(label, previousTextBindType);
+            }
+        }
+
+        @Override
         public void textBindMappingChanged(Label label, Label.TextBindMapping previousTextBindMapping)
{
             for (LabelListener listener : this) {
                 listener.textBindMappingChanged(label, previousTextBindMapping);
@@ -68,7 +77,9 @@ public class Label extends Component {
     }
 
     private String text = null;
+
     private String textKey = null;
+    private BindType textBindType = BindType.BOTH;
     private TextBindMapping textBindMapping = null;
 
     private LabelListenerList labelListeners = new LabelListenerList();
@@ -120,6 +131,19 @@ public class Label extends Component {
         }
     }
 
+    public BindType getTextBindType() {
+        return textBindType;
+    }
+
+    public void setTextBindType(BindType textBindType) {
+        BindType previousTextBindType = this.textBindType;
+        if (previousTextBindType != textBindType) {
+            this.textBindType = textBindType;
+            labelListeners.textBindTypeChanged(this, previousTextBindType);
+        }
+
+    }
+
     public TextBindMapping getTextBindMapping() {
         return textBindMapping;
     }
@@ -136,7 +160,8 @@ public class Label extends Component {
     @Override
     public void load(Dictionary<String, ?> context) {
         if (textKey != null
-            && JSON.containsKey(context, textKey)) {
+            && JSON.containsKey(context, textKey)
+            && textBindType != BindType.STORE) {
             Object value = JSON.get(context, textKey);
 
             if (textBindMapping == null) {
@@ -153,8 +178,8 @@ public class Label extends Component {
 
     @Override
     public void store(Dictionary<String, ?> context) {
-        if (isEnabled()
-            && textKey != null) {
+        if (textKey != null
+            && textBindType != BindType.LOAD) {
             String text = getText();
             JSON.put(context, textKey, (textBindMapping == null) ?
                 text : textBindMapping.valueOf(text));

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/LabelListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/LabelListener.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/LabelListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/LabelListener.java Thu Mar 11 13:31:05 2010
@@ -33,6 +33,10 @@ public interface LabelListener {
         }
 
         @Override
+        public void textBindTypeChanged(Label label, BindType previousTextBindType) {
+        }
+
+        @Override
         public void textBindMappingChanged(Label label, Label.TextBindMapping previousTextBindMapping)
{
         }
     }
@@ -54,6 +58,14 @@ public interface LabelListener {
     public void textKeyChanged(Label label, String previousTextKey);
 
     /**
+     * Called when a label's text bind type has changed.
+     *
+     * @param label
+     * @param previousTextBindType
+     */
+    public void textBindTypeChanged(Label label, BindType previousTextBindType);
+
+    /**
      * Called when a label's bind mapping has changed.
      *
      * @param label

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java Thu Mar 11 13:31:05 2010
@@ -93,7 +93,7 @@ public class ListButton extends Button {
         }
 
         @Override
-        public void selectedItemBindMappingChanged(ListButton listButton, ListView.SelectedItemBindMapping
previousSelectedItemBindMapping) {
+        public void selectedItemBindMappingChanged(ListButton listButton, ListView.ItemBindMapping
previousSelectedItemBindMapping) {
             for (ListButtonListener listener : this) {
                 listener.selectedItemBindMappingChanged(listButton, previousSelectedItemBindMapping);
             }
@@ -121,7 +121,7 @@ public class ListButton extends Button {
 
     private String selectedItemKey = null;
     private BindType selectedItemBindType = BindType.BOTH;
-    private ListView.SelectedItemBindMapping selectedItemBindMapping = null;
+    private ListView.ItemBindMapping selectedItemBindMapping = null;
 
     private ListButtonListenerList listButtonListeners = new ListButtonListenerList();
     private ListButtonSelectionListenerList listButtonSelectionListeners = new ListButtonSelectionListenerList();
@@ -425,12 +425,12 @@ public class ListButton extends Button {
         }
     }
 
-    public ListView.SelectedItemBindMapping getSelectedItemBindMapping() {
+    public ListView.ItemBindMapping getSelectedItemBindMapping() {
         return selectedItemBindMapping;
     }
 
-    public void setSelectedItemBindMapping(ListView.SelectedItemBindMapping selectedItemBindMapping)
{
-        ListView.SelectedItemBindMapping previousSelectedItemBindMapping = this.selectedItemBindMapping;
+    public void setSelectedItemBindMapping(ListView.ItemBindMapping selectedItemBindMapping)
{
+        ListView.ItemBindMapping previousSelectedItemBindMapping = this.selectedItemBindMapping;
 
         if (previousSelectedItemBindMapping != selectedItemBindMapping) {
             this.selectedItemBindMapping = selectedItemBindMapping;

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonListener.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonListener.java Thu Mar 11 13:31:05 2010
@@ -62,7 +62,7 @@ public interface ListButtonListener {
 
         @Override
         public void selectedItemBindMappingChanged(ListButton listButton,
-            ListView.SelectedItemBindMapping previousSelectedItemBindMapping) {
+            ListView.ItemBindMapping previousSelectedItemBindMapping) {
         }
     }
 
@@ -137,5 +137,5 @@ public interface ListButtonListener {
      * @param previousSelectedItemBindMapping
      */
     public void selectedItemBindMappingChanged(ListButton listButton,
-        ListView.SelectedItemBindMapping previousSelectedItemBindMapping);
+        ListView.ItemBindMapping previousSelectedItemBindMapping);
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java Thu Mar 11 13:31:05 2010
@@ -366,14 +366,16 @@ public class ListView extends Component 
      */
     public interface ListDataBindMapping {
         /**
-         * Converts a context value to list data.
+         * Converts a context value to list data during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param value
          */
         public List<?> toListData(Object value);
 
         /**
-         * Converts list data to a context value.
+         * Converts list data to a context value during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param listData
          */
@@ -381,11 +383,12 @@ public class ListView extends Component 
     }
 
     /**
-     * Translates between selection and bind context data during data binding.
+     * Translates between item position and bind context data during data binding.
      */
-    public interface SelectedItemBindMapping {
+    public interface ItemBindMapping {
         /**
-         * Returns the index of the item in the source list.
+         * Returns the index of the item in the source list during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param listData
          * The source list data.
@@ -400,7 +403,8 @@ public class ListView extends Component 
         public int indexOf(List<?> listData, Object value);
 
         /**
-         * Retrieves the value at the given index.
+         * Retrieves the value at the given index during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param listData
          * The source list data.
@@ -508,7 +512,7 @@ public class ListView extends Component 
 
         @Override
         public void selectedItemBindMappingChanged(ListView listView,
-            SelectedItemBindMapping previousSelectedItemBindMapping) {
+            ItemBindMapping previousSelectedItemBindMapping) {
             for (ListViewListener listener : this) {
                 listener.selectedItemBindMappingChanged(listView, previousSelectedItemBindMapping);
             }
@@ -530,11 +534,33 @@ public class ListView extends Component 
 
         @Override
         public void selectedItemsBindMappingChanged(ListView listView,
-            SelectedItemBindMapping previousSelectedItemsBindMapping) {
+            ItemBindMapping previousSelectedItemsBindMapping) {
             for (ListViewListener listener : this) {
                 listener.selectedItemsBindMappingChanged(listView, previousSelectedItemsBindMapping);
             }
         }
+
+        @Override
+        public void checkedItemsKeyChanged(ListView listView, String previousCheckedItemsKey)
{
+            for (ListViewListener listener : this) {
+                listener.checkedItemsKeyChanged(listView, previousCheckedItemsKey);
+            }
+        }
+
+        @Override
+        public void checkedItemsBindTypeChanged(ListView listView, BindType previousCheckedItemsBindType)
{
+            for (ListViewListener listener : this) {
+                listener.checkedItemsBindTypeChanged(listView, previousCheckedItemsBindType);
+            }
+        }
+
+        @Override
+        public void checkedItemsBindMappingChanged(ListView listView,
+            ListView.ItemBindMapping previousCheckedItemsBindMapping) {
+            for (ListViewListener listener : this) {
+                listener.checkedItemsBindMappingChanged(listView, previousCheckedItemsBindMapping);
+            }
+        }
     }
 
     /**
@@ -638,11 +664,15 @@ public class ListView extends Component 
 
     private String selectedItemKey = null;
     private BindType selectedItemBindType = BindType.BOTH;
-    private SelectedItemBindMapping selectedItemBindMapping = null;
+    private ItemBindMapping selectedItemBindMapping = null;
 
     private String selectedItemsKey = null;
     private BindType selectedItemsBindType = BindType.BOTH;
-    private SelectedItemBindMapping selectedItemsBindMapping = null;
+    private ItemBindMapping selectedItemsBindMapping = null;
+
+    private String checkedItemsKey = null;
+    private BindType checkedItemsBindType = BindType.BOTH;
+    private ItemBindMapping checkedItemsBindMapping = null;
 
     private ListListener<Object> listDataListener = new ListListener<Object>()
{
         @Override
@@ -1409,6 +1439,18 @@ public class ListView extends Component 
     }
 
     /**
+     * Clears the checked state of all checked items.
+     */
+    public void clearCheckmarks() {
+        ArrayList<Integer> checkedIndexes = this.checkedIndexes;
+        this.checkedIndexes = new ArrayList<Integer>();
+
+        for (Integer index : checkedIndexes) {
+            listViewItemStateListeners.itemCheckedChanged(this, index);
+        }
+    }
+
+    /**
      * Tells whether or not an item's checkmark is disabled.
      *
      * @param index
@@ -1591,12 +1633,12 @@ public class ListView extends Component 
         }
     }
 
-    public SelectedItemBindMapping getSelectedItemBindMapping() {
+    public ItemBindMapping getSelectedItemBindMapping() {
         return selectedItemBindMapping;
     }
 
-    public void setSelectedItemBindMapping(SelectedItemBindMapping selectedItemBindMapping)
{
-        SelectedItemBindMapping previousSelectedItemBindMapping = this.selectedItemBindMapping;
+    public void setSelectedItemBindMapping(ItemBindMapping selectedItemBindMapping) {
+        ItemBindMapping previousSelectedItemBindMapping = this.selectedItemBindMapping;
 
         if (previousSelectedItemBindMapping != selectedItemBindMapping) {
             this.selectedItemBindMapping = selectedItemBindMapping;
@@ -1633,12 +1675,12 @@ public class ListView extends Component 
         }
     }
 
-    public SelectedItemBindMapping getSelectedItemsBindMapping() {
+    public ItemBindMapping getSelectedItemsBindMapping() {
         return selectedItemsBindMapping;
     }
 
-    public void setSelectedItemsBindMapping(SelectedItemBindMapping selectedItemsBindMapping)
{
-        SelectedItemBindMapping previousSelectedItemsBindMapping = this.selectedItemsBindMapping;
+    public void setSelectedItemsBindMapping(ItemBindMapping selectedItemsBindMapping) {
+        ItemBindMapping previousSelectedItemsBindMapping = this.selectedItemsBindMapping;
 
         if (previousSelectedItemsBindMapping != selectedItemsBindMapping) {
             this.selectedItemsBindMapping = selectedItemsBindMapping;
@@ -1646,6 +1688,48 @@ public class ListView extends Component 
         }
     }
 
+    public String getCheckedItemsKey() {
+        return checkedItemsKey;
+    }
+
+    public void setCheckedItemsKey(String checkedItemsKey) {
+        String previousCheckedItemsKey = this.checkedItemsKey;
+
+        if (previousCheckedItemsKey != checkedItemsKey) {
+            this.checkedItemsKey = checkedItemsKey;
+            listViewListeners.checkedItemsKeyChanged(this, previousCheckedItemsKey);
+        }
+    }
+
+    public BindType getCheckedItemsBindType() {
+        return checkedItemsBindType;
+    }
+
+    public void setCheckedItemsBindType(BindType checkedItemsBindType) {
+        if (checkedItemsBindType == null) {
+            throw new IllegalArgumentException();
+        }
+
+        BindType previousCheckedItemsBindType = this.checkedItemsBindType;
+        if (previousCheckedItemsBindType != checkedItemsBindType) {
+            this.checkedItemsBindType = checkedItemsBindType;
+            listViewListeners.checkedItemsBindTypeChanged(this, previousCheckedItemsBindType);
+        }
+    }
+
+    public ItemBindMapping getCheckedItemsBindMapping() {
+        return checkedItemsBindMapping;
+    }
+
+    public void setCheckedItemsBindMapping(ItemBindMapping checkedItemsBindMapping) {
+        ItemBindMapping previousCheckedItemsBindMapping = this.checkedItemsBindMapping;
+
+        if (previousCheckedItemsBindMapping != checkedItemsBindMapping) {
+            this.checkedItemsBindMapping = checkedItemsBindMapping;
+            listViewListeners.checkedItemsBindMappingChanged(this, previousCheckedItemsBindMapping);
+        }
+    }
+
     @Override
     @SuppressWarnings("unchecked")
     public void load(Dictionary<String, ?> context) {
@@ -1714,6 +1798,31 @@ public class ListView extends Component 
                 break;
             }
         }
+
+        if (checkmarksEnabled) {
+            if (checkedItemsKey != null
+                && JSON.containsKey(context, checkedItemsKey)
+                && checkedItemsBindType != BindType.STORE) {
+                Sequence<Object> items = (Sequence<Object>)JSON.get(context,
checkedItemsKey);
+
+                clearCheckmarks();
+
+                for (int i = 0, n = items.getLength(); i < n; i++) {
+                    Object item = items.get(i);
+
+                    int index;
+                    if (checkedItemsBindMapping == null) {
+                        index = ((List<Object>)listData).indexOf(item);
+                    } else {
+                        index = checkedItemsBindMapping.indexOf(listData, item);
+                    }
+
+                    if (index != -1) {
+                        setItemChecked(index, true);
+                    }
+                }
+            }
+        }
     }
 
     @Override
@@ -1784,6 +1893,29 @@ public class ListView extends Component 
                 break;
             }
         }
+
+        if (checkmarksEnabled) {
+            if (checkedItemsKey != null
+                && JSON.containsKey(context, checkedItemsKey)
+                && checkedItemsBindType != BindType.LOAD) {
+                ArrayList<Object> items = new ArrayList<Object>();
+
+                for (int i = 0, n = checkedIndexes.getLength(); i < n; i++) {
+                    Integer index = checkedIndexes.get(i);
+
+                    Object item;
+                    if (checkedItemsBindMapping == null) {
+                        item = listData.get(index);
+                    } else {
+                        item = checkedItemsBindMapping.get(listData, index);
+                    }
+
+                    items.add(item);
+                }
+
+                JSON.put(context, checkedItemsKey, items);
+            }
+        }
     }
 
     @Override
@@ -1796,6 +1928,10 @@ public class ListView extends Component 
             || selectedItemsKey != null) {
             setSelectedItem(null);
         }
+
+        if (checkedItemsKey != null) {
+            clearCheckmarks();
+        }
     }
 
     /**

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListViewListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListViewListener.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListViewListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListViewListener.java Thu Mar 11 13:31:05 2010
@@ -80,7 +80,7 @@ public interface ListViewListener {
 
         @Override
         public void selectedItemBindMappingChanged(ListView listView,
-            ListView.SelectedItemBindMapping previousSelectedItemBindMapping) {
+            ListView.ItemBindMapping previousSelectedItemBindMapping) {
         }
 
         @Override
@@ -93,7 +93,20 @@ public interface ListViewListener {
 
         @Override
         public void selectedItemsBindMappingChanged(ListView listView,
-            ListView.SelectedItemBindMapping previousSelectedItemsBindMapping) {
+            ListView.ItemBindMapping previousSelectedItemsBindMapping) {
+        }
+
+        @Override
+        public void checkedItemsKeyChanged(ListView listView, String previousCheckedItemsKey)
{
+        }
+
+        @Override
+        public void checkedItemsBindTypeChanged(ListView listView, BindType previousCheckedItemsBindType)
{
+        }
+
+        @Override
+        public void checkedItemsBindMappingChanged(ListView listView,
+            ListView.ItemBindMapping previousCheckedItemsBindMapping) {
         }
     }
 
@@ -200,7 +213,7 @@ public interface ListViewListener {
      * @param previousSelectedItemBindMapping
      */
     public void selectedItemBindMappingChanged(ListView listView,
-        ListView.SelectedItemBindMapping previousSelectedItemBindMapping);
+        ListView.ItemBindMapping previousSelectedItemBindMapping);
 
     /**
      * Called when a list view's selected items key has changed.
@@ -225,5 +238,30 @@ public interface ListViewListener {
      * @param previousSelectedItemsBindMapping
      */
     public void selectedItemsBindMappingChanged(ListView listView,
-        ListView.SelectedItemBindMapping previousSelectedItemsBindMapping);
+        ListView.ItemBindMapping previousSelectedItemsBindMapping);
+
+    /**
+     * Called when a list view's checked items key has changed.
+     *
+     * @param listView
+     * @param previousCheckedItemsKey
+     */
+    public void checkedItemsKeyChanged(ListView listView, String previousCheckedItemsKey);
+
+    /**
+     * Called when a list view's checked items bind type has changed.
+     *
+     * @param listView
+     * @param previousCheckedItemsBindType
+     */
+    public void checkedItemsBindTypeChanged(ListView listView, BindType previousCheckedItemsBindType);
+
+    /**
+     * Called when a list view's checked items bind mapping has changed.
+     *
+     * @param listView
+     * @param previousCheckedItemsBindMapping
+     */
+    public void checkedItemsBindMappingChanged(ListView listView,
+        ListView.ItemBindMapping previousCheckedItemsBindMapping);
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java Thu Mar 11 13:31:05 2010
@@ -75,9 +75,10 @@ public class Spinner extends Container {
     /**
      * Translates between spinner and bind context data during data binding.
      */
-    public interface SelectedItemBindMapping {
+    public interface ItemBindMapping {
         /**
-         * Returns the index of the item in the source list.
+         * Returns the index of the item in the source list during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param spinnerData
          * The source spinner data.
@@ -92,7 +93,8 @@ public class Spinner extends Container {
         public int indexOf(List<?> spinnerData, Object value);
 
         /**
-         * Retrieves the item at the given index.
+         * Retrieves the item at the given index during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param spinnerData
          * The source spinner data.
@@ -189,7 +191,7 @@ public class Spinner extends Container {
         }
 
         @Override
-        public void selectedItemBindMappingChanged(Spinner spinner, SelectedItemBindMapping
previousSelectedItemBindMapping) {
+        public void selectedItemBindMappingChanged(Spinner spinner, ItemBindMapping previousSelectedItemBindMapping)
{
             for (SpinnerListener listener : this) {
                 listener.selectedItemBindMappingChanged(spinner, previousSelectedItemBindMapping);
             }
@@ -259,7 +261,7 @@ public class Spinner extends Container {
     private boolean circular = false;
     private int selectedIndex = -1;
     private String selectedItemKey = null;
-    private SelectedItemBindMapping selectedItemBindMapping = null;
+    private ItemBindMapping selectedItemBindMapping = null;
 
     private SpinnerListenerList spinnerListeners = new SpinnerListenerList();
     private SpinnerItemListenerList spinnerItemListeners = new SpinnerItemListenerList();
@@ -448,12 +450,12 @@ public class Spinner extends Container {
         }
     }
 
-    public SelectedItemBindMapping getSelectedItemBindMapping() {
+    public ItemBindMapping getSelectedItemBindMapping() {
         return selectedItemBindMapping;
     }
 
-    public void setSelectedItemBindMapping(SelectedItemBindMapping selectedItemBindMapping)
{
-        SelectedItemBindMapping previousSelectedItemBindMapping = this.selectedItemBindMapping;
+    public void setSelectedItemBindMapping(ItemBindMapping selectedItemBindMapping) {
+        ItemBindMapping previousSelectedItemBindMapping = this.selectedItemBindMapping;
 
         if (previousSelectedItemBindMapping != selectedItemBindMapping) {
             this.selectedItemBindMapping = selectedItemBindMapping;

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerListener.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerListener.java Thu Mar 11 13:31:05 2010
@@ -43,7 +43,7 @@ public interface SpinnerListener {
         }
 
         @Override
-        public void selectedItemBindMappingChanged(Spinner spinner, Spinner.SelectedItemBindMapping
previousSelectedItemBindMapping) {
+        public void selectedItemBindMappingChanged(Spinner spinner, Spinner.ItemBindMapping
previousSelectedItemBindMapping) {
         }
     }
 
@@ -84,5 +84,5 @@ public interface SpinnerListener {
      * @param spinner
      * @param previousSelectedItemBindMapping
      */
-    public void selectedItemBindMappingChanged(Spinner spinner, Spinner.SelectedItemBindMapping
previousSelectedItemBindMapping);
+    public void selectedItemBindMappingChanged(Spinner spinner, Spinner.ItemBindMapping previousSelectedItemBindMapping);
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java Thu Mar 11 13:31:05 2010
@@ -99,6 +99,27 @@ public class TextArea extends Component 
         public Bounds getCharacterBounds(int offset);
     }
 
+    /**
+     * Translates between text and context data during data binding.
+     */
+    public interface TextBindMapping {
+        /**
+         * Converts a value from the bind context to a text representation during a
+         * {@link Component#load(Dictionary)} operation.
+         *
+         * @param value
+         */
+        public String toString(Object value);
+
+        /**
+         * Converts a text string to a value to be stored in the bind context during a
+         * {@link Component#store(Dictionary)} operation.
+         *
+         * @param text
+         */
+        public Object valueOf(String text);
+    }
+
     private static class TextAreaListenerList extends ListenerList<TextAreaListener>
         implements TextAreaListener {
         @Override
@@ -121,6 +142,20 @@ public class TextArea extends Component 
                 listener.textKeyChanged(textArea, previousTextKey);
             }
         }
+
+        @Override
+        public void textBindTypeChanged(TextArea textArea, BindType previousTextBindType)
{
+            for (TextAreaListener listener : this) {
+                listener.textBindTypeChanged(textArea, previousTextBindType);
+            }
+        }
+
+        @Override
+        public void textBindMappingChanged(TextArea textArea, TextBindMapping previousTextBindMapping)
{
+            for (TextAreaListener listener : this) {
+                listener.textBindMappingChanged(textArea, previousTextBindMapping);
+            }
+        }
     }
 
     private static class TextAreaCharacterListenerList extends ListenerList<TextAreaCharacterListener>
@@ -157,7 +192,10 @@ public class TextArea extends Component 
     private int selectionLength = 0;
 
     private boolean editable = true;
+
     private String textKey = null;
+    private BindType textBindType = BindType.BOTH;
+    private TextBindMapping textBindMapping = null;
 
     private NodeListener documentListener = new NodeListener() {
         @Override
@@ -779,13 +817,45 @@ public class TextArea extends Component 
         }
     }
 
+    public BindType getTextBindType() {
+        return textBindType;
+    }
+
+    public void setTextBindType(BindType textBindType) {
+        BindType previousTextBindType = this.textBindType;
+        if (previousTextBindType != textBindType) {
+            this.textBindType = textBindType;
+            textAreaListeners.textBindTypeChanged(this, previousTextBindType);
+        }
+
+    }
+
+    public TextBindMapping getTextBindMapping() {
+        return textBindMapping;
+    }
+
+    public void setTextBindMapping(TextBindMapping textBindMapping) {
+        TextBindMapping previousTextBindMapping = this.textBindMapping;
+
+        if (previousTextBindMapping != textBindMapping) {
+            this.textBindMapping = textBindMapping;
+            textAreaListeners.textBindMappingChanged(this, previousTextBindMapping);
+        }
+    }
+
     @Override
     public void load(Dictionary<String, ?> context) {
         if (textKey != null
-            && JSON.containsKey(context, textKey)) {
+            && JSON.containsKey(context, textKey)
+            && textBindType != BindType.STORE) {
             Object value = JSON.get(context, textKey);
-            if (value != null) {
-                value = value.toString();
+
+            if (textBindMapping == null) {
+                if (value != null) {
+                    value = value.toString();
+                }
+            } else {
+                value = textBindMapping.toString(value);
             }
 
             setText((String)value);
@@ -794,9 +864,11 @@ public class TextArea extends Component 
 
     @Override
     public void store(Dictionary<String, ?> context) {
-        if (isEnabled()
-            && textKey != null) {
-            JSON.put(context, textKey, getText());
+        if (textKey != null
+            && textBindType != BindType.LOAD) {
+            String text = getText();
+            JSON.put(context, textKey, (textBindMapping == null) ?
+                text : textBindMapping.valueOf(text));
         }
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java Thu Mar 11 13:31:05 2010
@@ -37,6 +37,14 @@ public interface TextAreaListener {
         @Override
         public void textKeyChanged(TextArea textArea, String previousTextKey) {
         }
+
+        @Override
+        public void textBindTypeChanged(TextArea textArea, BindType previousTextBindType)
{
+        }
+
+        @Override
+        public void textBindMappingChanged(TextArea textArea, TextArea.TextBindMapping previousTextBindMapping)
{
+        }
     }
 
     /**
@@ -64,4 +72,20 @@ public interface TextAreaListener {
      * @param previousTextKey
      */
     public void textKeyChanged(TextArea textArea, String previousTextKey);
+
+    /**
+     * Called when a text area's text bind type has changed.
+     *
+     * @param textArea
+     * @param previousTextBindType
+     */
+    public void textBindTypeChanged(TextArea textArea, BindType previousTextBindType);
+
+    /**
+     * Called when a text area's bind mapping has changed.
+     *
+     * @param textArea
+     * @param previousTextBindMapping
+     */
+    public void textBindMappingChanged(TextArea textArea, TextArea.TextBindMapping previousTextBindMapping);
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Thu Mar 11 13:31:05 2010
@@ -64,14 +64,16 @@ public class TextInput extends Component
      */
     public interface TextBindMapping {
         /**
-         * Converts a value from the bind context to a text representation.
+         * Converts a value from the bind context to a text representation during a
+         * {@link Component#load(Dictionary)} operation.
          *
          * @param value
          */
         public String toString(Object value);
 
         /**
-         * Converts a text string to a value to be stored in the bind context.
+         * Converts a text string to a value to be stored in the bind context during a
+         * {@link Component#store(Dictionary)} operation.
          *
          * @param text
          */
@@ -123,6 +125,13 @@ public class TextInput extends Component
         }
 
         @Override
+        public void textBindTypeChanged(TextInput textInput, BindType previousTextBindType)
{
+            for (TextInputListener listener : this) {
+                listener.textBindTypeChanged(textInput, previousTextBindType);
+            }
+        }
+
+        @Override
         public void textBindMappingChanged(TextInput textInput, TextInput.TextBindMapping
previousTextBindMapping) {
             for (TextInputListener listener : this) {
                 listener.textBindMappingChanged(textInput, previousTextBindMapping);
@@ -195,6 +204,7 @@ public class TextInput extends Component
     private String prompt = null;
 
     private String textKey = null;
+    private BindType textBindType = BindType.BOTH;
     private TextBindMapping textBindMapping = null;
 
     private Validator validator = null;
@@ -740,6 +750,19 @@ public class TextInput extends Component
         }
     }
 
+    public BindType getTextBindType() {
+        return textBindType;
+    }
+
+    public void setTextBindType(BindType textBindType) {
+        BindType previousTextBindType = this.textBindType;
+        if (previousTextBindType != textBindType) {
+            this.textBindType = textBindType;
+            textInputListeners.textBindTypeChanged(this, previousTextBindType);
+        }
+
+    }
+
     public TextBindMapping getTextBindMapping() {
         return textBindMapping;
     }
@@ -756,7 +779,8 @@ public class TextInput extends Component
     @Override
     public void load(Dictionary<String, ?> context) {
         if (textKey != null
-            && JSON.containsKey(context, textKey)) {
+            && JSON.containsKey(context, textKey)
+            && textBindType != BindType.STORE) {
             Object value = JSON.get(context, textKey);
 
             if (textBindMapping == null) {
@@ -773,8 +797,8 @@ public class TextInput extends Component
 
     @Override
     public void store(Dictionary<String, ?> context) {
-        if (isEnabled()
-            && textKey != null) {
+        if (textKey != null
+            && textBindType != BindType.LOAD) {
             String text = getText();
             JSON.put(context, textKey, (textBindMapping == null) ?
                 text : textBindMapping.valueOf(text));
@@ -784,7 +808,7 @@ public class TextInput extends Component
     @Override
     public void clear() {
         if (textKey != null) {
-            setText("");
+            setText(null);
         }
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java Thu Mar 11 13:31:05 2010
@@ -52,6 +52,10 @@ public interface TextInputListener {
         }
 
         @Override
+        public void textBindTypeChanged(TextInput textInput, BindType previousTextBindType)
{
+        }
+
+        @Override
         public void textBindMappingChanged(TextInput textInput, TextInput.TextBindMapping
previousTextBindMapping) {
         }
 
@@ -115,6 +119,14 @@ public interface TextInputListener {
     public void textKeyChanged(TextInput textInput, String previousTextKey);
 
     /**
+     * Called when a text input's text bind type has changed.
+     *
+     * @param textInput
+     * @param previousTextBindType
+     */
+    public void textBindTypeChanged(TextInput textInput, BindType previousTextBindType);
+
+    /**
      * Called when a text input's bind mapping has changed.
      *
      * @param textInput

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java Thu Mar 11 13:31:05 2010
@@ -31,6 +31,7 @@ import java.text.StringCharacterIterator
 
 import org.apache.pivot.collections.ArrayList;
 import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.wtk.BindType;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.Dimensions;
 import org.apache.pivot.wtk.GraphicsUtilities;
@@ -590,6 +591,11 @@ public class LabelSkin extends Component
     }
 
     @Override
+    public void textBindTypeChanged(Label label, BindType previousTextBindType) {
+        // No-op
+    }
+
+    @Override
     public void textBindMappingChanged(Label label, Label.TextBindMapping previousTextBindMapping)
{
         // No-op
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java Thu Mar 11 13:31:05
2010
@@ -373,7 +373,7 @@ public abstract class ListButtonSkin ext
     }
 
     @Override
-    public void selectedItemBindMappingChanged(ListButton listButton, ListView.SelectedItemBindMapping
previousSelectedItemBindMapping) {
+    public void selectedItemBindMappingChanged(ListButton listButton, ListView.ItemBindMapping
previousSelectedItemBindMapping) {
         // No-op
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=921842&r1=921841&r2=921842&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Thu Mar 11 13:31:05 2010
@@ -36,6 +36,7 @@ import org.apache.pivot.collections.Dict
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.util.ImmutableIterator;
 import org.apache.pivot.wtk.ApplicationContext;
+import org.apache.pivot.wtk.BindType;
 import org.apache.pivot.wtk.Bounds;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.Cursor;
@@ -2294,6 +2295,16 @@ public class TextAreaSkin extends Compon
         // No-op
     }
 
+    @Override
+    public void textBindTypeChanged(TextArea textArea, BindType previousTextBindType) {
+        // No-op
+    }
+
+    @Override
+    public void textBindMappingChanged(TextArea textArea, TextArea.TextBindMapping previousTextBindMapping)
{
+        // No-op
+    }
+
     // Text area selection events
     @Override
     public void selectionChanged(TextArea textArea, int previousSelectionStart,



Mime
View raw message