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/03/13 14:39:57 UTC
svn commit: r922561 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk:
Button.java Calendar.java CalendarButton.java Component.java Label.java
ListButton.java ListView.java Spinner.java SpinnerBindingListener.java
TableView.java TextArea.java TextInput.java
Author: gbrown
Date: Sat Mar 13 13:39:56 2010
New Revision: 922561
URL: http://svn.apache.org/viewvc?rev=922561&view=rev
Log:
Add string setters for bind type properties so they can be specified in WTKX; add spinner data binding to Spinner class.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Calendar.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerBindingListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java Sat Mar 13 13:39:56 2010
@@ -570,6 +570,14 @@ public abstract class Button extends Com
}
}
+ public final void setSelectedBindType(String selectedBindType) {
+ if (selectedBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedBindType(BindType.valueOf(selectedBindType.toUpperCase()));
+ }
+
public SelectedBindMapping getSelectedBindMapping() {
return selectedBindMapping;
}
@@ -613,6 +621,14 @@ public abstract class Button extends Com
}
}
+ public final void setStateBindType(String stateBindType) {
+ if (stateBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setStateBindType(BindType.valueOf(stateBindType.toUpperCase()));
+ }
+
public StateBindMapping getStateBindMapping() {
return stateBindMapping;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Calendar.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Calendar.java?rev=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Calendar.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Calendar.java Sat Mar 13 13:39:56 2010
@@ -342,6 +342,10 @@ public class Calendar extends Container
}
public void setSelectedDateBindType(BindType selectedDateBindType) {
+ if (selectedDateBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
BindType previousSelectedDateBindType = this.selectedDateBindType;
if (previousSelectedDateBindType != selectedDateBindType) {
@@ -350,6 +354,14 @@ public class Calendar extends Container
}
}
+ public final void setSelectedDateBindType(String selectedDateBindType) {
+ if (selectedDateBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedDateBindType(BindType.valueOf(selectedDateBindType.toUpperCase()));
+ }
+
public SelectedDateBindMapping getSelectedDateBindMapping() {
return selectedDateBindMapping;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java?rev=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java Sat Mar 13 13:39:56 2010
@@ -289,6 +289,10 @@ public class CalendarButton extends Butt
}
public void setSelectedDateBindType(BindType selectedDateBindType) {
+ if (selectedDateBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
BindType previousSelectedDateBindType = this.selectedDateBindType;
if (previousSelectedDateBindType != selectedDateBindType) {
@@ -297,6 +301,14 @@ public class CalendarButton extends Butt
}
}
+ public final void setSelectedDateBindType(String selectedDateBindType) {
+ if (selectedDateBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedDateBindType(BindType.valueOf(selectedDateBindType.toUpperCase()));
+ }
+
public Calendar.SelectedDateBindMapping getSelectedDateBindMapping() {
return selectedDateBindMapping;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Sat Mar 13 13:39:56 2010
@@ -1660,26 +1660,22 @@ public abstract class Component implemen
/**
* Determines if this component is showing. To be showing, the component
- * and all of its ancestors must be visible, and the component's window
- * must be open.
+ * and all of its ancestors must be visible and attached to a display.
*
* @return
- * <tt>true</tt> if this component is showing; <tt>false</tt> otherwise
+ * <tt>true</tt> if this component is showing; <tt>false</tt> otherwise.
*/
public boolean isShowing() {
- boolean showing = true;
-
Component component = this;
- while (component != null
- && showing) {
- Container parent = component.getParent();
- showing &= (component.isVisible()
- && (parent != null || component instanceof Display));
- component = parent;
+ while (component != null
+ && component.isVisible()
+ && !(component instanceof Display)) {
+ component = component.getParent();
}
- return showing;
+ return (component != null
+ && component.isVisible());
}
/**
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Label.java Sat Mar 13 13:39:56 2010
@@ -140,12 +140,24 @@ public class Label extends Component {
}
public void setTextBindType(BindType textBindType) {
+ if (textBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
BindType previousTextBindType = this.textBindType;
+
if (previousTextBindType != textBindType) {
this.textBindType = textBindType;
labelBindingListeners.textBindTypeChanged(this, previousTextBindType);
}
+ }
+
+ public final void setTextBindType(String textBindType) {
+ if (textBindType == null) {
+ throw new IllegalArgumentException();
+ }
+ setTextBindType(BindType.valueOf(textBindType.toUpperCase()));
}
public TextBindMapping getTextBindMapping() {
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java Sat Mar 13 13:39:56 2010
@@ -387,6 +387,14 @@ public class ListButton extends Button {
}
}
+ public final void setListDataBindType(String listDataBindType) {
+ if (listDataBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setListDataBindType(BindType.valueOf(listDataBindType.toUpperCase()));
+ }
+
public ListDataBindMapping getListDataBindMapping() {
return listDataBindMapping;
}
@@ -429,6 +437,14 @@ public class ListButton extends Button {
}
}
+ public final void setSelectedItemBindType(String selectedItemBindType) {
+ if (selectedItemBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedItemBindType(BindType.valueOf(selectedItemBindType.toUpperCase()));
+ }
+
public ListView.ItemBindMapping getSelectedItemBindMapping() {
return selectedItemBindMapping;
}
@@ -483,7 +499,6 @@ public class ListButton extends Button {
// Bind to list data
if (listDataKey != null
&& listDataBindType != BindType.LOAD) {
-
Object value;
if (listDataBindMapping == null) {
value = listData;
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListView.java Sat Mar 13 13:39:56 2010
@@ -1581,6 +1581,14 @@ public class ListView extends Component
}
}
+ public final void setListDataBindType(String listDataBindType) {
+ if (listDataBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setListDataBindType(BindType.valueOf(listDataBindType.toUpperCase()));
+ }
+
public ListDataBindMapping getListDataBindMapping() {
return listDataBindMapping;
}
@@ -1623,6 +1631,14 @@ public class ListView extends Component
}
}
+ public final void setSelectedItemBindType(String selectedItemBindType) {
+ if (selectedItemBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedItemBindType(BindType.valueOf(selectedItemBindType.toUpperCase()));
+ }
+
public ItemBindMapping getSelectedItemBindMapping() {
return selectedItemBindMapping;
}
@@ -1665,6 +1681,14 @@ public class ListView extends Component
}
}
+ public final void setSelectedItemsBindType(String selectedItemsBindType) {
+ if (selectedItemsBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedItemsBindType(BindType.valueOf(selectedItemsBindType.toUpperCase()));
+ }
+
public ItemBindMapping getSelectedItemsBindMapping() {
return selectedItemsBindMapping;
}
@@ -1820,7 +1844,6 @@ public class ListView extends Component
// Bind to list data
if (listDataKey != null
&& listDataBindType != BindType.LOAD) {
-
Object value;
if (listDataBindMapping == null) {
value = listData;
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Spinner.java Sat Mar 13 13:39:56 2010
@@ -65,6 +65,27 @@ public class Spinner extends Container {
}
/**
+ * Translates between spinner and bind context data during data binding.
+ */
+ public interface SpinnerDataBindMapping {
+ /**
+ * Converts a context value to spinner data during a
+ * {@link Component#load(Dictionary)} operation.
+ *
+ * @param value
+ */
+ public List<?> toSpinnerData(Object value);
+
+ /**
+ * Converts spinner data to a context value during a
+ * {@link Component#store(Dictionary)} operation.
+ *
+ * @param spinnerData
+ */
+ public Object valueOf(List<?> spinnerData);
+ }
+
+ /**
* Spinner skin interface. Spinner skins must implement this interface to
* facilitate additional communication between the component and the skin.
*/
@@ -105,60 +126,6 @@ public class Spinner extends Container {
public Object get(List<?> spinnerData, int index);
}
- /**
- * List event handler.
- */
- private class ListHandler implements ListListener<Object> {
- @Override
- public void itemInserted(List<Object> list, int index) {
- if (index <= selectedIndex) {
- selectedIndex++;
- }
-
- // Notify listeners that items were inserted
- spinnerItemListeners.itemInserted(Spinner.this, index);
- }
-
- @Override
- public void itemsRemoved(List<Object> list, int index, Sequence<Object> items) {
- int count = items.getLength();
-
- if (index + count <= selectedIndex) {
- selectedIndex--;
- } else if (index <= selectedIndex) {
- selectedIndex = -1;
- }
-
- // Notify listeners that items were removed
- spinnerItemListeners.itemsRemoved(Spinner.this, index, count);
- }
-
- @Override
- public void itemUpdated(List<Object> list, int index, Object previousItem) {
- spinnerItemListeners.itemUpdated(Spinner.this, index);
- }
-
- @Override
- public void listCleared(List<Object> list) {
- // All items were removed; clear the selection and notify
- // listeners
- selectedIndex = -1;
- spinnerItemListeners.itemsCleared(Spinner.this);
- }
-
- @Override
- public void comparatorChanged(List<Object> list,
- Comparator<Object> previousComparator) {
- if (list.getComparator() != null) {
- selectedIndex = -1;
- spinnerItemListeners.itemsSorted(Spinner.this);
- }
- }
- }
-
- /**
- * Spinner listener list.
- */
private static class SpinnerListenerList extends ListenerList<SpinnerListener>
implements SpinnerListener {
@Override
@@ -236,6 +203,28 @@ public class Spinner extends Container {
private class SpinnerBindingListenerList extends ListenerList<SpinnerBindingListener>
implements SpinnerBindingListener {
@Override
+ public void spinnerDataKeyChanged(Spinner spinner, String previousSpinnerDataKey) {
+ for (SpinnerBindingListener listener : this) {
+ listener.spinnerDataKeyChanged(spinner, previousSpinnerDataKey);
+ }
+ }
+
+ @Override
+ public void spinnerDataBindTypeChanged(Spinner spinner, BindType previousSpinnerDataBindType) {
+ for (SpinnerBindingListener listener : this) {
+ listener.spinnerDataBindTypeChanged(spinner, previousSpinnerDataBindType);
+ }
+ }
+
+ @Override
+ public void spinnerDataBindMappingChanged(Spinner spinner,
+ Spinner.SpinnerDataBindMapping previousSpinnerDataBindMapping) {
+ for (SpinnerBindingListener listener : this) {
+ listener.spinnerDataBindMappingChanged(spinner, previousSpinnerDataBindMapping);
+ }
+ }
+
+ @Override
public void selectedItemKeyChanged(Spinner spinner, String previousSelectedItemKey) {
for (SpinnerBindingListener listener : this) {
listener.selectedItemKeyChanged(spinner, previousSelectedItemKey);
@@ -258,17 +247,68 @@ public class Spinner extends Container {
}
private List<?> spinnerData = null;
- private ListHandler spinnerDataHandler = new ListHandler();
private ItemRenderer itemRenderer = null;
private boolean circular = false;
private int selectedIndex = -1;
+ private String spinnerDataKey = null;
+ private BindType spinnerDataBindType = BindType.BOTH;
+ private SpinnerDataBindMapping spinnerDataBindMapping = null;
+
private String selectedItemKey = null;
private BindType selectedItemBindType = BindType.BOTH;
private ItemBindMapping selectedItemBindMapping = null;
+ private ListListener<Object> spinnerDataListener = new ListListener<Object>() {
+ @Override
+ public void itemInserted(List<Object> list, int index) {
+ if (index <= selectedIndex) {
+ selectedIndex++;
+ }
+
+ // Notify listeners that items were inserted
+ spinnerItemListeners.itemInserted(Spinner.this, index);
+ }
+
+ @Override
+ public void itemsRemoved(List<Object> list, int index, Sequence<Object> items) {
+ int count = items.getLength();
+
+ if (index + count <= selectedIndex) {
+ selectedIndex--;
+ } else if (index <= selectedIndex) {
+ selectedIndex = -1;
+ }
+
+ // Notify listeners that items were removed
+ spinnerItemListeners.itemsRemoved(Spinner.this, index, count);
+ }
+
+ @Override
+ public void itemUpdated(List<Object> list, int index, Object previousItem) {
+ spinnerItemListeners.itemUpdated(Spinner.this, index);
+ }
+
+ @Override
+ public void listCleared(List<Object> list) {
+ // All items were removed; clear the selection and notify
+ // listeners
+ selectedIndex = -1;
+ spinnerItemListeners.itemsCleared(Spinner.this);
+ }
+
+ @Override
+ public void comparatorChanged(List<Object> list,
+ Comparator<Object> previousComparator) {
+ if (list.getComparator() != null) {
+ selectedIndex = -1;
+ spinnerItemListeners.itemsSorted(Spinner.this);
+ }
+ }
+ };
+
private SpinnerListenerList spinnerListeners = new SpinnerListenerList();
private SpinnerItemListenerList spinnerItemListeners = new SpinnerItemListenerList();
private SpinnerSelectionListenerList spinnerSelectionListeners =
@@ -323,10 +363,10 @@ public class Spinner extends Container {
// Clear any existing selection
selectedIndex = -1;
- ((List<Object>)previousSpinnerData).getListListeners().remove(spinnerDataHandler);
+ ((List<Object>)previousSpinnerData).getListListeners().remove(spinnerDataListener);
}
- ((List<Object>)spinnerData).getListListeners().add(spinnerDataHandler);
+ ((List<Object>)spinnerData).getListListeners().add(spinnerDataListener);
// Update the spinner data and fire change event
this.spinnerData = spinnerData;
@@ -438,16 +478,60 @@ public class Spinner extends Container {
setSelectedIndex((item == null) ? -1 : ((List<Object>)spinnerData).indexOf(item));
}
- /**
- * Gets the data binding key that is set on this spinner.
- */
+ public String getSpinnerDataKey() {
+ return spinnerDataKey;
+ }
+
+ public void setSpinnerDataKey(String spinnerDataKey) {
+ String previousSpinnerDataKey = this.spinnerDataKey;
+ if (previousSpinnerDataKey != spinnerDataKey) {
+ this.spinnerDataKey = spinnerDataKey;
+ spinnerBindingListeners.spinnerDataKeyChanged(this, previousSpinnerDataKey);
+ }
+ }
+
+ public BindType getSpinnerDataBindType() {
+ return spinnerDataBindType;
+ }
+
+ public void setSpinnerDataBindType(BindType spinnerDataBindType) {
+ if (spinnerDataBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ BindType previousSpinnerDataBindType = this.spinnerDataBindType;
+
+ if (previousSpinnerDataBindType != spinnerDataBindType) {
+ this.spinnerDataBindType = spinnerDataBindType;
+ spinnerBindingListeners.spinnerDataBindTypeChanged(this, previousSpinnerDataBindType);
+ }
+ }
+
+ public final void setSpinnerDataBindType(String spinnerDataBindType) {
+ if (spinnerDataBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSpinnerDataBindType(BindType.valueOf(spinnerDataBindType.toUpperCase()));
+ }
+
+ public SpinnerDataBindMapping getSpinnerDataBindMapping() {
+ return spinnerDataBindMapping;
+ }
+
+ public void setSpinnerDataBindMapping(SpinnerDataBindMapping spinnerDataBindMapping) {
+ SpinnerDataBindMapping previousSpinnerDataBindMapping = this.spinnerDataBindMapping;
+
+ if (previousSpinnerDataBindMapping != spinnerDataBindMapping) {
+ this.spinnerDataBindMapping = spinnerDataBindMapping;
+ spinnerBindingListeners.spinnerDataBindMappingChanged(this, previousSpinnerDataBindMapping);
+ }
+ }
+
public String getSelectedItemKey() {
return selectedItemKey;
}
- /**
- * Sets this spinner's data binding key.
- */
public void setSelectedItemKey(String selectedItemKey) {
String previousSelectedItemKey = this.selectedItemKey;
@@ -473,6 +557,14 @@ public class Spinner extends Container {
}
}
+ public final void setSelectedItemBindType(String selectedItemBindType) {
+ if (selectedItemBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedItemBindType(BindType.valueOf(selectedItemBindType.toUpperCase()));
+ }
+
public ItemBindMapping getSelectedItemBindMapping() {
return selectedItemBindMapping;
}
@@ -489,6 +581,23 @@ public class Spinner extends Container {
@Override
@SuppressWarnings("unchecked")
public void load(Dictionary<String, ?> context) {
+ // Bind to spinner data
+ if (spinnerDataKey != null
+ && spinnerDataBindType != BindType.STORE
+ && JSON.containsKey(context, spinnerDataKey)) {
+ Object value = JSON.get(context, spinnerDataKey);
+
+ List<?> spinnerData;
+ if (spinnerDataBindMapping == null) {
+ spinnerData = (List<?>)value;
+ } else {
+ spinnerData = spinnerDataBindMapping.toSpinnerData(value);
+ }
+
+ setSpinnerData(spinnerData);
+ }
+
+ // Bind to selected item
if (selectedItemKey != null
&& JSON.containsKey(context, selectedItemKey)
&& selectedItemBindType != BindType.STORE) {
@@ -507,6 +616,20 @@ public class Spinner extends Container {
@Override
public void store(Dictionary<String, ?> context) {
+ // Bind to spinner data
+ if (spinnerDataKey != null
+ && spinnerDataBindType != BindType.LOAD) {
+ Object value;
+ if (spinnerDataBindMapping == null) {
+ value = spinnerData;
+ } else {
+ value = spinnerDataBindMapping.valueOf(spinnerData);
+ }
+
+ JSON.put(context, spinnerDataKey, value);
+ }
+
+ // Bind to selected item
if (selectedItemKey != null
&& selectedItemBindType != BindType.LOAD) {
Object item;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerBindingListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerBindingListener.java?rev=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerBindingListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerBindingListener.java Sat Mar 13 13:39:56 2010
@@ -25,6 +25,19 @@ public interface SpinnerBindingListener
*/
public static class Adapter implements SpinnerBindingListener {
@Override
+ public void spinnerDataKeyChanged(Spinner spinner, String previousSpinnerDataKey) {
+ }
+
+ @Override
+ public void spinnerDataBindTypeChanged(Spinner spinner, BindType previousSpinnerDataBindType) {
+ }
+
+ @Override
+ public void spinnerDataBindMappingChanged(Spinner spinner,
+ Spinner.SpinnerDataBindMapping previousSpinnerDataBindMapping) {
+ }
+
+ @Override
public void selectedItemKeyChanged(Spinner spinner, String previousSelectedItemKey) {
}
@@ -38,6 +51,31 @@ public interface SpinnerBindingListener
}
/**
+ * Called when a spinner's spinner data key has changed.
+ *
+ * @param spinner
+ * @param previousSpinnerDataKey
+ */
+ public void spinnerDataKeyChanged(Spinner spinner, String previousSpinnerDataKey);
+
+ /**
+ * Called when a spinner's spinner data bind type has changed.
+ *
+ * @param spinner
+ * @param previousSpinnerDataBindType
+ */
+ public void spinnerDataBindTypeChanged(Spinner spinner, BindType previousSpinnerDataBindType);
+
+ /**
+ * Called when a spinner's spinner data bind mapping has changed.
+ *
+ * @param spinner
+ * @param previousSpinnerDataBindMapping
+ */
+ public void spinnerDataBindMappingChanged(Spinner spinner,
+ Spinner.SpinnerDataBindMapping previousSpinnerDataBindMapping);
+
+ /**
* Called when a spinner's selected item key has changed.
*
* @param spinner
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java?rev=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java Sat Mar 13 13:39:56 2010
@@ -2112,6 +2112,14 @@ public class TableView extends Component
}
}
+ public final void setTableDataBindType(String tableDataBindType) {
+ if (tableDataBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setTableDataBindType(BindType.valueOf(tableDataBindType.toUpperCase()));
+ }
+
public TableDataBindMapping getTableDataBindMapping() {
return tableDataBindMapping;
}
@@ -2154,6 +2162,14 @@ public class TableView extends Component
}
}
+ public final void setSelectedRowBindType(String selectedRowBindType) {
+ if (selectedRowBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedRowBindType(BindType.valueOf(selectedRowBindType.toUpperCase()));
+ }
+
public SelectedRowBindMapping getSelectedRowBindMapping() {
return selectedRowBindMapping;
}
@@ -2196,6 +2212,14 @@ public class TableView extends Component
}
}
+ public final void setSelectedRowsBindType(String selectedRowsBindType) {
+ if (selectedRowsBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setSelectedRowsBindType(BindType.valueOf(selectedRowsBindType.toUpperCase()));
+ }
+
public SelectedRowBindMapping getSelectedRowsBindMapping() {
return selectedRowsBindMapping;
}
@@ -2284,7 +2308,6 @@ public class TableView extends Component
// Bind to table data
if (tableDataKey != null
&& tableDataBindType != BindType.LOAD) {
-
Object value;
if (tableDataBindMapping == null) {
value = tableData;
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java Sat Mar 13 13:39:56 2010
@@ -188,6 +188,8 @@ public class TextArea extends Component
}
}
}
+
+ // TODO Don't allow null values, only empty strings
private Document document;
private int selectionStart = 0;
@@ -825,12 +827,24 @@ public class TextArea extends Component
}
public void setTextBindType(BindType textBindType) {
+ if (textBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
BindType previousTextBindType = this.textBindType;
+
if (previousTextBindType != textBindType) {
this.textBindType = textBindType;
textAreaBindingListeners.textBindTypeChanged(this, previousTextBindType);
}
+ }
+
+ public final void setTextBindType(String textBindType) {
+ if (textBindType == null) {
+ throw new IllegalArgumentException();
+ }
+ setTextBindType(BindType.valueOf(textBindType.toUpperCase()));
}
public TextBindMapping getTextBindMapping() {
@@ -854,9 +868,7 @@ public class TextArea extends Component
Object value = JSON.get(context, textKey);
if (textBindMapping == null) {
- if (value != null) {
- value = value.toString();
- }
+ value = (value == null) ? "" : value.toString();
} else {
value = textBindMapping.toString(value);
}
@@ -878,7 +890,7 @@ public class TextArea extends Component
@Override
public void clear() {
if (textKey != null) {
- setText((String)null);
+ setText("");
}
}
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=922561&r1=922560&r2=922561&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Sat Mar 13 13:39:56 2010
@@ -195,6 +195,7 @@ public class TextInput extends Component
}
}
+ // TODO Don't allow null values, only empty strings
private TextNode textNode;
private int selectionStart = 0;
@@ -550,7 +551,7 @@ public class TextInput extends Component
}
if (selectionStart < 0
- || selectionStart + selectionLength > textNode.getCharacterCount()) {
+ || selectionStart + selectionLength > getTextLength()) {
throw new IndexOutOfBoundsException();
}
@@ -586,7 +587,7 @@ public class TextInput extends Component
* Selects all text.
*/
public void selectAll() {
- setSelection(0, textNode.getCharacterCount());
+ setSelection(0, getTextLength());
}
/**
@@ -759,12 +760,24 @@ public class TextInput extends Component
}
public void setTextBindType(BindType textBindType) {
+ if (textBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
BindType previousTextBindType = this.textBindType;
+
if (previousTextBindType != textBindType) {
this.textBindType = textBindType;
textInputBindingListeners.textBindTypeChanged(this, previousTextBindType);
}
+ }
+ public final void setTextBindType(String textBindType) {
+ if (textBindType == null) {
+ throw new IllegalArgumentException();
+ }
+
+ setTextBindType(BindType.valueOf(textBindType.toUpperCase()));
}
public TextBindMapping getTextBindMapping() {
@@ -788,9 +801,7 @@ public class TextInput extends Component
Object value = JSON.get(context, textKey);
if (textBindMapping == null) {
- if (value != null) {
- value = value.toString();
- }
+ value = (value == null) ? "" : value.toString();
} else {
value = textBindMapping.toString(value);
}
@@ -812,7 +823,7 @@ public class TextInput extends Component
@Override
public void clear() {
if (textKey != null) {
- setText(null);
+ setText("");
}
}