pivot-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbr...@apache.org
Subject svn commit: r800874 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra: TerraListViewSkin.java TerraTableViewSkin.java
Date Tue, 04 Aug 2009 17:01:33 GMT
Author: gbrown
Date: Tue Aug  4 17:01:32 2009
New Revision: 800874

URL: http://svn.apache.org/viewvc?rev=800874&view=rev
Log:
Update mouse selection handling in ListView and TableView for PIVOT-182.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java?rev=800874&r1=800873&r2=800874&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java Tue
Aug  4 17:01:32 2009
@@ -582,43 +582,47 @@
                 && y < itemY + checkboxPadding.top + CHECKBOX.getHeight())) {
                 ListView.SelectMode selectMode = listView.getSelectMode();
 
-                if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
-                    && selectMode == ListView.SelectMode.MULTI) {
-                    // Select the range
-                    int startIndex = listView.getFirstSelectedIndex();
-                    int endIndex = listView.getLastSelectedIndex();
-                    Span selectedRange = (itemIndex > startIndex) ?
-                        new Span(startIndex, itemIndex) : new Span(itemIndex, endIndex);
-
-                    ArrayList<Span> selectedRanges = new ArrayList<Span>();
-                    Filter<?> disabledItemFilter = listView.getDisabledItemFilter();
-                    if (disabledItemFilter == null) {
-                        selectedRanges.add(selectedRange);
-                    } else {
-                        // TODO Split the range by the disabled indexes; for now,
-                        // just return
-                        return consumed;
-                    }
-
-                    listView.setSelectedRanges(selectedRanges);
-                } else if (Keyboard.isPressed(Keyboard.Modifier.CTRL)
-                    && selectMode == ListView.SelectMode.MULTI) {
-                    // Toggle the item's selection state
-                    if (listView.isItemSelected(itemIndex)) {
-                        listView.removeSelectedIndex(itemIndex);
-                    } else {
-                        listView.addSelectedIndex(itemIndex);
+                if (button == Mouse.Button.RIGHT) {
+                    if (!listView.isItemSelected(itemIndex)
+                        && selectMode != ListView.SelectMode.NONE) {
+                        listView.setSelectedIndex(itemIndex);
                     }
                 } else {
-                    if (selectMode != ListView.SelectMode.NONE) {
-                        if (listView.isItemSelected(itemIndex)
-                            && listView.isFocused()) {
-                            // Edit the item
-                            editIndex = itemIndex;
+                    if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
+                        && selectMode == ListView.SelectMode.MULTI) {
+                        Filter<?> disabledItemFilter = listView.getDisabledItemFilter();
+
+                        if (disabledItemFilter == null) {
+                            // Select the range
+                            ArrayList<Span> selectedRanges = new ArrayList<Span>();
+                            int startIndex = listView.getFirstSelectedIndex();
+                            int endIndex = listView.getLastSelectedIndex();
+
+                            Span selectedRange = (itemIndex > startIndex) ?
+                                new Span(startIndex, itemIndex) : new Span(itemIndex, endIndex);
+                            selectedRanges.add(selectedRange);
+
+                            listView.setSelectedRanges(selectedRanges);
+                        }
+                    } else if (Keyboard.isPressed(Keyboard.Modifier.CTRL)
+                        && selectMode == ListView.SelectMode.MULTI) {
+                        // Toggle the item's selection state
+                        if (listView.isItemSelected(itemIndex)) {
+                            listView.removeSelectedIndex(itemIndex);
+                        } else {
+                            listView.addSelectedIndex(itemIndex);
                         }
+                    } else {
+                        if (selectMode != ListView.SelectMode.NONE) {
+                            if (listView.isItemSelected(itemIndex)
+                                && listView.isFocused()) {
+                                // Edit the item
+                                editIndex = itemIndex;
+                            }
 
-                        // Select the item
-                        listView.setSelectedIndex(itemIndex);
+                            // Select the item
+                            listView.setSelectedIndex(itemIndex);
+                        }
                     }
                 }
             }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java?rev=800874&r1=800873&r2=800874&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
(original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
Tue Aug  4 17:01:32 2009
@@ -819,43 +819,47 @@
             && !tableView.isRowDisabled(rowIndex)) {
             TableView.SelectMode selectMode = tableView.getSelectMode();
 
-            if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
-                && selectMode == TableView.SelectMode.MULTI) {
-                // Select the range
-                int startIndex = tableView.getFirstSelectedIndex();
-                int endIndex = tableView.getLastSelectedIndex();
-                Span selectedRange = (rowIndex > startIndex) ?
-                    new Span(startIndex, rowIndex) : new Span(rowIndex, endIndex);
-
-                ArrayList<Span> selectedRanges = new ArrayList<Span>();
-                Filter<?> disabledRowFilter = tableView.getDisabledRowFilter();
-                if (disabledRowFilter == null) {
-                    selectedRanges.add(selectedRange);
-                } else {
-                    // TODO Split the range by the disabled indexes; for now,
-                    // just return
-                    return consumed;
-                }
-
-                tableView.setSelectedRanges(selectedRanges);
-            } else if (Keyboard.isPressed(Keyboard.Modifier.CTRL)
-                && selectMode == TableView.SelectMode.MULTI) {
-                // Toggle the item's selection state
-                if (tableView.isRowSelected(rowIndex)) {
-                    tableView.removeSelectedIndex(rowIndex);
-                } else {
-                    tableView.addSelectedIndex(rowIndex);
+            if (button == Mouse.Button.RIGHT) {
+                if (!tableView.isRowSelected(rowIndex)
+                    && selectMode != TableView.SelectMode.NONE) {
+                    tableView.setSelectedIndex(rowIndex);
                 }
             } else {
-                if (selectMode != TableView.SelectMode.NONE) {
-                    if (tableView.isRowSelected(rowIndex)
-                        && tableView.isFocused()) {
-                        // Edit the row
-                        editIndex = rowIndex;
+                if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)
+                    && selectMode == TableView.SelectMode.MULTI) {
+                    Filter<?> disabledRowFilter = tableView.getDisabledRowFilter();
+
+                    if (disabledRowFilter == null) {
+                        // Select the range
+                        int startIndex = tableView.getFirstSelectedIndex();
+                        int endIndex = tableView.getLastSelectedIndex();
+                        Span selectedRange = (rowIndex > startIndex) ?
+                            new Span(startIndex, rowIndex) : new Span(rowIndex, endIndex);
+
+                        ArrayList<Span> selectedRanges = new ArrayList<Span>();
+                        selectedRanges.add(selectedRange);
+
+                        tableView.setSelectedRanges(selectedRanges);
+                    }
+                } else if (Keyboard.isPressed(Keyboard.Modifier.CTRL)
+                    && selectMode == TableView.SelectMode.MULTI) {
+                    // Toggle the item's selection state
+                    if (tableView.isRowSelected(rowIndex)) {
+                        tableView.removeSelectedIndex(rowIndex);
+                    } else {
+                        tableView.addSelectedIndex(rowIndex);
                     }
+                } else {
+                    if (selectMode != TableView.SelectMode.NONE) {
+                        if (tableView.isRowSelected(rowIndex)
+                            && tableView.isFocused()) {
+                            // Edit the row
+                            editIndex = rowIndex;
+                        }
 
-                    // Select the row
-                    tableView.setSelectedIndex(rowIndex);
+                        // Select the row
+                        tableView.setSelectedIndex(rowIndex);
+                    }
                 }
             }
         }



Mime
View raw message