Author: smartini
Date: Wed May 18 21:46:51 2011
New Revision: 1124443
URL: http://svn.apache.org/viewvc?rev=1124443&view=rev
Log:
PIVOT-737 (the new fix and some tests for multiple selection)
Added:
pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_list.bxml
pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_table.bxml
pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_tree.bxml
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
Added: pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_list.bxml
URL:
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_list.bxml?rev=1124443&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_list.bxml
(added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_list.bxml
Wed May 18 21:46:51 2011
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="Multiple Selection on Lists" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:collections="org.apache.pivot.collections"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk">
+ <windowStateListeners>
+ function windowOpened(window) {
+ dataListView.requestFocus();
+ }
+ </windowStateListeners>
+
+ <TablePane styles="{horizontalSpacing:8}">
+ <columns>
+ <TablePane.Column width="1*"/>
+ <TablePane.Column width="1*"/>
+ </columns>
+
+ <TablePane.Row height="1*">
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill">
+ <ListView bxml:id="dataListView" selectMode="multi">
+ <listData>
+ <content:NumericSpinnerData lowerBound="0"
upperBound="30" increment="1"/>
+ </listData>
+
+ <listViewSelectionListeners>
+ importPackage(org.apache.pivot.collections);
+ function selectedRangesChanged(viewComponent,
previousSelectedElements) {
+ selectionListView.listData = new
ArrayList(viewComponent.selectedRanges);
+ }
+ </listViewSelectionListeners>
+ </ListView>
+ </ScrollPane>
+ </Border>
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill">
+ <ListView bxml:id="selectionListView" selectMode="none"/>
+ </ScrollPane>
+ </Border>
+ </TablePane.Row>
+ </TablePane>
+</Window>
Added:
pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_table.bxml
URL:
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_table.bxml?rev=1124443&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_table.bxml
(added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_table.bxml
Wed May 18 21:46:51 2011
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="Multiple Selection on Tables" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:collections="org.apache.pivot.collections"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk">
+ <windowStateListeners
+>
+ function windowOpened(window) {
+ dataTableView.requestFocus();
+ }
+ </windowStateListeners>
+
+ <TablePane styles="{horizontalSpacing:8}">
+ <columns>
+ <TablePane.Column width="1*"/>
+ <TablePane.Column width="1*"/>
+ </columns>
+
+ <TablePane.Row height="1*">
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
+ <TableView bxml:id="dataTableView"
selectMode="multi">
+ <columns>
+ <TableView.Column name="i"
width="75"/>
+ <TableView.Column name="a"
width="75"/>
+ <TableView.Column name="b"
width="75"/>
+ <TableView.Column name="c"
width="75"/>
+ <TableView.Column name="d"
width="1*"/>
+ </columns>
+ <componentListeners>
+ <![CDATA[
+
importClass(org.apache.pivot.collections.ArrayList);
+
importClass(org.apache.pivot.collections.HashMap);
+
+ function
parentChanged(component, previousParent) {
+ if (component.getParent()
!= null) {
+ var tableData = new
ArrayList();
+
+ for (var i = 0; i < 20;
i++) {
+ var row = new
HashMap();
+ row.put("i", new
String(i));
+ row.put("a", new
String(Math.floor(Math.random() * 100)));
+ row.put("b", new
String(Math.floor(Math.random() * 1000)));
+ row.put("c", new
String(Math.floor(Math.random() * 10000)));
+ tableData.add(row);
+ }
+
+
component.setTableData(tableData);
+ }
+ }
+
+ function selectedRangesChanged(viewComponent,
previousSelectedElements) {
+ selectionListView.listData = new
ArrayList(viewComponent.selectedRanges);
+ }
+ ]]>
+ </componentListeners>
+
+ <tableViewSelectionListeners>
+ importPackage(org.apache.pivot.collections);
+ function selectedRangesChanged(viewComponent,
previousSelectedElements) {
+ selectionListView.listData = new
ArrayList(viewComponent.selectedRanges);
+ }
+ </tableViewSelectionListeners>
+ </TableView>
+ </ScrollPane>
+ </Border>
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill">
+ <ListView bxml:id="selectionListView" selectMode="none"/>
+ </ScrollPane>
+ </Border>
+ </TablePane.Row>
+ </TablePane>
+</Window>
Added: pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_tree.bxml
URL:
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_tree.bxml?rev=1124443&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_tree.bxml
(added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/multiple_selection_tree.bxml
Wed May 18 21:46:51 2011
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="Multiple Selection on Trees" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:collections="org.apache.pivot.collections"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk"
+>
+ <windowStateListeners>
+ function windowOpened(window) {
+ dataTreeView.requestFocus();
+ }
+ </windowStateListeners>
+
+ <TablePane styles="{horizontalSpacing:8}">
+ <columns>
+ <TablePane.Column width="1*"/>
+ <TablePane.Column width="1*"/>
+ </columns>
+
+ <TablePane.Row height="1*">
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
+ <TreeView bxml:id="dataTreeView" selectMode="multi">
+ <nodeRenderer>
+ <content:TreeViewNodeRenderer showIcon="true"/>
+ </nodeRenderer>
+ <treeData>
+ <content:TreeBranch>
+ <content:TreeBranch text="Activity">
+ <content:TreeBranch text="Games">
+ <content:TreeNode text="Foosball"/>
+ <content:TreeNode text="A very long
game name that just serves to show how a wide tree node behaves"/>
+ <content:TreeNode text="Ping Pong"/>
+ <content:TreeNode text="Air Hockey"/>
+ </content:TreeBranch>
+ <content:TreeBranch text="Sports">
+ <content:TreeNode text="Baseball"/>
+ <content:TreeNode text="Basketball"/>
+ <content:TreeNode text="Football"/>
+ <content:TreeNode text="Ice Hockey"/>
+ <content:TreeNode text="Soccer"/>
+ <content:TreeNode text="Softball"/>
+ </content:TreeBranch>
+ <content:TreeNode text="Camping"/>
+ <content:TreeNode text="Skiing"/>
+ </content:TreeBranch>
+ <content:TreeBranch text="Occasion">
+ <content:TreeBranch text="Holidays">
+ <content:TreeNode text="Christmas"/>
+ <content:TreeNode text="Independence
Day"/>
+ <content:TreeNode text="Labor Day"/>
+ <content:TreeNode text="New Year's
Day"/>
+ <content:TreeNode text="President's
Day"/>
+ <content:TreeNode text="Thanksgiving"/>
+ <content:TreeNode text="Valentine's
Day"/>
+ <content:TreeNode text="Veteran's
Day"/>
+ </content:TreeBranch>
+ <content:TreeNode text="Anniversary"/>
+ <content:TreeNode text="Birthday"/>
+ <content:TreeNode text="Wedding"/>
+ </content:TreeBranch>
+ <content:TreeBranch text="Location">
+ <content:TreeNode text="Africa"/>
+ <content:TreeNode text="Antarctica"/>
+ <content:TreeNode text="Asia"/>
+ <content:TreeNode text="Australia"/>
+ <content:TreeNode text="Europe"/>
+ <content:TreeNode text="North America"/>
+ <content:TreeBranch text="South America">
+ <content:TreeNode text="Peru"/>
+ </content:TreeBranch>
+ </content:TreeBranch>
+ </content:TreeBranch>
+ </treeData>
+
+ <treeViewSelectionListeners>
+ importPackage(org.apache.pivot.collections);
+ function selectedPathsChanged(viewComponent,
previousSelectedElements) {
+ selectionListView.listData = new
ArrayList(viewComponent.selectedPaths);
+ }
+ </treeViewSelectionListeners>
+ </TreeView>
+ </ScrollPane>
+ </Border>
+ <Border styles="{color:10}">
+ <ScrollPane horizontalScrollBarPolicy="fill">
+ <ListView bxml:id="selectionListView" selectMode="none"/>
+ </ScrollPane>
+ </Border>
+ </TablePane.Row>
+ </TablePane>
+</Window>
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=1124443&r1=1124442&r2=1124443&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
Wed May 18 21:46:51 2011
@@ -33,10 +33,7 @@ import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.GraphicsUtilities;
import org.apache.pivot.wtk.Insets;
import org.apache.pivot.wtk.Keyboard;
-import org.apache.pivot.wtk.Keyboard.KeyCode;
-import org.apache.pivot.wtk.Keyboard.Modifier;
import org.apache.pivot.wtk.ListView;
-import org.apache.pivot.wtk.ListView.SelectMode;
import org.apache.pivot.wtk.ListViewItemListener;
import org.apache.pivot.wtk.ListViewItemStateListener;
import org.apache.pivot.wtk.ListViewListener;
@@ -45,6 +42,9 @@ import org.apache.pivot.wtk.Mouse;
import org.apache.pivot.wtk.Platform;
import org.apache.pivot.wtk.Span;
import org.apache.pivot.wtk.Theme;
+import org.apache.pivot.wtk.Keyboard.KeyCode;
+import org.apache.pivot.wtk.Keyboard.Modifier;
+import org.apache.pivot.wtk.ListView.SelectMode;
import org.apache.pivot.wtk.skin.ComponentSkin;
/**
@@ -849,12 +849,7 @@ public class TerraListViewSkin extends C
|| !getCheckboxBounds(itemIndex).contains(x, y)) {
ListView.SelectMode selectMode = listView.getSelectMode();
- if (button == Mouse.Button.RIGHT) {
- if (selectMode != ListView.SelectMode.NONE
- && !listView.isItemSelected(itemIndex)) {
- listView.setSelectedIndex(itemIndex);
- }
- } else {
+ if (button == Mouse.Button.LEFT) {
Keyboard.Modifier commandModifier =
Platform.getCommandModifier();
if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java?rev=1124443&r1=1124442&r2=1124443&view=diff
==============================================================================
---
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
(original)
+++
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
Wed May 18 21:46:51 2011
@@ -32,20 +32,20 @@ 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.Keyboard.Modifier;
import org.apache.pivot.wtk.Mouse;
import org.apache.pivot.wtk.Orientation;
import org.apache.pivot.wtk.Platform;
import org.apache.pivot.wtk.SortDirection;
import org.apache.pivot.wtk.Span;
import org.apache.pivot.wtk.TableView;
-import org.apache.pivot.wtk.TableView.SelectMode;
import org.apache.pivot.wtk.TableViewColumnListener;
import org.apache.pivot.wtk.TableViewListener;
import org.apache.pivot.wtk.TableViewRowListener;
import org.apache.pivot.wtk.TableViewSelectionListener;
import org.apache.pivot.wtk.Theme;
+import org.apache.pivot.wtk.Keyboard.KeyCode;
+import org.apache.pivot.wtk.Keyboard.Modifier;
+import org.apache.pivot.wtk.TableView.SelectMode;
import org.apache.pivot.wtk.skin.ComponentSkin;
/**
@@ -1188,12 +1188,7 @@ public class TerraTableViewSkin extends
&& !tableView.isRowDisabled(rowIndex)) {
TableView.SelectMode selectMode = tableView.getSelectMode();
- if (button == Mouse.Button.RIGHT) {
- if (selectMode != TableView.SelectMode.NONE
- && !tableView.isRowSelected(rowIndex)) {
- tableView.setSelectedIndex(rowIndex);
- }
- } else {
+ if (button == Mouse.Button.LEFT) {
Keyboard.Modifier commandModifier =
Platform.getCommandModifier();
if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java?rev=1124443&r1=1124442&r2=1124443&view=diff
==============================================================================
---
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
(original)
+++
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
Wed May 18 21:46:51 2011
@@ -390,7 +390,7 @@ public class TerraTreeViewSkin extends C
*/
@SuppressWarnings("unchecked")
public void loadChildren() {
- if (children == null || children.isEmpty()) {
+ if (children == null) {
List<Object> data = (List<Object>)this.data;
int count = data.getLength();
@@ -1630,12 +1630,7 @@ public class TerraTreeViewSkin extends C
if (!consumed) {
TreeView.SelectMode selectMode =
treeView.getSelectMode();
- if (button == Mouse.Button.RIGHT) {
- if (!treeView.isNodeSelected(path)
- && selectMode != TreeView.SelectMode.NONE) {
- treeView.setSelectedPath(path);
- }
- } else {
+ if (button == Mouse.Button.LEFT) {
Keyboard.Modifier commandModifier =
Platform.getCommandModifier();
if (Keyboard.isPressed(commandModifier)