OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [java/] [awt/] [dnd/] [DropTarget.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* DropTarget.java --
2
   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
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 java.awt.Component;
42
import java.awt.GraphicsEnvironment;
43
import java.awt.HeadlessException;
44
import java.awt.Point;
45
import java.awt.datatransfer.FlavorMap;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
48
import java.io.Serializable;
49
import java.util.EventListener;
50
import java.util.TooManyListenersException;
51
 
52
/**
53
 * @author Michael Koch
54
 * @since 1.2
55
 */
56
public class DropTarget
57
  implements DropTargetListener, EventListener, Serializable
58
{
59
  /**
60
   * Compatible with JDK 1.2+
61
   */
62
  private static final long serialVersionUID = -6283860791671019047L;
63
 
64
  /** @specnote According to the online documentation, this is
65
   * protected, but in reality it is public.  */
66
  public static class DropTargetAutoScroller
67
    implements ActionListener
68
  {
69
    private Component component;
70
    private Point point;
71
 
72
    protected DropTargetAutoScroller (Component c, Point p)
73
    {
74
      component = c;
75
      point = p;
76
    }
77
 
78
    protected void updateLocation (Point newLocn)
79
    {
80
      point = newLocn;
81
    }
82
 
83
    protected void stop ()
84
    {
85
    }
86
 
87
    public void actionPerformed (ActionEvent e)
88
    {
89
    }
90
  }
91
 
92
  private Component component;
93
  private FlavorMap flavorMap;
94
  private int actions;
95
  private DropTargetContext dropTargetContext;
96
  private DropTargetListener dropTargetListener;
97
  private boolean active = true;
98
 
99
  /**
100
   * Creates a <code>DropTarget</code> object.
101
   *
102
   * @exception HeadlessException If GraphicsEnvironment.isHeadless()
103
   * returns true.
104
   */
105
  public DropTarget ()
106
  {
107
    this (null, 0, null, true, null);
108
  }
109
 
110
  /**
111
   * Creates a <code>DropTarget</code> object.
112
   *
113
   * @exception HeadlessException If GraphicsEnvironment.isHeadless()
114
   * returns true.
115
   */
116
  public DropTarget (Component c, DropTargetListener dtl)
117
  {
118
    this (c, 0, dtl, true, null);
119
  }
120
 
121
  /**
122
   * Creates a <code>DropTarget</code> object.
123
   *
124
   * @exception HeadlessException If GraphicsEnvironment.isHeadless()
125
   * returns true.
126
   */
127
  public DropTarget (Component c, int i, DropTargetListener dtl)
128
  {
129
    this (c, i, dtl, true, null);
130
  }
131
 
132
  /**
133
   * Creates a <code>DropTarget</code> object.
134
   *
135
   * @exception HeadlessException If GraphicsEnvironment.isHeadless()
136
   * returns true.
137
   */
138
  public DropTarget (Component c, int i, DropTargetListener dtl, boolean b)
139
  {
140
    this (c, i, dtl, b, null);
141
  }
142
 
143
  /**
144
   * Creates a <code>DropTarget</code> object.
145
   *
146
   * @exception HeadlessException If GraphicsEnvironment.isHeadless()
147
   * returns true.
148
   */
149
  public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
150
                     FlavorMap fm)
151
  {
152
    if (GraphicsEnvironment.isHeadless ())
153
      throw new HeadlessException ();
154
 
155
    component = c;
156
    actions = i;
157
    dropTargetListener = dtl;
158
    flavorMap = fm;
159
 
160
    setActive (b);
161
  }
162
 
163
  /**
164
   * Sets the component associated with this drop target object.
165
   */
166
  public void setComponent (Component c)
167
  {
168
    component = c;
169
  }
170
 
171
  /**
172
   * Returns the component associated with this drop target object.
173
   */
174
  public Component getComponent ()
175
  {
176
    return component;
177
  }
178
 
179
  /**
180
   * Sets the default actions.
181
   */
182
  public void setDefaultActions (int ops)
183
  {
184
    actions = ops;
185
  }
186
 
187
  /**
188
   * Returns the default actions.
189
   */
190
  public int getDefaultActions ()
191
  {
192
    return actions;
193
  }
194
 
195
  public void setActive (boolean active)
196
  {
197
    this.active = active;
198
  }
199
 
200
  public boolean isActive()
201
  {
202
    return active;
203
  }
204
 
205
  /**
206
   * Adds a new <code>DropTargetListener</code>.
207
   *
208
   * @exception TooManyListenersException Sun's JDK does not, despite
209
   * documentation, throw this exception here when you install an additional
210
   * <code>DropTargetListener</code>.  So to be compatible, we do the same
211
   * thing.
212
   */
213
  public void addDropTargetListener (DropTargetListener dtl)
214
    throws TooManyListenersException
215
  {
216
    dropTargetListener = dtl;
217
  }
218
 
219
  public void removeDropTargetListener(DropTargetListener dtl)
220
  {
221
    // FIXME: Do we need to do something with dtl ?
222
    dropTargetListener = null;
223
  }
224
 
225
  public void dragEnter(DropTargetDragEvent dtde)
226
  {
227
  }
228
 
229
  public void dragOver(DropTargetDragEvent dtde)
230
  {
231
  }
232
 
233
  public void dropActionChanged(DropTargetDragEvent dtde)
234
  {
235
  }
236
 
237
  public void dragExit(DropTargetEvent dte)
238
  {
239
  }
240
 
241
  public void drop(DropTargetDropEvent dtde)
242
  {
243
  }
244
 
245
  public FlavorMap getFlavorMap()
246
  {
247
    return flavorMap;
248
  }
249
 
250
  public void setFlavorMap(FlavorMap fm)
251
  {
252
    flavorMap = fm;
253
  }
254
 
255
  public void addNotify(java.awt.peer.ComponentPeer peer)
256
  {
257
  }
258
 
259
  public void removeNotify(java.awt.peer.ComponentPeer peer)
260
  {
261
  }
262
 
263
  public DropTargetContext getDropTargetContext()
264
  {
265
    if (dropTargetContext == null)
266
      dropTargetContext = createDropTargetContext ();
267
 
268
    return dropTargetContext;
269
  }
270
 
271
  protected DropTargetContext createDropTargetContext()
272
  {
273
    return new DropTargetContext (this);
274
  }
275
 
276
  protected DropTarget.DropTargetAutoScroller createDropTargetAutoScroller
277
                                                       (Component c, Point p)
278
  {
279
    return new DropTarget.DropTargetAutoScroller (c, p);
280
  }
281
 
282
  protected void initializeAutoscrolling(Point p)
283
  {
284
  }
285
 
286
  protected void updateAutoscroll(Point dragCursorLocn)
287
  {
288
  }
289
 
290
  protected void clearAutoscroll()
291
  {
292
  }
293
} // class DropTarget

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.