Source for java.awt.dnd.DragSourceContext

   1: /* DragSourceContext.java --
   2:    Copyright (C) 2002 Free Software Foundation
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package java.awt.dnd;
  40: 
  41: import gnu.classpath.NotImplementedException;
  42: 
  43: import java.awt.Component;
  44: import java.awt.Cursor;
  45: import java.awt.Image;
  46: import java.awt.Point;
  47: import java.awt.datatransfer.Transferable;
  48: import java.awt.dnd.peer.DragSourceContextPeer;
  49: import java.io.Serializable;
  50: import java.util.TooManyListenersException;
  51: 
  52: /**
  53:  * @since 1.2
  54:  */
  55: public class DragSourceContext
  56:   implements DragSourceListener, DragSourceMotionListener, Serializable
  57: {
  58:   /**
  59:    * Compatible with JDK 1.2+
  60:    */
  61:   static final long serialVersionUID = -115407898692194719L;
  62: 
  63:   protected static final int DEFAULT = 0;
  64:   protected static final int ENTER = 1;
  65:   protected static final int OVER = 2;
  66:   protected static final int CHANGED = 3;
  67: 
  68:   private DragSourceContextPeer peer;
  69:   private Cursor cursor;
  70:   private Transferable transferable;
  71:   private DragGestureEvent trigger;
  72:   private DragSourceListener dragSourceListener;
  73:   private boolean useCustomCursor; // FIXME: currently unused but needed for serialization.
  74:   private int sourceActions; // FIXME: currently unused but needed for serialization.
  75:   private Image image;
  76:   private Point offset;
  77:   
  78:   /**
  79:    * Initializes a drag source context.
  80:    *
  81:    * @exception IllegalArgumentException If Component or DragSource of trigger
  82:    * are null, the drag action for the trigger event is DnDConstants.ACTION_NONE
  83:    * or if the source actions for the DragGestureRecognizer associated with the
  84:    * trigger event are equal to DnDConstants.ACTION_NONE.
  85:    * @exception NullPointerException If peer or trigger is null.
  86:    */
  87:   public DragSourceContext (DragSourceContextPeer peer,
  88:                             DragGestureEvent trigger, Cursor cursor,
  89:                             Image image, Point offset, Transferable trans,
  90:                             DragSourceListener dsl)
  91:     throws NotImplementedException
  92:   {
  93:     if (peer == null
  94:         || trigger == null)
  95:       throw new NullPointerException ();
  96: 
  97:     if (trigger.getComponent () == null
  98:         || trigger.getDragSource () == null
  99:         || trigger.getDragAction () == DnDConstants.ACTION_NONE
 100:         || trigger.getSourceAsDragGestureRecognizer ()
 101:               .getSourceActions () == DnDConstants.ACTION_NONE)
 102:       throw new IllegalArgumentException ();
 103: 
 104:     this.peer = peer;
 105:     this.trigger = trigger;
 106:     this.cursor = cursor;
 107:     this.image = image;
 108:     this.offset = offset;
 109:     this.transferable = trans;
 110:     this.dragSourceListener = dsl;
 111:     
 112:     throw new Error ("not implemented");
 113:   }
 114: 
 115:   public DragSource getDragSource()
 116:   {
 117:     return trigger.getDragSource ();
 118:   }
 119: 
 120:   public Component getComponent()
 121:   {
 122:     return trigger.getComponent ();
 123:   }
 124: 
 125:   public DragGestureEvent getTrigger()
 126:   {
 127:     return trigger;
 128:   }
 129: 
 130:   public int getSourceActions()
 131:   {
 132:     return trigger.getSourceAsDragGestureRecognizer ().getSourceActions ();
 133:   }
 134: 
 135:   public void setCursor (Cursor cursor)
 136:     throws NotImplementedException
 137:   {
 138:     this.cursor = cursor;
 139:     // FIXME: Check if we need to do more here
 140:   }
 141: 
 142:   public Cursor getCursor()
 143:   {
 144:     return cursor;
 145:   }
 146: 
 147:   /**
 148:    * Adds a <code>DragSourceListener</code>.
 149:    *
 150:    * @exception TooManyListenersException If a <code>DragSourceListener</code>
 151:    * has already been added.
 152:    */
 153:   public void addDragSourceListener (DragSourceListener dsl)
 154:     throws TooManyListenersException
 155:   {
 156:     if (dragSourceListener != null)
 157:       throw new TooManyListenersException ();
 158: 
 159:     dragSourceListener = dsl;
 160:   }
 161: 
 162:   public void removeDragSourceListener (DragSourceListener dsl)
 163:   {
 164:     if (dragSourceListener == dsl)
 165:       dragSourceListener = null;
 166:   }
 167: 
 168:   public void transferablesFlavorsChanged()
 169:     throws NotImplementedException
 170:   {
 171:   }
 172: 
 173:   public void dragEnter(DragSourceDragEvent e)
 174:     throws NotImplementedException
 175:   {
 176:   }
 177: 
 178:   public void dragOver(DragSourceDragEvent e)
 179:     throws NotImplementedException
 180:   {
 181:   }
 182: 
 183:   public void dragExit(DragSourceEvent e)
 184:     throws NotImplementedException
 185:   {
 186:   }
 187: 
 188:   public void dropActionChanged(DragSourceDragEvent e)
 189:     throws NotImplementedException
 190:   {
 191:   }
 192: 
 193:   public void dragDropEnd(DragSourceDropEvent e)
 194:     throws NotImplementedException
 195:   {
 196:   }
 197: 
 198:   public void dragMouseMoved(DragSourceDragEvent e)
 199:     throws NotImplementedException
 200:   {
 201:   }
 202: 
 203:   public Transferable getTransferable()
 204:   {
 205:     return transferable;
 206:   }
 207: 
 208:   protected void updateCurrentCursor(int dropOp, int targetAct, int status)
 209:     throws NotImplementedException
 210:   {
 211:   }
 212: } // class DragSourceContext