2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / awt / dnd / DropTargetContext.java
blob4301fbccc85642cd29cb6325f179e7af4de3e3ce
1 /* DropTargetContext.java --
2 Copyright (C) 2002, 2003 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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 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. */
38 package java.awt.dnd;
40 import java.awt.dnd.peer.DropTargetContextPeer;
41 import java.io.Serializable;
42 import java.io.IOException;
43 import java.awt.Component;
44 import java.awt.datatransfer.DataFlavor;
45 import java.awt.datatransfer.Transferable;
46 import java.awt.datatransfer.UnsupportedFlavorException;
47 import java.util.Arrays;
48 import java.util.List;
50 /**
51 * @author Michael Koch <konqueror@gmx.de>
52 * @since 1.2
54 public class DropTargetContext implements Serializable
56 static final long serialVersionUID = -634158968993743371L;
58 /** @specnote According to the online documentation, this is
59 * protected, but in reality it is public. */
60 public class TransferableProxy implements Transferable
62 protected boolean isLocal;
63 protected Transferable transferable;
65 TransferableProxy (Transferable t, boolean local)
67 this.transferable = t;
68 this.isLocal = local;
71 public DataFlavor[] getTransferDataFlavors ()
73 return transferable.getTransferDataFlavors ();
76 public boolean isDataFlavorSupported (DataFlavor flavor)
78 return transferable.isDataFlavorSupported (flavor);
81 public Object getTransferData (DataFlavor flavor)
82 throws UnsupportedFlavorException, IOException
84 return transferable.getTransferData (flavor);
88 private DropTarget dropTarget;
89 private int targetActions;
90 private java.awt.dnd.peer.DropTargetContextPeer dtcp;
92 // package private
93 DropTargetContext (DropTarget dropTarget)
95 this.dropTarget = dropTarget;
98 public DropTarget getDropTarget ()
100 return dropTarget;
103 public Component getComponent ()
105 return dropTarget.getComponent ();
108 public void addNotify (java.awt.dnd.peer.DropTargetContextPeer dtcp)
110 this.dtcp = dtcp;
113 public void removeNotify ()
115 this.dtcp = null;
118 protected void setTargetActions (int actions)
120 targetActions = actions;
123 protected int getTargetActions()
125 return targetActions;
129 * Signals that the drop is completed.
131 * @exception InvalidDnDOperationException If a drop is not outstanding.
133 public void dropComplete (boolean success)
135 // FIXME: implement this
138 protected void acceptDrag (int dragOperation)
140 // FIXME: implement this
143 protected void rejectDrag ()
145 // FIXME: implement this
148 protected void acceptDrop (int dropOperation)
150 // FIXME: implement this
153 protected void rejectDrop ()
155 // FIXME: implement this
158 protected DataFlavor[] getCurrentDataFlavors ()
160 // FIXME: implement this
161 return null;
164 protected List getCurrentDataFlavorsAsList ()
166 return Arrays.asList (getCurrentDataFlavors ());
169 protected boolean isDataFlavorSupported (DataFlavor flavor)
171 return getCurrentDataFlavorsAsList ().contains (flavor);
175 * Return the <code>Transferable</code> operandof this operation.
177 * @exception InvalidDnDOperationException If a drag is not outstanding.
179 protected Transferable getTransferable() throws InvalidDnDOperationException
181 // FIXME: implement this
182 return null;
185 protected Transferable createTransferableProxy(Transferable t, boolean local)
187 return new TransferableProxy (t, local);
189 } // class DropTargetContext