harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r440748 [23/25] - in /incubator/harmony/enhanced/classlib/trunk/modules: accessibility/src/main/java/javax/accessibility/ awt/ awt/make/ awt/src/main/java/common/java/awt/ awt/src/main/java/common/java/awt/datatransfer/ awt/src/main/java/co...
Date Wed, 06 Sep 2006 16:06:30 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListKeyboardActions.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListKeyboardActions.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListKeyboardActions.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListKeyboardActions.java Wed Sep  6 09:06:15 2006
@@ -25,6 +25,7 @@
 import java.awt.event.ActionEvent;
 
 import javax.swing.AbstractAction;
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.JComponent;
 import javax.swing.JList;
 import javax.swing.TransferHandler;
@@ -47,6 +48,23 @@
         }
     };
 
+    private static AbstractAction selectPreviousRowChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int previousIndex = getPreviousRow(list);
+            if (previousIndex == -1) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(previousIndex);
+            list.ensureIndexIsVisible(previousIndex);
+        }
+    };
+
     private static AbstractAction selectPreviousRowExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -57,7 +75,7 @@
             }
 
             list.setValueIsAdjusting(true);
-            list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+            list.clearSelection();
             list.addSelectionInterval(list.getAnchorSelectionIndex(), previousIndex);
             list.setValueIsAdjusting(false);
             list.ensureIndexIsVisible(previousIndex);
@@ -77,6 +95,23 @@
         }
     };
 
+    private static AbstractAction selectNextRowChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int nextIndex = getNextRow(list);
+            if (nextIndex == -1) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(nextIndex);
+            list.ensureIndexIsVisible(nextIndex);
+        }
+    };
+
     private static AbstractAction selectNextRowExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -86,7 +121,7 @@
             }
 
             list.setValueIsAdjusting(true);
-            list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+            list.clearSelection();
             list.addSelectionInterval(list.getAnchorSelectionIndex(), nextIndex);
             list.setValueIsAdjusting(false);
             list.ensureIndexIsVisible(nextIndex);
@@ -106,6 +141,23 @@
         }
     };
 
+    private static AbstractAction selectPreviousColumnChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int previousIndex = getPreviousColumn(list);
+            if (previousIndex == -1) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(previousIndex);
+            list.ensureIndexIsVisible(previousIndex);
+        }
+    };
+
     private static AbstractAction selectPreviousColumnExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -116,7 +168,7 @@
             }
 
             list.setValueIsAdjusting(true);
-            list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+            list.clearSelection();
             list.addSelectionInterval(list.getAnchorSelectionIndex(), previousIndex);
             list.setValueIsAdjusting(false);
             list.ensureIndexIsVisible(previousIndex);
@@ -137,6 +189,23 @@
         }
     };
 
+    private static AbstractAction selectNextColumnChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int nextIndex = getNextColumn(list);
+            if (nextIndex == -1) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(nextIndex);
+            list.ensureIndexIsVisible(nextIndex);
+        }
+    };
+
     private static AbstractAction selectNextColumnExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -147,7 +216,7 @@
             }
 
             list.setValueIsAdjusting(true);
-            list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+            list.clearSelection();
             list.addSelectionInterval(list.getAnchorSelectionIndex(), nextIndex);
             list.setValueIsAdjusting(false);
             list.ensureIndexIsVisible(nextIndex);
@@ -166,6 +235,21 @@
         }
     };
 
+    private static AbstractAction selectFirstRowChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (list.getModel().getSize() == 0) {
+                return;
+            }
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(0);
+            list.ensureIndexIsVisible(0);
+        }
+    };
+
     private static AbstractAction selectFirstRowExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -176,7 +260,7 @@
             int beginIndex = list.getAnchorSelectionIndex();
             if (beginIndex != -1) {
                 list.setValueIsAdjusting(true);
-                list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+                list.clearSelection();
                 list.addSelectionInterval(beginIndex, 0);
                 list.setValueIsAdjusting(false);
             }
@@ -198,6 +282,22 @@
         }
     };
 
+    private static AbstractAction selectLastRowChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (list.getModel().getSize() == 0) {
+                return;
+            }
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int lastIndex = list.getModel().getSize() - 1;
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(lastIndex);
+            list.ensureIndexIsVisible(lastIndex);
+        }
+    };
+
     private static AbstractAction selectLastRowExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -209,7 +309,7 @@
             int beginIndex = list.getAnchorSelectionIndex();
             if (beginIndex != -1) {
                 list.setValueIsAdjusting(true);
-                list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+                list.clearSelection();
                 list.addSelectionInterval(beginIndex, lastIndex);
                 list.setValueIsAdjusting(false);
             }
@@ -232,6 +332,23 @@
         }
     };
 
+    private static AbstractAction scrollUpChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int upIndex = getScrollUpIndex(list);
+            if (upIndex == -1) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(upIndex);
+            list.ensureIndexIsVisible(upIndex);
+        }
+    };
+
     private static AbstractAction scrollUpExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -244,7 +361,7 @@
             int beginIndex = list.getAnchorSelectionIndex();
             if (beginIndex != -1) {
                 list.setValueIsAdjusting(true);
-                list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+                list.clearSelection();
                 list.addSelectionInterval(beginIndex, upIndex);
                 list.setValueIsAdjusting(false);
             }
@@ -267,6 +384,23 @@
         }
     };
 
+    private static AbstractAction scrollDownChangeLeadAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            if (!(list.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                return;
+            }
+
+            int downIndex = getScrollDownIndex(list);
+            if (downIndex == -1) {
+                return;
+            }
+
+            ((DefaultListSelectionModel)list.getSelectionModel()).moveLeadSelectionIndex(downIndex);
+            list.ensureIndexIsVisible(downIndex);
+        }
+    };
+
     private static AbstractAction scrollDownExtendSelectionAction = new AbstractAction() {
         public void actionPerformed(final ActionEvent e) {
             JList list = (JList)e.getSource();
@@ -279,7 +413,7 @@
             int beginIndex = list.getAnchorSelectionIndex();
             if (beginIndex != -1) {
                 list.setValueIsAdjusting(true);
-                list.removeSelectionInterval(list.getAnchorSelectionIndex(), list.getLeadSelectionIndex());
+                list.clearSelection();
                 list.addSelectionInterval(beginIndex, downIndex);
                 list.setValueIsAdjusting(false);
             }
@@ -310,6 +444,65 @@
         }
     };
 
+    private static AbstractAction addToSelectionAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+
+            int addIndex = list.getLeadSelectionIndex();
+            if (addIndex == -1) {
+                return;
+            }
+
+            list.addSelectionInterval(addIndex, addIndex);
+        }
+    };
+
+    private static AbstractAction toggleAndAnchorAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+
+            int toggleIndex = list.getLeadSelectionIndex();
+            if (toggleIndex == -1) {
+                return;
+            }
+
+            if (list.isSelectedIndex(toggleIndex)) {
+                list.removeSelectionInterval(toggleIndex, toggleIndex);
+            } else {
+                list.addSelectionInterval(toggleIndex, toggleIndex);
+            }
+            list.getSelectionModel().setAnchorSelectionIndex(toggleIndex);
+        }
+    };
+
+    private static AbstractAction moveSelectionToAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+
+            int moveIndex = list.getLeadSelectionIndex();
+            if (moveIndex == -1) {
+                return;
+            }
+
+            list.setSelectedIndex(moveIndex);
+        }
+    };
+
+    private static AbstractAction extendToAction = new AbstractAction() {
+        public void actionPerformed(final ActionEvent e) {
+            JList list = (JList)e.getSource();
+            int extendIndex = list.getLeadSelectionIndex();
+            if (extendIndex == -1) {
+                return;
+            }
+
+            list.setValueIsAdjusting(true);
+            list.clearSelection();
+            list.addSelectionInterval(list.getAnchorSelectionIndex(), extendIndex);
+            list.setValueIsAdjusting(false);
+        }
+    };
+
 
     public static void installKeyboardActions(final JList list) {
         Utilities.installKeyboardActions(list, JComponent.WHEN_FOCUSED, "List.focusInputMap", "List.focusInputMap.RightToLeft");
@@ -319,6 +512,11 @@
         list.getActionMap().put("selectPreviousRowExtendSelection", selectPreviousRowExtendSelectionAction);
         list.getActionMap().put("selectNextRowExtendSelection", selectNextRowExtendSelectionAction);
 
+        list.getActionMap().put("selectPreviousRowChangeLead", selectPreviousRowChangeLeadAction);
+        list.getActionMap().put("selectNextRowChangeLead", selectNextRowChangeLeadAction);
+        list.getActionMap().put("selectPreviousColumnChangeLead", selectPreviousColumnChangeLeadAction);
+        list.getActionMap().put("selectNextColumnChangeLead", selectNextColumnChangeLeadAction);
+
         list.getActionMap().put("selectPreviousColumn", selectPreviousColumnAction);
         list.getActionMap().put("selectNextColumn", selectNextColumnAction);
         list.getActionMap().put("selectPreviousColumnExtendSelection", selectPreviousColumnExtendSelectionAction);
@@ -329,14 +527,25 @@
         list.getActionMap().put("selectLastRow", selectLastRowAction);
         list.getActionMap().put("selectLastRowExtendSelection", selectLastRowExtendSelectionAction);
 
+        list.getActionMap().put("selectLastRowChangeLead", selectLastRowChangeLeadAction);
+        list.getActionMap().put("selectFirstRowChangeLead", selectFirstRowChangeLeadAction);
+
         list.getActionMap().put("scrollUp", scrollUpAction);
         list.getActionMap().put("scrollUpExtendSelection", scrollUpExtendSelectionAction);
         list.getActionMap().put("scrollDown", scrollDownAction);
         list.getActionMap().put("scrollDownExtendSelection", scrollDownExtendSelectionAction);
 
+        list.getActionMap().put("scrollUpChangeLead", scrollUpChangeLeadAction);
+        list.getActionMap().put("scrollDownChangeLead", scrollDownChangeLeadAction);
+
         list.getActionMap().put("selectAll", selectAllAction);
         list.getActionMap().put("clearSelection", clearSelectionAction);
 
+        list.getActionMap().put("addToSelection", addToSelectionAction);
+        list.getActionMap().put("toggleAndAnchor", toggleAndAnchorAction);
+        list.getActionMap().put("moveSelectionTo", moveSelectionToAction);
+        list.getActionMap().put("extendTo", extendToAction);
+
         list.getActionMap().put("copy", TransferHandler.getCopyAction());
         list.getActionMap().put("paste", TransferHandler.getPasteAction());
         list.getActionMap().put("cut", TransferHandler.getCutAction());
@@ -422,8 +631,6 @@
             } else {
                 return list.getModel().getSize() - 1;
             }
-        } else if (list.getLayoutOrientation() == JList.VERTICAL_WRAP && selectedRow < strategy.getRowCount() - 1 && strategy.getIndex(selectedRow + 1, selectedColumn) < list.getModel().getSize()) {
-            return strategy.getIndex(selectedRow + 1, selectedColumn);
         }
 
         return -1;
@@ -448,8 +655,6 @@
         int selectedColumn = strategy.getColumn(currectSelection);
         if (selectedColumn > 0) {
             return strategy.getIndex(selectedRow, selectedColumn - 1);
-        } else if (list.getLayoutOrientation() == JList.VERTICAL_WRAP && selectedRow > 0) {
-            return strategy.getIndex(selectedRow - 1, selectedColumn);
         }
 
         return -1;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicListUI.java Wed Sep  6 09:06:15 2006
@@ -327,6 +327,7 @@
             if (nextIndex != -1) {
                 searchTimer.stop();
                 list.setSelectedIndex(nextIndex);
+                list.ensureIndexIsVisible(nextIndex);
                 searchTimer.restart();
             } else {
                 resetSearch();
@@ -586,6 +587,7 @@
 
         if (currectSelection < list.getModel().getSize() - 1 && list.getModel().getSize() > 0) {
             list.setSelectedIndex(currectSelection + 1);
+            list.ensureIndexIsVisible(currectSelection + 1);
         }
     }
 
@@ -593,6 +595,7 @@
         int currectSelection = list.getMinSelectionIndex();
         if (currectSelection > 0) {
             list.setSelectedIndex(currectSelection - 1);
+            list.ensureIndexIsVisible(currectSelection - 1);
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicLookAndFeel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicLookAndFeel.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicLookAndFeel.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicLookAndFeel.java Wed Sep  6 09:06:15 2006
@@ -78,10 +78,14 @@
                                                    "CUT", "cut", "UP", "selectPrevious",
                                                    "KP_UP", "selectPrevious",
                                                    "shift UP", "selectPreviousExtendSelection",
+                                                   "shift ctrl UP", "selectPreviousExtendSelection",
                                                    "shift KP_UP", "selectPreviousExtendSelection",
+                                                   "shift ctrl KP_UP", "selectPreviousExtendSelection",
                                                    "DOWN", "selectNext", "KP_DOWN", "selectNext",
                                                    "shift DOWN", "selectNextExtendSelection",
+                                                   "shift ctrl DOWN", "selectNextExtendSelection",
                                                    "shift KP_DOWN", "selectNextExtendSelection",
+                                                   "shift ctrl KP_DOWN", "selectNextExtendSelection",
                                                    "RIGHT", "selectChild", "KP_RIGHT", "selectChild",
                                                    "LEFT", "selectParent", "KP_LEFT", "selectParent",
                                                    "PAGE_UP", "scrollUpChangeSelection",
@@ -90,8 +94,10 @@
                                                    "shift PAGE_DOWN", "scrollDownExtendSelection",
                                                    "HOME", "selectFirst",
                                                    "shift HOME", "selectFirstExtendSelection",
+                                                   "shift ctrl HOME", "selectFirstExtendSelection",
                                                    "END", "selectLast",
                                                    "shift END", "selectLastExtendSelection",
+                                                   "shift ctrl END", "selectLastExtendSelection",
                                                    "F2", "startEditing", "ctrl A", "selectAll",
                                                    "ctrl SLASH", "selectAll",
                                                    "ctrl BACK_SLASH", "clearSelection",
@@ -110,8 +116,10 @@
                                                    "ctrl LEFT", "scrollLeft", "ctrl KP_LEFT", "scrollLeft",
                                                    "ctrl RIGHT", "scrollRight",
                                                    "ctrl KP_RIGHT", "scrollRight",
-                                                   "SPACE", "toggleSelectionPreserveAnchor" };
-        Object[] scrollBarFocusInputMapRightToLeft = new Object[] {"RIGHT", "negativeUnitIncrement",
+                                                   "ADD", "expand", "SUBTRACT", "collapse",
+                                                   "SPACE", "toggleSelectionPreserveAnchor",
+                                                   "shift ctrl SPACE", "moveSelectionTo"};
+        Object[] scrollBarAncestorInputMapRightToLeft = new Object[] {"RIGHT", "negativeUnitIncrement",
                                                                    "KP_RIGHT", "negativeUnitIncrement",
                                                                    "LEFT", "positiveUnitIncrement",
                                                                    "KP_LEFT", "positiveUnitIncrement" };
@@ -143,11 +151,17 @@
                                                       "OptionPane.questionSound", "OptionPane.warningSound",
                                                       "PopupMenu.popupSound", "RadioButtonMenuItem.commandSound" };
         Object[] tableAncestorInputMapRightToLeft = new Object[] {"RIGHT", "selectPreviousColumn", "KP_RIGHT", "selectPreviousColumn",
+                                                                  "ctrl RIGHT", "selectPreviousColumnChangeLead", "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
                                                                   "LEFT", "selectNextColumn", "KP_LEFT", "selectNextColumn",
+                                                                  "ctrl LEFT", "selectNextColumnChangeLead", "ctrl KP_LEFT", "selectNextColumnChangeLead",
                                                                   "shift RIGHT", "selectPreviousColumnExtendSelection",
+                                                                  "shift ctrl RIGHT", "selectPreviousColumnExtendSelection",
                                                                   "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
+                                                                  "shift ctrl KP_RIGHT", "selectPreviousColumnExtendSelection",
                                                                   "shift LEFT", "selectNextColumnExtendSelection",
+                                                                  "shift ctrl LEFT", "selectNextColumnExtendSelection",
                                                                   "shift KP_LEFT", "selectNextColumnExtendSelection",
+                                                                  "shift ctrl KP_LEFT", "selectNextColumnExtendSelection",
                                                                   "ctrl PAGE_UP", "scrollRightChangeSelection",
                                                                   "ctrl PAGE_DOWN", "scrollLeftChangeSelection",
                                                                   "ctrl shift PAGE_UP", "scrollRightExtendSelection",
@@ -215,7 +229,7 @@
                                                          "KP_UP", "increment",
                                                          "DOWN", "decrement",
                                                          "KP_DOWN", "decrement" };
-        Object[] scrollBarFocusInputMap = new Object[] {"RIGHT", "positiveUnitIncrement",
+        Object[] scrollBarAncestorInputMap = new Object[] {"RIGHT", "positiveUnitIncrement",
                                                         "KP_RIGHT", "positiveUnitIncrement",
                                                         "DOWN", "positiveUnitIncrement",
                                                         "KP_DOWN", "positiveUnitIncrement",
@@ -227,24 +241,42 @@
                                                         "PAGE_UP", "negativeBlockIncrement",
                                                         "HOME", "minScroll",
                                                         "END", "maxScroll" };
+        Object[] rootPaneAncestorInputMap = new Object[] {"shift F10", "postPopup"};
         Object[] tableAncestorInputMap = new Object[] {"ctrl C", "copy", "ctrl V", "paste", "ctrl X", "cut",
                                                        "COPY", "copy", "PASTE", "paste",
                                                        "CUT", "cut", "RIGHT", "selectNextColumn",
+                                                       "ctrl RIGHT", "selectNextColumnChangeLead",
                                                        "KP_RIGHT", "selectNextColumn",
+                                                       "ctrl KP_RIGHT", "selectNextColumnChangeLead",
                                                        "LEFT", "selectPreviousColumn",
+                                                       "ctrl LEFT", "selectPreviousColumnChangeLead",
                                                        "KP_LEFT", "selectPreviousColumn",
+                                                       "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
                                                        "DOWN", "selectNextRow",
+                                                       "ctrl DOWN", "selectNextRowChangeLead",
                                                        "KP_DOWN", "selectNextRow",
+                                                       "ctrl KP_DOWN", "selectNextRowChangeLead",
                                                        "UP", "selectPreviousRow",
+                                                       "ctrl UP", "selectPreviousRowChangeLead",
                                                        "KP_UP", "selectPreviousRow",
+                                                       "ctrl KP_UP", "selectPreviousRowChangeLead",
                                                        "shift RIGHT", "selectNextColumnExtendSelection",
+                                                       "shift RIGHT", "selectNextColumnExtendSelection",
+                                                       "shift ctrl RIGHT", "selectNextColumnExtendSelection",
                                                        "shift KP_RIGHT", "selectNextColumnExtendSelection",
+                                                       "shift ctrl KP_RIGHT", "selectNextColumnExtendSelection",
                                                        "shift LEFT", "selectPreviousColumnExtendSelection",
+                                                       "shift ctrl LEFT", "selectPreviousColumnExtendSelection",
                                                        "shift KP_LEFT", "selectPreviousColumnExtendSelection",
+                                                       "shift ctrl KP_LEFT", "selectPreviousColumnExtendSelection",
                                                        "shift DOWN", "selectNextRowExtendSelection",
+                                                       "shift ctrl DOWN", "selectNextRowExtendSelection",
                                                        "shift KP_DOWN", "selectNextRowExtendSelection",
+                                                       "shift ctrl KP_DOWN", "selectNextRowExtendSelection",
                                                        "shift UP", "selectPreviousRowExtendSelection",
+                                                       "shift ctrl UP", "selectPreviousRowExtendSelection",
                                                        "shift KP_UP", "selectPreviousRowExtendSelection",
+                                                       "shift ctrl KP_UP", "selectPreviousRowExtendSelection",
                                                        "PAGE_UP", "scrollUpChangeSelection",
                                                        "PAGE_DOWN", "scrollDownChangeSelection",
                                                        "HOME", "selectFirstColumn",
@@ -265,15 +297,18 @@
                                                        "shift TAB", "selectPreviousColumnCell",
                                                        "ENTER", "selectNextRowCell",
                                                        "shift ENTER", "selectPreviousRowCell",
-                                                       "ctrl A", "selectAll",
-                                                       "ESCAPE", "cancel", "F2", "startEditing" };
+                                                       "ctrl A", "selectAll", "ctrl SLASH", "selectAll", "ctrl BACK_SLASH", "clearSelection",
+                                                       "ESCAPE", "cancel", "F2", "startEditing",
+                                                       "SPACE", "addToSelection", "ctrl SPACE", "toggleAndAnchor",
+                                                       "shift ctrl SPACE", "moveSelectionTo", "shift SPACE", "extendTo"};
         Object[] listFocusInputMapRightToLeft = new Object[] {"LEFT", "selectNextColumn", "KP_LEFT", "selectNextColumn",
-                                                              "shift LEFT", "selectNextColumnExtendSelection",
-                                                              "shift KP_LEFT", "selectNextColumnExtendSelection",
-                                                              "RIGHT", "selectPreviousColumn",
-                                                              "KP_RIGHT", "selectPreviousColumn",
-                                                              "shift RIGHT", "selectPreviousColumnExtendSelection",
-                                                              "shift KP_RIGHT", "selectPreviousColumnExtendSelection" };
+                                                              "ctrl LEFT", "selectNextColumnChangeLead", "ctrl KP_LEFT", "selectNextColumnChangeLead",
+                                                              "shift LEFT", "selectNextColumnExtendSelection", "shift ctrl LEFT", "selectNextColumnExtendSelection",
+                                                              "shift KP_LEFT", "selectNextColumnExtendSelection", "shift ctrl KP_LEFT", "selectNextColumnExtendSelection",
+                                                              "RIGHT", "selectPreviousColumn", "KP_RIGHT", "selectPreviousColumn",
+                                                              "ctrl RIGHT", "selectPreviousColumnChangeLead", "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
+                                                              "shift RIGHT", "selectPreviousColumnExtendSelection", "shift ctrl RIGHT", "selectPreviousColumnExtendSelection",
+                                                              "shift KP_RIGHT", "selectPreviousColumnExtendSelection", "shift ctrl KP_RIGHT", "selectPreviousColumnExtendSelection" };
         Object[] desktopAncestorInputMap = new Object[] {"ctrl F5", "restore", "ctrl F4", "close", "ctrl F7", "move",
                                                          "ctrl F8", "resize", "RIGHT", "right",
                                                          "KP_RIGHT", "right",
@@ -313,18 +348,30 @@
                                                    "ctrl X", "cut", "COPY", "copy",
                                                    "PASTE", "paste", "CUT", "cut", "UP", "selectPreviousRow",
                                                    "KP_UP", "selectPreviousRow", "shift UP", "selectPreviousRowExtendSelection",
-                                                   "shift KP_UP", "selectPreviousRowExtendSelection", "DOWN", "selectNextRow",
-                                                   "KP_DOWN", "selectNextRow", "shift DOWN", "selectNextRowExtendSelection",
-                                                   "shift KP_DOWN", "selectNextRowExtendSelection", "LEFT", "selectPreviousColumn",
-                                                   "KP_LEFT", "selectPreviousColumn", "shift LEFT", "selectPreviousColumnExtendSelection",
-                                                   "shift KP_LEFT", "selectPreviousColumnExtendSelection", "RIGHT", "selectNextColumn",
-                                                   "KP_RIGHT", "selectNextColumn", "shift RIGHT", "selectNextColumnExtendSelection",
-                                                   "shift KP_RIGHT", "selectNextColumnExtendSelection", "ctrl SPACE", "selectNextRowExtendSelection",
-                                                   "HOME", "selectFirstRow", "shift HOME", "selectFirstRowExtendSelection",
-                                                   "END", "selectLastRow", "shift END", "selectLastRowExtendSelection",
-                                                   "PAGE_UP", "scrollUp", "shift PAGE_UP", "scrollUpExtendSelection",
-                                                   "PAGE_DOWN", "scrollDown", "shift PAGE_DOWN", "scrollDownExtendSelection",
-                                                   "ctrl A", "selectAll", "ctrl SLASH", "selectAll", "ctrl BACK_SLASH", "clearSelection" };
+                                                   "shift ctrl UP", "selectPreviousRowExtendSelection", "shift KP_UP", "selectPreviousRowExtendSelection",
+                                                   "shift ctrl KP_UP", "selectPreviousRowExtendSelection", "DOWN", "selectNextRow",
+                                                   "ctrl DOWN", "selectNextRowChangeLead", "KP_DOWN", "selectNextRow",
+                                                   "ctrl KP_DOWN", "selectNextRowChangeLead", "shift DOWN", "selectNextRowExtendSelection",
+                                                   "shift ctrl DOWN", "selectNextRowExtendSelection", "shift KP_DOWN", "selectNextRowExtendSelection",
+                                                   "shift ctrl KP_DOWN", "selectNextRowExtendSelection", "LEFT", "selectPreviousColumn",
+                                                   "ctrl LEFT", "selectPreviousColumnChangeLead", "KP_LEFT", "selectPreviousColumn",
+                                                   "ctrl KP_LEFT", "selectPreviousColumnChangeLead", "shift LEFT", "selectPreviousColumnExtendSelection",
+                                                   "shift ctrl LEFT", "selectPreviousColumnExtendSelection", "shift KP_LEFT", "selectPreviousColumnExtendSelection",
+                                                   "shift ctrl KP_LEFT", "selectPreviousColumnExtendSelection", "RIGHT", "selectNextColumn",
+                                                   "ctrl RIGHT", "selectNextColumnChangeLead", "KP_RIGHT", "selectNextColumn",
+                                                   "ctrl KP_RIGHT", "selectNextColumnChangeLead", "shift RIGHT", "selectNextColumnExtendSelection",
+                                                   "shift ctrl RIGHT", "selectNextColumnExtendSelection", "shift KP_RIGHT", "selectNextColumnExtendSelection",
+                                                   "shift ctrl KP_RIGHT", "selectNextColumnExtendSelection", "ctrl SPACE", "selectNextRowExtendSelection",
+                                                   "HOME", "selectFirstRow", "ctrl HOME", "selectFirstRowChangeLead",
+                                                   "shift HOME", "selectFirstRowExtendSelection", "shift ctrl HOME", "selectFirstRowExtendSelection",
+                                                   "END", "selectLastRow", "ctrl END", "selectLastRowChangeLead",
+                                                   "shift END", "selectLastRowExtendSelection", "shift ctrl END", "selectLastRowExtendSelection",
+                                                   "PAGE_UP", "scrollUp", "ctrl PAGE_UP", "scrollUpChangeLead", "shift PAGE_UP", "scrollUpExtendSelection", "shift ctrl PAGE_UP", "scrollUpExtendSelection",
+                                                   "PAGE_DOWN", "scrollDown", "ctrl PAGE_DOWN", "scrollDownChangeLead", "shift PAGE_DOWN", "scrollDownExtendSelection", "shift ctrl PAGE_DOWN", "scrollDownExtendSelection",
+                                                   "ctrl A", "selectAll", "ctrl SLASH", "selectAll", "ctrl BACK_SLASH", "clearSelection",
+                                                   "ctrl UP", "selectPreviousRowChangeLead",
+                                                   "ctrl KP_UP", "selectPreviousRowChangeLead",
+                                                   "SPACE", "addToSelection", "ctrl SPACE", "toggleAndAnchor", "shift ctrl SPACE", "moveSelectionTo", "shift SPACE", "extendTo"};
         Object[] toolBarAncestorInputMap = new Object[] {"UP", "navigateUp", "KP_UP", "navigateUp",
                                                          "DOWN", "navigateDown", "KP_DOWN", "navigateDown",
                                                          "LEFT", "navigateLeft", "KP_LEFT", "navigateLeft",
@@ -473,8 +520,9 @@
                                       "RadioButtonMenuItem.font", lazyValueForFont("Dialog", Font.PLAIN, 12),
                                       "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
                                       "RootPane.defaultButtonWindowKeyBindings", new Object[] { "ENTER", "press", "released ENTER", "release", "ctrl ENTER", "press", "ctrl released ENTER", "release"},
-                                      "ScrollBar.focusInputMap", new UIDefaults.LazyInputMap(scrollBarFocusInputMap),
-                                      "ScrollBar.focusInputMap.RightToLeft",  new UIDefaults.LazyInputMap(scrollBarFocusInputMapRightToLeft),
+                                      "RootPane.ancestorInputMap", new UIDefaults.LazyInputMap(rootPaneAncestorInputMap),
+                                      "ScrollBar.ancestorInputMap", new UIDefaults.LazyInputMap(scrollBarAncestorInputMap),
+                                      "ScrollBar.ancestorInputMap.RightToLeft",  new UIDefaults.LazyInputMap(scrollBarAncestorInputMapRightToLeft),
                                       "ScrollBar.maximumThumbSize", new DimensionUIResource(4096, 4096),
                                       "ScrollBar.minimumThumbSize", new DimensionUIResource(8, 8),
                                       "ScrollBar.width", new Integer(16),

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicPanelUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicPanelUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicPanelUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicPanelUI.java Wed Sep  6 09:06:15 2006
@@ -69,8 +69,9 @@
      * Installs default properties for given panel
      */
     protected void installDefaults(final JPanel panel) {
-        LookAndFeel.installColors(panel, PROPERTY_PREFIX + "background",
-                                  PROPERTY_PREFIX + "foreground");
+        LookAndFeel.installColorsAndFont(panel, PROPERTY_PREFIX + "background",
+                                         PROPERTY_PREFIX + "foreground",
+                                         PROPERTY_PREFIX + "font");
         LookAndFeel.installBorder(panel, PROPERTY_PREFIX + "border");
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicProgressBarUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicProgressBarUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicProgressBarUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicProgressBarUI.java Wed Sep  6 09:06:15 2006
@@ -89,11 +89,11 @@
 
     private static final int NOTEXT_HEIGHT_ADDITION = 5;
     private static final int MIN_WIDTH = 10;
-
+    private static final int STRING_PAINTED_CELL_LENGTH = 1;
+    private static final int STRING_PAINTED_CELL_SPACING = 0;
+    
     private int cellLength;
     private int cellSpacing;
-    private int defCellLength;
-    private int defCellSpacing;
     private PropertyChangeListener propertyChangeListener;
     private Color selectionBackground;
     private Color selectionForeground;
@@ -170,11 +170,9 @@
         selectionBackground = UIManager.getColor("ProgressBar.selectionBackground");
         selectionForeground = UIManager.getColor("ProgressBar.selectionForeground");
 
-        defCellLength = UIManager.getInt("ProgressBar.cellLength");
-        defCellSpacing = UIManager.getInt("ProgressBar.cellSpacing");
-        cellLength = defCellLength;
-        cellSpacing = defCellSpacing;
-
+        cellLength = UIManager.getInt("ProgressBar.cellLength");
+        cellSpacing = UIManager.getInt("ProgressBar.cellSpacing");
+        
         cycleTime = UIManager.getInt("ProgressBar.cycleTime");
         repaintInterval = UIManager.getInt("ProgressBar.repaintInterval");
         maxAnimationIndex = cycleTime / repaintInterval;
@@ -233,11 +231,7 @@
     }
 
     protected int getCellLength() {
-        if (!progressBar.isStringPainted()) {
-            return cellLength;
-        } else {
-            return defCellLength;
-        }
+        return !progressBar.isStringPainted() ? cellLength : STRING_PAINTED_CELL_LENGTH;        
     }
 
     protected void setCellLength(final int cellLen) {
@@ -245,11 +239,7 @@
     }
 
     protected int getCellSpacing() {
-        if (progressBar.isStringPainted()) {
-            return defCellSpacing;
-        } else {
-            return cellSpacing;
-        }
+        return !progressBar.isStringPainted() ? cellSpacing : STRING_PAINTED_CELL_SPACING;
     }
 
     protected void setCellSpacing(final int cellSpace) {
@@ -257,11 +247,8 @@
     }
 
     protected int getAmountFull(final Insets b, final int width, final int height) {
-        if (!isVertical()) {
-            return (int)(width * progressBar.getPercentComplete());
-         } else {
-             return (int)(height * progressBar.getPercentComplete());
-         }
+        return isVertical() ? (int)(height * progressBar.getPercentComplete()) :
+                              (int)(width * progressBar.getPercentComplete());
     }
 
     protected Rectangle getBox(final Rectangle r) {
@@ -287,12 +274,27 @@
         int actualWidth = innerArea.width;
         int actualHeight = innerArea.height;
 
+        
         g.setColor(progressBar.getForeground());
         int amountFull = getAmountFull(insets, actualWidth, actualHeight);
         if (!isVertical()) {
-            g.fillRect(insets.left, insets.top, amountFull, actualHeight);
+            if (getCellSpacing() == 0) {
+                g.fillRect(insets.left, insets.top, amountFull, actualHeight);    
+            } else {
+                g.clipRect(insets.left, insets.top, amountFull, actualHeight);
+                for (int i = 0; i < amountFull; i += cellLength + cellSpacing) {
+                    g.fillRect(i, insets.top, cellLength, actualHeight);
+                }
+            }
         } else {
-            g.fillRect(insets.left, insets.top - amountFull + actualHeight, actualWidth, amountFull);
+            if (getCellSpacing() == 0) {
+                g.fillRect(insets.left, insets.top - amountFull + actualHeight, actualWidth, amountFull);
+            } else {
+                g.clipRect(insets.left, insets.top - amountFull + actualHeight, actualWidth, amountFull);
+                for (int i = 0; i < amountFull; i += cellLength + cellSpacing) {
+                    g.fillRect(insets.left, insets.top - i + actualHeight, actualWidth, cellLength);
+                }
+            }
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicRootPaneUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicRootPaneUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicRootPaneUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicRootPaneUI.java Wed Sep  6 09:06:15 2006
@@ -21,8 +21,10 @@
 
 package javax.swing.plaf.basic;
 
+import java.awt.Component;
+import java.awt.KeyboardFocusManager;
+import java.awt.Point;
 import java.awt.event.ActionEvent;
-
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
@@ -30,17 +32,18 @@
 import javax.swing.ActionMap;
 import javax.swing.InputMap;
 import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
 import javax.swing.JRootPane;
 import javax.swing.KeyStroke;
 import javax.swing.LookAndFeel;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
-
 import javax.swing.plaf.ActionMapUIResource;
-import javax.swing.plaf.ComponentInputMapUIResource;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.RootPaneUI;
 
+import org.apache.harmony.x.swing.Utilities;
+
 
 public class BasicRootPaneUI extends RootPaneUI
         implements PropertyChangeListener {
@@ -84,9 +87,7 @@
     protected void installKeyboardActions(final JRootPane root) {
         SwingUtilities.replaceUIActionMap(root, getActionMap(root));
 
-        SwingUtilities.replaceUIInputMap(root,
-                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
-                getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, root));
+        Utilities.installKeyboardActions(root, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, "RootPane.ancestorInputMap", "RootPane.ancestorInputMap.RightToLeft");
         if (root.getDefaultButton() != null) {
             loadDefaultButtonKeyBindings(root);
         }
@@ -94,8 +95,7 @@
 
     protected void uninstallKeyboardActions(final JRootPane root) {
         SwingUtilities.replaceUIActionMap(root, null);
-        SwingUtilities.replaceUIInputMap(root,
-                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+        Utilities.uninstallKeyboardActions(root, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
     }
 
     protected void installDefaults(final JRootPane root) {
@@ -176,24 +176,6 @@
     }
 
     /*
-     * Create InputMap and returns it.
-     */
-    private InputMap getInputMap(final int cond, final JRootPane root) {
-        // there is a separage InputMap for every JRootPane (because
-        // bindings are removed if defaultButton is set to null),
-        // but the bindings are the same
-        return createInputMap(cond, root);
-    }
-
-    /*
-     * Create a new instance of InputMap.
-     */
-    private InputMap createInputMap(final int cond, final JRootPane root) {
-        ComponentInputMapUIResource map = new ComponentInputMapUIResource(root);
-        return map;
-    }
-
-    /*
      * Create ActionMap if necessary, and return it.
      */
     private ActionMap getActionMap(final JRootPane root) {
@@ -209,6 +191,34 @@
 
         actionMap.put("press", new DefaultButtonAction(root, true));
         actionMap.put("release", new DefaultButtonAction(root, false));
+        actionMap.put("postPopup", new AbstractAction() {
+            public void actionPerformed(final ActionEvent e) {
+                JComponent focusOwner = getFocusOwner();
+                JPopupMenu menu = focusOwner.getComponentPopupMenu();
+                if (menu == null) {
+                    return;
+                }
+                Point location = focusOwner.getPopupLocation(null);
+                if (location == null) {
+                    location = Utilities.getMousePointerScreenLocation();
+                    SwingUtilities.convertPointFromScreen(location, focusOwner);
+                }
+
+                menu.show(focusOwner, location.x, location.y);
+            }
+
+            public boolean isEnabled() {
+                JComponent focusOwner = getFocusOwner();
+                return focusOwner != null
+                       && focusOwner.getComponentPopupMenu() != null;
+            }
+
+            private JComponent getFocusOwner() {
+                Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+                return focusOwner instanceof JComponent ? (JComponent)focusOwner : null;
+            }
+
+        });
 
         return actionMap;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicScrollBarUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicScrollBarUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicScrollBarUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicScrollBarUI.java Wed Sep  6 09:06:15 2006
@@ -376,7 +376,7 @@
     }
 
     protected void installKeyboardActions() {
-        Utilities.installKeyboardActions(scrollbar, JComponent.WHEN_FOCUSED, "ScrollBar.focusInputMap", "ScrollBar.focusInputMap.RightToLeft");
+        Utilities.installKeyboardActions(scrollbar, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, "ScrollBar.ancestorInputMap", "ScrollBar.ancestorInputMap.RightToLeft");
 
         scrollbar.getActionMap().put("positiveUnitIncrement", newPositiveUnitIncrementAction());
         scrollbar.getActionMap().put("positiveBlockIncrement", newPositiveBlockIncrementAction());

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSpinnerUI.java Wed Sep  6 09:06:15 2006
@@ -22,6 +22,7 @@
 import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
+import java.awt.Insets;
 import java.awt.LayoutManager;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -148,21 +149,27 @@
                     editor.setBounds(left, top, leftMargin - left, height - bottom - top);
                 }
                 if (nextButton != null) {
-                    nextButton.setBounds(leftMargin, 0, nextButton.getWidth(), height / 2);
+                    nextButton.setBounds(leftMargin, buttonInsets.top, 
+                                         nextButton.getWidth() - buttonInsets.right, height / 2 - buttonInsets.top);
                 }
                 if (previousButton != null) {
-                    previousButton.setBounds(leftMargin, height / 2, previousButton.getWidth(), height / 2);
+                    previousButton.setBounds(leftMargin, height / 2, previousButton.getWidth() - buttonInsets.right,
+                                             height / 2 - buttonInsets.bottom);
                 }
-            } else {
+            }  else {
                 if (editor != null) {
                     leftMargin = width - rightMargin;
                     editor.setBounds(rightMargin, top, leftMargin - right, height - bottom - top);
                 }
                 if (nextButton != null) {
-                    nextButton.setBounds(0, 0, nextButton.getWidth(), height / 2);
+                    nextButton.setBounds(buttonInsets.left, buttonInsets.top, 
+                                         nextButton.getWidth() - buttonInsets.left,
+                                         height / 2 - buttonInsets.top);
                 }
                 if (previousButton != null) {
-                    previousButton.setBounds(0, height / 2, previousButton.getWidth(), height / 2);
+                    previousButton.setBounds(buttonInsets.left, height / 2, 
+                                             previousButton.getWidth() - buttonInsets.left,
+                                             height / 2 - buttonInsets.bottom);
                 }
             }
         }
@@ -195,6 +202,7 @@
     private PropertyChangeListener changeListener;
     private ArrowButtonHandler buttonHandler = new ArrowButtonHandler();
     private Dimension buttonSize;
+    private Insets buttonInsets;
     private boolean paintEditorBorder;
 
     public static ComponentUI createUI(final JComponent c) {
@@ -246,6 +254,7 @@
 
         paintEditorBorder = UIManager.getBoolean("Spinner.editorBorderPainted");
         buttonSize = UIManager.getDimension("Spinner.arrowButtonSize");
+        buttonInsets = UIManager.getInsets("Spinner.arrowButtonInsets");
     }
 
     protected void uninstallDefaults() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneDivider.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneDivider.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneDivider.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneDivider.java Wed Sep  6 09:06:15 2006
@@ -44,6 +44,7 @@
 import javax.swing.border.Border;
 
 import org.apache.harmony.x.swing.StringConstants;
+import org.apache.harmony.x.swing.Utilities;
 
 
 public class BasicSplitPaneDivider extends Container implements PropertyChangeListener {
@@ -139,6 +140,10 @@
             int delta = mousePosition - initialMousePosition;
             int dividerLocation = splitPane.getDividerLocation() + delta;
 
+            if (splitPane.getMaximumDividerLocation() < splitPane.getMinimumDividerLocation()) {
+                return splitPane.getDividerLocation();
+            }
+            
             if (dividerLocation >= splitPane.getMinimumDividerLocation()
                 && dividerLocation <= splitPane.getMaximumDividerLocation()) {
 
@@ -299,6 +304,10 @@
         addMouseListener(mouseHandler);
         addMouseMotionListener(mouseHandler);
         updateCursor();
+        
+        if (Utilities.isUIResource(getBorder())) {
+            setBorder(UIManager.getBorder("SplitPaneDivider.border"));
+        }
     }
 
     public void setBasicSplitPaneUI(final BasicSplitPaneUI ui) {
@@ -378,13 +387,13 @@
 
     public void paint(final Graphics g) {
         super.paint(g);
-        if (getBorder() != null) {
-            getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
-        }
         if (splitPane.isFocusOwner()) {
             g.setColor(UIManager.getColor("SplitPane.darkShadow"));
             g.drawRect(0, 0, getWidth() - 2, getHeight() - 2);
         }
+        if (getBorder() != null) {
+            getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
+        }
     }
 
     protected JButton createLeftOneTouchButton() {
@@ -452,16 +461,17 @@
     }
 
     protected void oneTouchExpandableChanged() {
-        if (splitPane.isOneTouchExpandable()) {
+        if (leftButton != null) {
             remove(leftButton);
+        }
+        if (rightButton != null) {
             remove(rightButton);
+        }
+        if (splitPane.isOneTouchExpandable()) {
             leftButton = createLeftOneTouchButton();
             rightButton = createRightOneTouchButton();
             add(leftButton);
             add(rightButton);
-        } else {
-            remove(leftButton);
-            remove(rightButton);
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneKeyboardActions.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneKeyboardActions.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneKeyboardActions.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneKeyboardActions.java Wed Sep  6 09:06:15 2006
@@ -94,21 +94,75 @@
         return new AbstractAction() {
             public void actionPerformed(final ActionEvent e) {
                 JSplitPane splitPane = (JSplitPane)e.getSource();
+                isFocusRequested = false;
                 if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
-                    if (splitPane.getLeftComponent().isFocusOwner()) {
-                        splitPane.getRightComponent().requestFocus();
+                    if (splitPane.getLeftComponent() instanceof Container 
+                        && isHierarchyFocused((Container)splitPane.getLeftComponent()) 
+                        || splitPane.getLeftComponent().isFocusOwner()) {
+                        
+                        requestFocusInHierarchy((Container)splitPane.getRightComponent());
                     } else {
-                        splitPane.getLeftComponent().requestFocus();
+                        requestFocusInHierarchy((Container)splitPane.getLeftComponent());
                     }
                 } else {
-                    if (splitPane.getTopComponent().isFocusOwner()) {
-                        splitPane.getBottomComponent().requestFocus();
+                    if (splitPane.getTopComponent() instanceof Container 
+                        && isHierarchyFocused((Container)splitPane.getLeftComponent()) 
+                        || splitPane.getTopComponent().isFocusOwner()) {
+
+                        requestFocusInHierarchy((Container)splitPane.getBottomComponent());
                     } else {
-                        splitPane.getTopComponent().requestFocus();
+                        requestFocusInHierarchy((Container)splitPane.getTopComponent());
                     }
                 }
             }
         };
+    }
+    
+    private static boolean isHierarchyFocused(final Container root) {
+        if (root.isFocusOwner()) {
+            return root.isFocusOwner();
+        }
+
+        for (int i = 0; i < root.getComponentCount(); i++) {
+            Component child = root.getComponent(i);
+            if (child instanceof Container) {
+                return isHierarchyFocused((Container)child);
+            } else {
+                return child.isFocusOwner();
+            }
+        }
+
+        return false;
+    }
+
+    private static boolean isFocusRequested;
+    private static void requestFocusInHierarchy(final Container root) {
+        if (isFocusRequested) {
+            return;
+        }
+        
+        if (root.getComponentCount() == 0) {
+            root.requestFocus();
+            isFocusRequested = true;
+            
+            return;
+        }
+
+        for (int i = 0; i < root.getComponentCount(); i++) {
+            Component child = root.getComponent(i);
+            if (!(child instanceof JComponent)) {
+                root.requestFocus();
+                isFocusRequested = true;
+                
+                return;
+            }
+            if (child instanceof Container) {
+                requestFocusInHierarchy((Container)child);
+                if (isFocusRequested) {
+                    return;
+                }
+            }
+        }
     }
 
     private static Action newStartResizeAction() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicSplitPaneUI.java Wed Sep  6 09:06:15 2006
@@ -64,21 +64,9 @@
 
         public void layoutContainer(final Container container) {
             Insets insets = container.getInsets();
-
+            
             if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
-                if (splitPane.getDividerLocation() < 0) {
-                    resetToPreferredSizes();
-                } else if (splitPane.getDividerLocation() < insets.left) {
-                    dividerLocation = insets.left;
-                } else if (splitPane.getDividerLocation() > container.getWidth() - insets.right - dividerSize) {
-                    dividerLocation = container.getWidth() - insets.right - dividerSize;
-                } else {
-                    dividerLocation = splitPane.getDividerLocation();
-                }
-
-                if (dividerLocation >= insets.left && dividerLocation != splitPane.getDividerLocation() && isDisplayed) {
-                    splitPane.setDividerLocation(dividerLocation);
-                }
+                calculateNewDividerLocation(container.getWidth(), insets.left, insets.right);
 
                 int divX = dividerLocation;
                 int divY = insets.top;
@@ -91,6 +79,23 @@
                 int rightCompX = divX + divWidth;
                 int rightCompY = leftCompY;
                 int rightCompWidth = container.getWidth() - leftCompWidth - divWidth - insets.left - insets.right;
+                
+                if (rightCompWidth < components[RIGHT_COMPONENT_INDEX].getMinimumSize().width
+                    && leftCompWidth > components[LEFT_COMPONENT_INDEX].getMinimumSize().width) {
+                    
+                    rightCompWidth = components[RIGHT_COMPONENT_INDEX].getMinimumSize().width;
+                    leftCompWidth = container.getWidth() - rightCompWidth - divWidth - insets.left - insets.right;
+                    
+                    if (leftCompWidth < components[LEFT_COMPONENT_INDEX].getMinimumSize().width) {
+                        leftCompWidth = components[LEFT_COMPONENT_INDEX].getMinimumSize().width;
+                        rightCompWidth = container.getWidth() - leftCompWidth - divWidth - insets.left - insets.right;
+                    }
+
+                    dividerLocation = leftCompWidth + insets.left;
+                    if (dividerLocation >= insets.left && dividerLocation != splitPane.getDividerLocation() && isDisplayed) {
+                        splitPane.setDividerLocation(dividerLocation);
+                    }
+                }
 
                 int height = container.getHeight() - insets.top - insets.bottom;
 
@@ -107,22 +112,9 @@
                     sizes[RIGHT_COMPONENT_INDEX] = rightCompWidth;
                 }
             } else {
-                int divX = insets.left;
-
-                if (splitPane.getDividerLocation() < 0) {
-                    resetToPreferredSizes();
-                } else if (splitPane.getDividerLocation() < insets.top) {
-                    dividerLocation = insets.top;
-                } else if (splitPane.getDividerLocation() > container.getHeight() - insets.bottom - dividerSize) {
-                    dividerLocation = container.getHeight() - insets.bottom - dividerSize;
-                } else {
-                    dividerLocation = splitPane.getDividerLocation();
-                }
-
-                if (dividerLocation >= insets.top && dividerLocation != splitPane.getDividerLocation() && isDisplayed) {
-                    splitPane.setDividerLocation(dividerLocation);
-                }
+                calculateNewDividerLocation(container.getHeight(), insets.top, insets.bottom);
 
+                int divX = insets.left;
                 int divY = dividerLocation;
                 int divHeight = dividerSize;
 
@@ -133,9 +125,25 @@
                 int rightCompX = insets.left;
                 int rightCompY = divY + divHeight;
                 int rightCompHeight = container.getHeight() - leftCompHeight - divHeight - insets.top - insets.bottom;
-
+                
+                if (rightCompHeight < components[RIGHT_COMPONENT_INDEX].getMinimumSize().height
+                    && leftCompHeight > components[LEFT_COMPONENT_INDEX].getMinimumSize().height) {
+                        
+                    rightCompHeight = components[RIGHT_COMPONENT_INDEX].getMinimumSize().height;
+                    leftCompHeight = container.getHeight() - rightCompHeight - divHeight - insets.top - insets.bottom;
+                    
+                    if (leftCompHeight < components[LEFT_COMPONENT_INDEX].getMinimumSize().height) {
+                        leftCompHeight = components[LEFT_COMPONENT_INDEX].getMinimumSize().height;
+                        rightCompHeight = container.getHeight() - leftCompHeight - divHeight - insets.top - insets.bottom;
+                    }
+                    
+                    dividerLocation = leftCompHeight + insets.top;
+                    if (dividerLocation >= insets.top && dividerLocation != splitPane.getDividerLocation() && isDisplayed) {
+                        splitPane.setDividerLocation(dividerLocation);
+                    }
+                }
+                
                 int width = container.getWidth() - insets.left - insets.right;
-
                 if (components[LEFT_COMPONENT_INDEX] != null) {
                     components[LEFT_COMPONENT_INDEX].setBounds(leftCompX, leftCompY, width, leftCompHeight);
                     sizes[LEFT_COMPONENT_INDEX] = leftCompHeight;
@@ -170,6 +178,8 @@
             if (JSplitPane.BOTTOM.equals(place) || JSplitPane.RIGHT.equals(place)) {
                 components[RIGHT_COMPONENT_INDEX] = component;
             }
+            
+            resetToPreferredSizes();
         }
 
         public Dimension minimumLayoutSize(final Container container) {
@@ -255,8 +265,15 @@
         }
 
         public void resetToPreferredSizes() {
-            dividerLocation = getPreferredSizeOfComponent(components[LEFT_COMPONENT_INDEX])
+            if (components[LEFT_COMPONENT_INDEX] == null) {
+                return;
+            }
+            
+            int prefLocation = getPreferredSizeOfComponent(components[LEFT_COMPONENT_INDEX])
                               + getInitialLocation(splitPane.getInsets());
+            int minLocation = getMinimumSizeOfComponent(components[LEFT_COMPONENT_INDEX])
+                              + getInitialLocation(splitPane.getInsets());
+            dividerLocation = prefLocation > minLocation ? prefLocation : minLocation;
             splitPane.setDividerLocation(dividerLocation);
         }
 
@@ -348,6 +365,22 @@
         private int componentMinHeight(final int index) {
             return components[index] == null ? 0 : components[index].getMinimumSize().height;
         }
+
+        private void calculateNewDividerLocation(final int containerSize, final int topLeft, final int bottomRight) {
+            if (dividerLocation != splitPane.getDividerLocation()) {
+                if (splitPane.getDividerLocation() < 0 || splitPane.getDividerLocation() < topLeft) {
+                    dividerLocation = topLeft;
+                } else if (splitPane.getDividerLocation() > containerSize - bottomRight - dividerSize) {
+                    dividerLocation = containerSize - bottomRight - dividerSize;
+                } else {
+                    dividerLocation = splitPane.getDividerLocation();
+                }
+                
+                if (dividerLocation >= topLeft && dividerLocation != splitPane.getDividerLocation() && isDisplayed) {
+                    splitPane.setDividerLocation(dividerLocation);
+                }
+            }
+        }
     }
 
     public class BasicVerticalLayoutManager extends BasicHorizontalLayoutManager {
@@ -489,6 +522,7 @@
         installKeyboardActions();
 
         divider.oneTouchExpandableChanged();
+        resetToPreferredSizes(getSplitPane());
     }
 
     protected void installDefaults() {
@@ -509,7 +543,7 @@
         dividerSize = UIManager.getInt("SplitPane.dividerSize");
         divider = createDefaultDivider();
         divider.setDividerSize(dividerSize);
-        divider.setBorder(UIManager.getBorder("SplitPane.border"));
+        LookAndFeel.installBorder(splitPane, "SplitPane.border");
         splitPane.setDividerSize(dividerSize);
 
         setNonContinuousLayoutDivider(createDefaultNonContinuousLayoutDivider());
@@ -768,4 +802,15 @@
         return 0;
     }
 
+    private int getMinimumSizeOfComponent(final Component c) {
+        if (c == null) {
+            return 0;
+        }
+
+        if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
+            return c.getMinimumSize().width;
+        } else {
+            return c.getMinimumSize().height;
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTabbedPaneUI.java Wed Sep  6 09:06:15 2006
@@ -72,6 +72,7 @@
 import javax.swing.text.View;
 
 import org.apache.harmony.x.swing.ButtonCommons;
+import org.apache.harmony.x.swing.StringConstants;
 import org.apache.harmony.x.swing.Utilities;
 
 public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
@@ -656,6 +657,20 @@
         }
     }
 
+    private static class MnemonicAction extends AbstractAction {
+        public void actionPerformed(final ActionEvent e) {
+            JTabbedPane tabPane = (JTabbedPane)e.getSource();
+
+            int keyCode = Utilities.keyCharToKeyCode(e.getActionCommand().charAt(0));
+            for (int i = 0; i < tabPane.getTabCount(); i++) {
+                if (keyCode == tabPane.getMnemonicAt(i)) {
+                    tabPane.setSelectedIndex(i);
+                    break;
+                }
+            }
+        }
+    }
+
     public static ComponentUI createUI(final JComponent c) {
         return new BasicTabbedPaneUI();
     }
@@ -681,6 +696,7 @@
     }
 
     private static int TAB_RUNS_ARRAY_SIZE_INCREMENT = 5;
+    private static AbstractAction MNEMONIC_ACTION = new MnemonicAction();
 
     protected transient Rectangle calcRect = new Rectangle();
 
@@ -1137,6 +1153,8 @@
                             tabPane.requestFocus();
                         }
         });
+
+        actionMap.put(StringConstants.MNEMONIC_ACTION, MNEMONIC_ACTION);
 
         return actionMap;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableKeyboardActions.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableKeyboardActions.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableKeyboardActions.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableKeyboardActions.java Wed Sep  6 09:06:15 2006
@@ -23,6 +23,7 @@
 import java.awt.event.ActionEvent;
 
 import javax.swing.AbstractAction;
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.JComponent;
 import javax.swing.JTable;
 import javax.swing.ListSelectionModel;
@@ -71,6 +72,21 @@
         }
     }
 
+    private static abstract class EnablebableLeadRowColumnAction extends LeadRowColumnAction {
+        final JTable table;
+
+        public EnablebableLeadRowColumnAction(final JTable table) {
+            this.table = table;
+        }
+
+        public boolean isEnabled() {
+            return isEnabled(table, table.getSelectionModel().getLeadSelectionIndex(),
+                             table.getColumnModel().getSelectionModel().getLeadSelectionIndex());
+        }
+
+        public abstract boolean isEnabled(final JTable table, final int currentRow, final int currentColumn);
+    }
+
     private static AbstractAction selectNextColumnAction = new LeadRowColumnAction() {
         protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
             if (currentColumn + 1 < table.getColumnCount()) {
@@ -78,6 +94,14 @@
             }
         }
     };
+    private static AbstractAction selectNextColumnChangeLeadAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentColumn + 1 < table.getColumnCount() && (table.getColumnModel().getSelectionModel() instanceof DefaultListSelectionModel)) {
+                ((DefaultListSelectionModel)table.getColumnModel().getSelectionModel()).moveLeadSelectionIndex(currentColumn + 1);
+                ensureCellIsVisible(table, currentRow, currentColumn + 1);
+            }
+        }
+    };
     private static AbstractAction selectPreviousColumnAction = new LeadRowColumnAction() {
         protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
             if (currentColumn > 0) {
@@ -85,6 +109,14 @@
             }
         }
     };
+    private static AbstractAction selectPreviousColumnChangeLeadAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentColumn > 0 && (table.getColumnModel().getSelectionModel() instanceof DefaultListSelectionModel)) {
+                ((DefaultListSelectionModel)table.getColumnModel().getSelectionModel()).moveLeadSelectionIndex(currentColumn - 1);
+                ensureCellIsVisible(table, currentRow, currentColumn - 1);
+            }
+        }
+    };
     private static AbstractAction selectNextRowAction = new LeadRowColumnAction() {
         protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
             if (currentRow + 1 < table.getRowCount()) {
@@ -92,6 +124,14 @@
             }
         }
     };
+    private static AbstractAction selectNextRowChangeLeadAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentRow + 1 < table.getRowCount() && (table.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                ((DefaultListSelectionModel)table.getSelectionModel()).moveLeadSelectionIndex(currentRow + 1);
+                ensureCellIsVisible(table, currentRow + 1, currentColumn);
+            }
+        }
+    };
     private static AbstractAction selectPreviousRowAction = new LeadRowColumnAction() {
         protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
             if (currentRow > 0) {
@@ -99,6 +139,14 @@
             }
         }
     };
+    private static AbstractAction selectPreviousRowChangeLeadAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentRow > 0 && (table.getSelectionModel() instanceof DefaultListSelectionModel)) {
+                ((DefaultListSelectionModel)table.getSelectionModel()).moveLeadSelectionIndex(currentRow - 1);
+                ensureCellIsVisible(table, currentRow - 1, currentColumn);
+            }
+        }
+    };
 
     private static AbstractAction selectNextColumnExtendSelectionAction = new LeadRowColumnAction() {
         protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
@@ -170,6 +218,30 @@
             table.changeSelection(table.getRowCount() - 1, currentColumn, false, true);
         }
     };
+    private static AbstractAction toggleAndAnchorAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentRow >= 0 && currentColumn >=0) {
+                table.changeSelection(currentRow, currentColumn, true, false);
+                table.getSelectionModel().setAnchorSelectionIndex(currentRow);
+                table.getColumnModel().getSelectionModel().setAnchorSelectionIndex(currentColumn);
+            }
+        }
+    };
+    private static AbstractAction moveSelectionToAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentRow >= 0 && currentColumn >=0) {
+                table.changeSelection(currentRow, currentColumn, false, false);
+            }
+        }
+    };
+    private static AbstractAction extendToAction = new LeadRowColumnAction() {
+        protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+            if (currentRow >= 0 && currentColumn >=0) {
+                table.changeSelection(currentRow, currentColumn, false, true);
+            }
+        }
+    };
+
 
     private static abstract class SelectRowColumnCellAction extends LeadRowColumnAction {
         protected abstract int[] nextCellCoords(final int[] cell, final int minRow, final int maxRow,
@@ -186,11 +258,42 @@
                 table.changeSelection(currentCell[0], currentCell[1], false, false);
             } else {
                 int[] currentCell = new int[] { currentRow, currentColumn };
+                int rowMinSelectionIndex;
+                int rowMaxSelectionIndex;
+                int colMinSelectionIndex;
+                int colMaxSelectionIndex;
+                
+                if (table.getRowSelectionAllowed() && table.getColumnSelectionAllowed()) {
+                    rowMinSelectionIndex = rowSelectionModel.getMinSelectionIndex();
+                    rowMaxSelectionIndex = rowSelectionModel.getMaxSelectionIndex();
+                    colMinSelectionIndex = colSelectionModel.getMinSelectionIndex();
+                    colMaxSelectionIndex = colSelectionModel.getMaxSelectionIndex();
+                } else if (table.getRowSelectionAllowed() && !table.getColumnSelectionAllowed()) {
+                    rowMinSelectionIndex = rowSelectionModel.getMinSelectionIndex();
+                    rowMaxSelectionIndex = rowSelectionModel.getMaxSelectionIndex();
+                    colMinSelectionIndex = 0;
+                    colMaxSelectionIndex = table.getColumnCount() - 1;
+                } else if (!table.getRowSelectionAllowed() && table.getColumnSelectionAllowed()) {
+                    rowMinSelectionIndex = 0;
+                    rowMaxSelectionIndex = table.getRowCount() - 1;
+                    colMinSelectionIndex = colSelectionModel.getMinSelectionIndex();
+                    colMaxSelectionIndex = colSelectionModel.getMaxSelectionIndex();
+                } else {
+                    rowMinSelectionIndex = 0;
+                    rowMaxSelectionIndex = table.getRowCount() - 1;
+                    colMinSelectionIndex = 0;
+                    colMaxSelectionIndex = table.getColumnCount() - 1;
+                }
+                
                 do {
-                    currentCell = nextCellCoords(currentCell, rowSelectionModel.getMinSelectionIndex(), rowSelectionModel.getMaxSelectionIndex(),
-                            colSelectionModel.getMinSelectionIndex(), colSelectionModel.getMaxSelectionIndex());
+                    currentCell = nextCellCoords(currentCell, rowMinSelectionIndex, rowMaxSelectionIndex,
+                                                 colMinSelectionIndex, colMaxSelectionIndex);
+                    
+                    if (!table.getRowSelectionAllowed() && !table.getColumnSelectionAllowed()) {
+                        break;
+                    }
                 } while (!table.isCellSelected(currentCell[0], currentCell[1]));
-
+                
                 colSelectionModel.addSelectionInterval(currentCell[1], currentCell[1]);
                 rowSelectionModel.addSelectionInterval(currentCell[0], currentCell[0]);
             }
@@ -264,9 +367,20 @@
 
     private static AbstractAction selectAllAction = new AbstractTableAction() {
         protected void processTable(final JTable table) {
+            if (table.isEditing()) {
+                table.getCellEditor().cancelCellEditing();
+            }
             table.selectAll();
         }
     };
+    private static AbstractAction clearSelectionAction = new AbstractTableAction() {
+        protected void processTable(final JTable table) {
+            if (table.isEditing()) {
+                table.getCellEditor().cancelCellEditing();
+            }
+            table.clearSelection();
+        }
+    };
 
     private static AbstractAction startEditingAction = new LeadRowColumnAction() {
         protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
@@ -380,6 +494,11 @@
         table.getActionMap().put("selectPreviousColumn", selectPreviousColumnAction);
         table.getActionMap().put("selectNextRow", selectNextRowAction);
         table.getActionMap().put("selectPreviousRow", selectPreviousRowAction);
+        
+        table.getActionMap().put("selectPreviousRowChangeLead", selectPreviousRowChangeLeadAction);
+        table.getActionMap().put("selectNextRowChangeLead", selectNextRowChangeLeadAction);
+        table.getActionMap().put("selectPreviousColumnChangeLead", selectPreviousColumnChangeLeadAction);
+        table.getActionMap().put("selectNextColumnChangeLead", selectNextColumnChangeLeadAction);
 
         table.getActionMap().put("selectNextColumnExtendSelection", selectNextColumnExtendSelectionAction);
         table.getActionMap().put("selectPreviousColumnExtendSelection", selectPreviousColumnExtendSelectionAction);
@@ -411,6 +530,23 @@
         table.getActionMap().put("selectPreviousRowCell", selectPreviousRowCellAction);
 
         table.getActionMap().put("selectAll", selectAllAction);
+        table.getActionMap().put("clearSelection", clearSelectionAction);
+
+        table.getActionMap().put("addToSelection", new EnablebableLeadRowColumnAction(table) {
+            protected void processRowColumn(final JTable table, final int currentRow, final int currentColumn) {
+                if (currentRow >= 0 && currentColumn >=0) {
+                    table.addRowSelectionInterval(currentRow, currentRow);
+                    table.addColumnSelectionInterval(currentColumn, currentColumn);
+                }
+            }
+            public boolean isEnabled(final JTable table, final int currentRow, final int currentColumn) {
+                return !table.isCellSelected(currentRow, currentColumn);
+            }
+        });
+
+        table.getActionMap().put("toggleAndAnchor", toggleAndAnchorAction);
+        table.getActionMap().put("moveSelectionTo", moveSelectionToAction);
+        table.getActionMap().put("extendTo", extendToAction);
 
         table.getActionMap().put("startEditing", startEditingAction);
         table.getActionMap().put("cancel", cancelAction);
@@ -583,4 +719,8 @@
             return i;
         }
     }
+
+    private static void ensureCellIsVisible(final JTable table, final int row, final int column) {
+        table.scrollRectToVisible(table.getCellRect(row, column, true));
+     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java?view=diff&rev=440748&r1=440747&r2=440748
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java Wed Sep  6 09:06:15 2006
@@ -150,7 +150,6 @@
                         changeSelection(e);
                     }
                     forwardEventToEditor(e);
-                    table.getEditorComponent().requestFocus();
                 } else {
                     changeSelection(e);
                 }



Mime
View raw message