You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/08/07 18:17:46 UTC
svn commit: r1370337 - in /pivot/branches/2.0.x:
tests/src/org/apache/pivot/tests/issues/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/
Author: smartini
Date: Tue Aug 7 16:17:45 2012
New Revision: 1370337
URL: http://svn.apache.org/viewvc?rev=1370337&view=rev
Log:
PIVOT-784, enhancements in clear and clearSelection for some components.
The test application here is still that of the original issue (already closed), Pivot-694.
Modified:
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/Pivot694.java
pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/pivot_694.bxml
pivot/branches/2.0.x/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/CalendarButton.java
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/ListButton.java
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TreeView.java
Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/Pivot694.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/Pivot694.java?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/Pivot694.java (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/Pivot694.java Tue Aug 7 16:17:45 2012
@@ -132,12 +132,15 @@ public class Pivot694 extends Applicatio
// radioButtons.clearSelection();
// checkButtons.clearSelection();
// checkTriButtons.clearSelection();
-//
-// calendarButton.clearSelection();
-// spinner.clearSelection();
-//
-// listButton1.clearSelection();
-// listButton2.clearSelection();
+
+ calendarButton1.clearSelection();
+ calendarButton2.clearSelection();
+
+ spinner1.clearSelection();
+ spinner2.clearSelection();
+
+ listButton1.clearSelection();
+ listButton2.clearSelection();
listView1.clearSelection();
listView2.clearSelection();
@@ -163,7 +166,7 @@ public class Pivot694 extends Applicatio
// checkTriButtons.remove(button);
// force clear of elements data ...
- clearComponent(calendarButton1); // TODO: doesn't seem to work on this component ...
+ clearComponent(calendarButton1);
clearComponent(calendarButton2);
clearComponent(spinner1);
clearComponent(spinner2);
@@ -174,12 +177,12 @@ public class Pivot694 extends Applicatio
clearComponent(listView2);
clearComponent(tableView1);
clearComponent(tableView2);
- clearComponent(treeView1); // TODO: doesn't seem to work on this component ...
+ clearComponent(treeView1);
clearComponent(treeView2);
// TODO: put (in bxml) the two tableView in a SplitPane, and see some strange moving mouse over ...
-// TODO: add clear even to some type of buttons (all types in the first row displayed) ...
+// TODO: add clear/clearSelection methods even to some type of buttons (all types in the first row displayed) ...
}
});
Modified: pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/pivot_694.bxml
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/pivot_694.bxml?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/pivot_694.bxml (original)
+++ pivot/branches/2.0.x/tests/src/org/apache/pivot/tests/issues/pivot_694.bxml Tue Aug 7 16:17:45 2012
@@ -118,12 +118,12 @@ limitations under the License.
<BoxPane styles="{padding:4, verticalAlignment:'top'}">
<FlowPane>
- <Label text="Select a date (buttonDataKey set):"/>
- <CalendarButton bxml:id="calendarButton1" buttonDataKey = "buttonDataKey" />
+ <Label text="Select a date (selectedDateKey set):"/>
+ <CalendarButton bxml:id="calendarButton1" selectedDateKey = "selectedDateKey" />
</FlowPane>
<Separator/>
<FlowPane>
- <Label text="Select a date (buttonDataKey not set):"/>
+ <Label text="Select a date (selectedDateKey not set):"/>
<CalendarButton bxml:id="calendarButton2" />
</FlowPane>
</BoxPane>
@@ -210,9 +210,10 @@ limitations under the License.
<BoxPane styles="{padding:4, verticalAlignment:'top'}">
<FlowPane>
- <Label text="TreeView (treeDataKey set): - future"/>
+ <Label text="TreeView (treeDataKey set):"/>
<TreeView bxml:id="treeView1" selectMode="multi"
ComponentListener.parentChanged="treeView1.expandAll();"
+ treeDataKey="treeDataKey"
>
<nodeRenderer>
<content:TreeViewNodeRenderer showIcon="true"/>
Modified: pivot/branches/2.0.x/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java (original)
+++ pivot/branches/2.0.x/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java Tue Aug 7 16:17:45 2012
@@ -32,13 +32,13 @@ import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.GraphicsUtilities;
import org.apache.pivot.wtk.Keyboard;
+import org.apache.pivot.wtk.Keyboard.KeyCode;
import org.apache.pivot.wtk.Mouse;
import org.apache.pivot.wtk.Orientation;
import org.apache.pivot.wtk.Spinner;
import org.apache.pivot.wtk.SpinnerListener;
import org.apache.pivot.wtk.SpinnerSelectionListener;
import org.apache.pivot.wtk.Theme;
-import org.apache.pivot.wtk.Keyboard.KeyCode;
import org.apache.pivot.wtk.media.Image;
import org.apache.pivot.wtk.skin.ComponentSkin;
import org.apache.pivot.wtk.skin.ContainerSkin;
@@ -97,6 +97,11 @@ public class TerraSpinnerSkin extends Co
boolean circular = spinner.isCircular();
int selectedIndex = spinner.getSelectedIndex();
int count = spinner.getSpinnerData().getLength();
+ if (count < 1) {
+ // empty spinner
+ stop();
+ return ;
+ }
if (direction > 0) {
if (selectedIndex < count - 1) {
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/CalendarButton.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/CalendarButton.java?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/CalendarButton.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/CalendarButton.java Tue Aug 7 16:17:45 2012
@@ -433,9 +433,19 @@ public class CalendarButton extends Butt
@Override
public void clear() {
+ super.clear(); // for better consistency with superclass
+
if (selectedDateKey != null) {
setSelectedDate((CalendarDate)null);
}
+
+ }
+
+ /**
+ * Clears the selection.
+ */
+ public void clearSelection() {
+ setSelectedDate((CalendarDate)null);
}
/**
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/ListButton.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/ListButton.java?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/ListButton.java Tue Aug 7 16:17:45 2012
@@ -772,6 +772,13 @@ public class ListButton extends Button {
}
/**
+ * Clears the selection.
+ */
+ public void clearSelection() {
+ setSelectedItem(null);
+ }
+
+ /**
* Returns the list button listener list.
*/
public ListenerList<ListButtonListener> getListButtonListeners() {
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Spinner.java Tue Aug 7 16:17:45 2012
@@ -679,12 +679,23 @@ public class Spinner extends Container {
@Override
public void clear() {
+ if (spinnerDataKey != null) {
+ setSpinnerData(new ArrayList<Object>());
+ }
+
if (selectedItemKey != null) {
setSelectedItem(null);
}
}
/**
+ * Clears the selection.
+ */
+ public void clearSelection() {
+ setSelectedItem(null);
+ }
+
+ /**
* Gets the bounding area of the spinner content (the area in which the
* item renderer will render the content).
*
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TreeView.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TreeView.java?rev=1370337&r1=1370336&r2=1370337&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TreeView.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/TreeView.java Tue Aug 7 16:17:45 2012
@@ -897,6 +897,9 @@ public class TreeView extends Component
private TreeViewSelectionListenerList treeViewSelectionListeners =
new TreeViewSelectionListenerList();
+ // other properties
+ private String treeDataKey = null;
+
private static final NodeRenderer DEFAULT_NODE_RENDERER = new TreeViewNodeRenderer();
private static final Comparator<Path> PATH_COMPARATOR = new PathComparator();
@@ -1326,7 +1329,30 @@ public class TreeView extends Component
return (index >= 0);
}
+ public String getTreeDataKey() {
+ return treeDataKey;
+ }
+
+ public void setTreeDataKey(String treeDataKey) {
+ String previousTreeDataKey = this.treeDataKey;
+
+ if (previousTreeDataKey != treeDataKey) {
+ this.treeDataKey = treeDataKey;
+ // treeViewBindingListeners.treeDataKeyChanged(this, previousTreeDataKey); // future use
+ }
+ }
+
+ @Override
+ public void clear() {
+ if (treeDataKey != null) {
+ setTreeData(new ArrayList<Object>());
+ }
+
+ clearSelection();
+ }
+
/**
+ * Clears the selection.
*/
public void clearSelection() {
if (selectedPaths.getLength() > 0) {