< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.plaf.basic;
  27 
  28 import javax.swing.*;
  29 import javax.swing.event.*;
  30 import java.awt.*;
  31 import java.awt.event.*;
  32 import java.awt.datatransfer.*;
  33 import java.beans.*;

  34 import java.util.Enumeration;
  35 import java.util.Hashtable;
  36 import java.util.ArrayList;
  37 import java.util.Collections;
  38 import java.util.Comparator;
  39 import javax.swing.plaf.ComponentUI;
  40 import javax.swing.plaf.UIResource;
  41 import javax.swing.plaf.TreeUI;
  42 import javax.swing.tree.*;
  43 import javax.swing.text.Position;
  44 import javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag;
  45 import sun.awt.AWTAccessor;
  46 import sun.swing.SwingUtilities2;
  47 
  48 import sun.swing.DefaultLookup;
  49 import sun.swing.UIAction;
  50 
  51 /**
  52  * The basic L&amp;F for a hierarchical data structure.
  53  *


3987 
3988             if (grabFocus) {
3989                 SwingUtilities2.adjustFocus(tree);
3990             }
3991 
3992             handleSelection(e);
3993         }
3994 
3995         void handleSelection(MouseEvent e) {
3996             if(pressedPath != null) {
3997                 Rectangle bounds = getPathBounds(tree, pressedPath);
3998 
3999                 if (bounds == null || e.getY() >= (bounds.y + bounds.height)) {
4000                     return;
4001                 }
4002 
4003                 // Preferably checkForClickInExpandControl could take
4004                 // the Event to do this it self!
4005                 if(SwingUtilities.isLeftMouseButton(e)) {
4006                     checkForClickInExpandControl(pressedPath, e.getX(), e.getY());







4007                 }
4008 
4009                 int x = e.getX();
4010 
4011                 // Perhaps they clicked the cell itself. If so,
4012                 // select it.
4013                 if (x >= bounds.x && x < (bounds.x + bounds.width)) {
4014                     if (tree.getDragEnabled() || !startEditing(pressedPath, e)) {
4015                         selectPathForEvent(pressedPath, e);
4016                     }
4017                 }
4018             }
4019         }
4020 
4021         public void dragStarting(MouseEvent me) {
4022             dragStarted = true;
4023 
4024             if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) {
4025                 tree.addSelectionPath(pressedPath);
4026                 setAnchorSelectionPath(pressedPath);




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.plaf.basic;
  27 
  28 import javax.swing.*;
  29 import javax.swing.event.*;
  30 import java.awt.*;
  31 import java.awt.event.*;
  32 import java.awt.datatransfer.*;
  33 import java.beans.*;
  34 import static java.lang.Boolean.TRUE;
  35 import java.util.Enumeration;
  36 import java.util.Hashtable;
  37 import java.util.ArrayList;
  38 import java.util.Collections;
  39 import java.util.Comparator;
  40 import javax.swing.plaf.ComponentUI;
  41 import javax.swing.plaf.UIResource;
  42 import javax.swing.plaf.TreeUI;
  43 import javax.swing.tree.*;
  44 import javax.swing.text.Position;
  45 import javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag;
  46 import sun.awt.AWTAccessor;
  47 import sun.swing.SwingUtilities2;
  48 
  49 import sun.swing.DefaultLookup;
  50 import sun.swing.UIAction;
  51 
  52 /**
  53  * The basic L&amp;F for a hierarchical data structure.
  54  *


3988 
3989             if (grabFocus) {
3990                 SwingUtilities2.adjustFocus(tree);
3991             }
3992 
3993             handleSelection(e);
3994         }
3995 
3996         void handleSelection(MouseEvent e) {
3997             if(pressedPath != null) {
3998                 Rectangle bounds = getPathBounds(tree, pressedPath);
3999 
4000                 if (bounds == null || e.getY() >= (bounds.y + bounds.height)) {
4001                     return;
4002                 }
4003 
4004                 // Preferably checkForClickInExpandControl could take
4005                 // the Event to do this it self!
4006                 if(SwingUtilities.isLeftMouseButton(e)) {
4007                     checkForClickInExpandControl(pressedPath, e.getX(), e.getY());
4008                     
4009                     if(tree.getClientProperty("Tree.enableDoubleClickOnExpandControl") == TRUE)
4010                         // without this return statement, when double click on 
4011                         // the expand control, only the first click is processed. 
4012                         // used by WindowsNavigationTree
4013                         if (isLocationInExpandControl(pressedPath, e.getX(), e.getY())) 
4014                             return;
4015                 }
4016 
4017                 int x = e.getX();
4018 
4019                 // Perhaps they clicked the cell itself. If so,
4020                 // select it.
4021                 if (x >= bounds.x && x < (bounds.x + bounds.width)) {
4022                     if (tree.getDragEnabled() || !startEditing(pressedPath, e)) {
4023                         selectPathForEvent(pressedPath, e);
4024                     }
4025                 }
4026             }
4027         }
4028 
4029         public void dragStarting(MouseEvent me) {
4030             dragStarted = true;
4031 
4032             if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) {
4033                 tree.addSelectionPath(pressedPath);
4034                 setAnchorSelectionPath(pressedPath);


< prev index next >