Source Code Cross Referenced for DropTargetDropEvent.java in  » 6.0-JDK-Core » AWT » java » awt » dnd » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.dnd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1997-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.awt.dnd;
027
028        import java.awt.Point;
029
030        import java.awt.datatransfer.DataFlavor;
031        import java.awt.datatransfer.Transferable;
032
033        import java.util.List;
034
035        /**
036         * The <code>DropTargetDropEvent</code> is delivered 
037         * via the <code>DropTargetListener</code> drop() method. 
038         * <p>
039         * The <code>DropTargetDropEvent</code> reports the <i>source drop actions</i>
040         * and the <i>user drop action</i> that reflect the current state of the
041         * drag-and-drop operation. 
042         * <p>
043         * <i>Source drop actions</i> is a bitwise mask of <code>DnDConstants</code>
044         * that represents the set of drop actions supported by the drag source for 
045         * this drag-and-drop operation.
046         * <p>
047         * <i>User drop action</i> depends on the drop actions supported by the drag
048         * source and the drop action selected by the user. The user can select a drop
049         * action by pressing modifier keys during the drag operation: 
050         * <pre> 
051         *   Ctrl + Shift -> ACTION_LINK
052         *   Ctrl         -> ACTION_COPY
053         *   Shift        -> ACTION_MOVE
054         * </pre> 
055         * If the user selects a drop action, the <i>user drop action</i> is one of 
056         * <code>DnDConstants</code> that represents the selected drop action if this
057         * drop action is supported by the drag source or
058         * <code>DnDConstants.ACTION_NONE</code> if this drop action is not supported 
059         * by the drag source.
060         * <p>
061         * If the user doesn't select a drop action, the set of
062         * <code>DnDConstants</code> that represents the set of drop actions supported
063         * by the drag source is searched for <code>DnDConstants.ACTION_MOVE</code>,
064         * then for <code>DnDConstants.ACTION_COPY</code>, then for
065         * <code>DnDConstants.ACTION_LINK</code> and the <i>user drop action</i> is the
066         * first constant found. If no constant is found the <i>user drop action</i>
067         * is <code>DnDConstants.ACTION_NONE</code>.
068         * 
069         * @version 	1.35, 05/05/07
070         * @since 1.2
071         */
072
073        public class DropTargetDropEvent extends DropTargetEvent {
074
075            private static final long serialVersionUID = -1721911170440459322L;
076
077            /**
078             * Construct a <code>DropTargetDropEvent</code> given
079             * the <code>DropTargetContext</code> for this operation, 
080             * the location of the drag <code>Cursor</code>'s
081             * hotspot in the <code>Component</code>'s coordinates, 
082             * the currently
083             * selected user drop action, and the current set of
084             * actions supported by the source.
085             * By default, this constructor 
086             * assumes that the target is not in the same virtual machine as 
087             * the source; that is, {@link #isLocalTransfer()} will 
088             * return <code>false</code>.
089             * <P>
090             * @param dtc        The <code>DropTargetContext</code> for this operation
091             * @param cursorLocn The location of the "Drag" Cursor's 
092             * hotspot in <code>Component</code> coordinates
093             * @param dropAction the user drop action.
094             * @param srcActions the source drop actions.
095             * 
096             * @throws <code>NullPointerException</code> 
097             * if cursorLocn is <code>null</code>
098             * @throws <code>IllegalArgumentException</code> if dropAction is not one of
099             *         <code>DnDConstants</code>.
100             * @throws <code>IllegalArgumentException</code> if srcActions is not
101             *         a bitwise mask of <code>DnDConstants</code>.
102             * @throws <code>IllegalArgumentException</code> if dtc is <code>null</code>.
103             */
104
105            public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn,
106                    int dropAction, int srcActions) {
107                super (dtc);
108
109                if (cursorLocn == null)
110                    throw new NullPointerException("cursorLocn");
111
112                if (dropAction != DnDConstants.ACTION_NONE
113                        && dropAction != DnDConstants.ACTION_COPY
114                        && dropAction != DnDConstants.ACTION_MOVE
115                        && dropAction != DnDConstants.ACTION_LINK)
116                    throw new IllegalArgumentException("dropAction = "
117                            + dropAction);
118
119                if ((srcActions & ~(DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK)) != 0)
120                    throw new IllegalArgumentException("srcActions");
121
122                location = cursorLocn;
123                actions = srcActions;
124                this .dropAction = dropAction;
125            }
126
127            /**
128             * Construct a <code>DropTargetEvent</code> given the 
129             * <code>DropTargetContext</code> for this operation,
130             * the location of the drag <code>Cursor</code>'s hotspot 
131             * in the <code>Component</code>'s 
132             * coordinates, the currently selected user drop action, 
133             * the current set of actions supported by the source,
134             * and a <code>boolean</code> indicating if the source is in the same JVM
135             * as the target.
136             * <P>
137             * @param dtc        The DropTargetContext for this operation
138             * @param cursorLocn The location of the "Drag" Cursor's 
139             * hotspot in Component's coordinates
140             * @param dropAction the user drop action.
141             * @param srcActions the source drop actions.
142             * @param isLocal  True if the source is in the same JVM as the target
143             *
144             * @throws <code>NullPointerException</code> if cursorLocn is
145             *         <code>null</code> 
146             * @throws <code>IllegalArgumentException</code> if dropAction is not one of
147             *         <code>DnDConstants</code>.
148             * @throws <code>IllegalArgumentException</code> if srcActions is not
149             *         a bitwise mask of <code>DnDConstants</code>.
150             * @throws <code>IllegalArgumentException</code> if dtc is <code>null</code>.
151             */
152
153            public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn,
154                    int dropAction, int srcActions, boolean isLocal) {
155                this (dtc, cursorLocn, dropAction, srcActions);
156
157                isLocalTx = isLocal;
158            }
159
160            /**
161             * This method returns a <code>Point</code>
162             * indicating the <code>Cursor</code>'s current
163             * location in the <code>Component</code>'s coordinates.
164             * <P>
165             * @return the current <code>Cursor</code> location in Component's coords.
166             */
167
168            public Point getLocation() {
169                return location;
170            }
171
172            /**
173             * This method returns the current DataFlavors.
174             * <P>
175             * @return current DataFlavors
176             */
177
178            public DataFlavor[] getCurrentDataFlavors() {
179                return getDropTargetContext().getCurrentDataFlavors();
180            }
181
182            /**
183             * This method returns the currently available
184             * <code>DataFlavor</code>s as a <code>java.util.List</code>.
185             * <P>
186             * @return the currently available DataFlavors as a java.util.List
187             */
188
189            public List<DataFlavor> getCurrentDataFlavorsAsList() {
190                return getDropTargetContext().getCurrentDataFlavorsAsList();
191            }
192
193            /**
194             * This method returns a <code>boolean</code> indicating if the
195             * specified <code>DataFlavor</code> is available
196             * from the source.
197             * <P>
198             * @param df the <code>DataFlavor</code> to test
199             * <P>
200             * @return if the DataFlavor specified is available from the source
201             */
202
203            public boolean isDataFlavorSupported(DataFlavor df) {
204                return getDropTargetContext().isDataFlavorSupported(df);
205            }
206
207            /**
208             * This method returns the source drop actions.
209             * 
210             * @return the source drop actions.
211             */
212            public int getSourceActions() {
213                return actions;
214            }
215
216            /**
217             * This method returns the user drop action.
218             * 
219             * @return the user drop actions.
220             */
221            public int getDropAction() {
222                return dropAction;
223            }
224
225            /**
226             * This method returns the <code>Transferable</code> object 
227             * associated with the drop.
228             * <P>
229             * @return the <code>Transferable</code> associated with the drop
230             */
231
232            public Transferable getTransferable() {
233                return getDropTargetContext().getTransferable();
234            }
235
236            /**
237             * accept the drop, using the specified action.
238             * <P>
239             * @param dropAction the specified action
240             */
241
242            public void acceptDrop(int dropAction) {
243                getDropTargetContext().acceptDrop(dropAction);
244            }
245
246            /**
247             * reject the Drop.
248             */
249
250            public void rejectDrop() {
251                getDropTargetContext().rejectDrop();
252            }
253
254            /**
255             * This method notifies the <code>DragSource</code> 
256             * that the drop transfer(s) are completed.
257             * <P>
258             * @param success a <code>boolean</code> indicating that the drop transfer(s) are completed.
259             */
260
261            public void dropComplete(boolean success) {
262                getDropTargetContext().dropComplete(success);
263            }
264
265            /**
266             * This method returns an <code>int</code> indicating if
267             * the source is in the same JVM as the target.
268             * <P>
269             * @return if the Source is in the same JVM
270             */
271
272            public boolean isLocalTransfer() {
273                return isLocalTx;
274            }
275
276            /*
277             * fields
278             */
279
280            static final private Point zero = new Point(0, 0);
281
282            /**
283             * The location of the drag cursor's hotspot in Component coordinates.
284             *
285             * @serial
286             */
287            private Point location = zero;
288
289            /**
290             * The source drop actions.
291             *
292             * @serial
293             */
294            private int actions = DnDConstants.ACTION_NONE;
295
296            /**
297             * The user drop action.
298             *
299             * @serial
300             */
301            private int dropAction = DnDConstants.ACTION_NONE;
302
303            /**
304             * <code>true</code> if the source is in the same JVM as the target.
305             *
306             * @serial
307             */
308            private boolean isLocalTx = false;
309        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.