< prev index next >

src/share/classes/javax/swing/plaf/basic/DragRecognitionSupport.java

Print this page
rev 1580 : 6727661: Code improvement and warnings removing from the swing/plaf packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: alexp
Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>


  56     /**
  57      * Returns the DragRecognitionSupport for the caller's AppContext.
  58      */
  59     private static DragRecognitionSupport getDragRecognitionSupport() {
  60         DragRecognitionSupport support =
  61             (DragRecognitionSupport)AppContext.getAppContext().
  62                 get(DragRecognitionSupport.class);
  63 
  64         if (support == null) {
  65             support = new DragRecognitionSupport();
  66             AppContext.getAppContext().put(DragRecognitionSupport.class, support);
  67         }
  68 
  69         return support;
  70     }
  71 
  72     /**
  73      * Returns whether or not the event is potentially part of a drag sequence.
  74      */
  75     public static boolean mousePressed(MouseEvent me) {
  76         return ((DragRecognitionSupport)getDragRecognitionSupport()).
  77             mousePressedImpl(me);
  78     }
  79 
  80     /**
  81      * If a dnd recognition has been going on, return the MouseEvent
  82      * that started the recognition. Otherwise, return null.
  83      */
  84     public static MouseEvent mouseReleased(MouseEvent me) {
  85         return ((DragRecognitionSupport)getDragRecognitionSupport()).
  86             mouseReleasedImpl(me);
  87     }
  88 
  89     /**
  90      * Returns whether or not a drag gesture recognition is ongoing.
  91      */
  92     public static boolean mouseDragged(MouseEvent me, BeforeDrag bd) {
  93         return ((DragRecognitionSupport)getDragRecognitionSupport()).
  94             mouseDraggedImpl(me, bd);
  95     }
  96 
  97     private void clearState() {
  98         dndArmedEvent = null;
  99         component = null;
 100     }
 101 
 102     private int mapDragOperationFromModifiers(MouseEvent me,
 103                                               TransferHandler th) {
 104 
 105         if (th == null || !SwingUtilities.isLeftMouseButton(me)) {
 106             return TransferHandler.NONE;
 107         }
 108 
 109         return SunDragSourceContextPeer.
 110             convertModifiersToDropAction(me.getModifiersEx(),
 111                                          th.getSourceActions(component));
 112     }
 113 
 114     /**




  56     /**
  57      * Returns the DragRecognitionSupport for the caller's AppContext.
  58      */
  59     private static DragRecognitionSupport getDragRecognitionSupport() {
  60         DragRecognitionSupport support =
  61             (DragRecognitionSupport)AppContext.getAppContext().
  62                 get(DragRecognitionSupport.class);
  63 
  64         if (support == null) {
  65             support = new DragRecognitionSupport();
  66             AppContext.getAppContext().put(DragRecognitionSupport.class, support);
  67         }
  68 
  69         return support;
  70     }
  71 
  72     /**
  73      * Returns whether or not the event is potentially part of a drag sequence.
  74      */
  75     public static boolean mousePressed(MouseEvent me) {
  76         return getDragRecognitionSupport().mousePressedImpl(me);

  77     }
  78 
  79     /**
  80      * If a dnd recognition has been going on, return the MouseEvent
  81      * that started the recognition. Otherwise, return null.
  82      */
  83     public static MouseEvent mouseReleased(MouseEvent me) {
  84         return getDragRecognitionSupport().mouseReleasedImpl(me);

  85     }
  86 
  87     /**
  88      * Returns whether or not a drag gesture recognition is ongoing.
  89      */
  90     public static boolean mouseDragged(MouseEvent me, BeforeDrag bd) {
  91         return getDragRecognitionSupport().mouseDraggedImpl(me, bd);

  92     }
  93 
  94     private void clearState() {
  95         dndArmedEvent = null;
  96         component = null;
  97     }
  98 
  99     private int mapDragOperationFromModifiers(MouseEvent me,
 100                                               TransferHandler th) {
 101 
 102         if (th == null || !SwingUtilities.isLeftMouseButton(me)) {
 103             return TransferHandler.NONE;
 104         }
 105 
 106         return SunDragSourceContextPeer.
 107             convertModifiersToDropAction(me.getModifiersEx(),
 108                                          th.getSourceActions(component));
 109     }
 110 
 111     /**


< prev index next >