Merge from mainline.
[official-gcc.git] / libjava / classpath / java / awt / dnd / DragSourceContext.java
blob88607b090eab634e85f7a7c50ecd52c089ec9793
1 /* DragSourceContext.java --
2 Copyright (C) 2002 Free Software Foundation
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
39 package java.awt.dnd;
41 import gnu.classpath.NotImplementedException;
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;
52 /**
53 * @since 1.2
55 public class DragSourceContext
56 implements DragSourceListener, DragSourceMotionListener, Serializable
58 /**
59 * Compatible with JDK 1.2+
61 static final long serialVersionUID = -115407898692194719L;
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;
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;
78 /**
79 * Initializes a drag source context.
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.
87 public DragSourceContext (DragSourceContextPeer peer,
88 DragGestureEvent trigger, Cursor cursor,
89 Image image, Point offset, Transferable trans,
90 DragSourceListener dsl)
91 throws NotImplementedException
93 if (peer == null
94 || trigger == null)
95 throw new NullPointerException ();
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 ();
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;
112 throw new Error ("not implemented");
115 public DragSource getDragSource()
117 return trigger.getDragSource ();
120 public Component getComponent()
122 return trigger.getComponent ();
125 public DragGestureEvent getTrigger()
127 return trigger;
130 public int getSourceActions()
132 return trigger.getSourceAsDragGestureRecognizer ().getSourceActions ();
135 public void setCursor (Cursor cursor)
136 throws NotImplementedException
138 this.cursor = cursor;
139 // FIXME: Check if we need to do more here
142 public Cursor getCursor()
144 return cursor;
148 * Adds a <code>DragSourceListener</code>.
150 * @exception TooManyListenersException If a <code>DragSourceListener</code>
151 * has already been added.
153 public void addDragSourceListener (DragSourceListener dsl)
154 throws TooManyListenersException
156 if (dragSourceListener != null)
157 throw new TooManyListenersException ();
159 dragSourceListener = dsl;
162 public void removeDragSourceListener (DragSourceListener dsl)
164 if (dragSourceListener == dsl)
165 dragSourceListener = null;
168 public void transferablesFlavorsChanged()
169 throws NotImplementedException
173 public void dragEnter(DragSourceDragEvent e)
174 throws NotImplementedException
178 public void dragOver(DragSourceDragEvent e)
179 throws NotImplementedException
183 public void dragExit(DragSourceEvent e)
184 throws NotImplementedException
188 public void dropActionChanged(DragSourceDragEvent e)
189 throws NotImplementedException
193 public void dragDropEnd(DragSourceDropEvent e)
194 throws NotImplementedException
198 public void dragMouseMoved(DragSourceDragEvent e)
199 throws NotImplementedException
203 public Transferable getTransferable()
205 return transferable;
208 protected void updateCurrentCursor(int dropOp, int targetAct, int status)
209 throws NotImplementedException
212 } // class DragSourceContext