1:
37:
38: package ;
39:
40: import ;
41:
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50:
51:
55: public class DropTargetContext implements Serializable
56: {
57: static final long serialVersionUID = -634158968993743371L;
58:
59: protected class TransferableProxy implements Transferable
60: {
61: protected boolean isLocal;
62: protected Transferable transferable;
63:
64: TransferableProxy(Transferable t, boolean local)
65: {
66: this.transferable = t;
67: this.isLocal = local;
68: }
69:
70: public DataFlavor[] getTransferDataFlavors()
71: {
72: return transferable.getTransferDataFlavors();
73: }
74:
75: public boolean isDataFlavorSupported(DataFlavor flavor)
76: {
77: return transferable.isDataFlavorSupported(flavor);
78: }
79:
80: public Object getTransferData(DataFlavor flavor)
81: throws UnsupportedFlavorException, IOException
82: {
83: return transferable.getTransferData (flavor);
84: }
85: }
86:
87: private DropTarget dropTarget;
88: private int targetActions;
89: private java.awt.dnd.peer.DropTargetContextPeer dtcp;
90:
91:
92: DropTargetContext(DropTarget dropTarget)
93: {
94: this.dropTarget = dropTarget;
95: }
96:
97: public DropTarget getDropTarget()
98: {
99: return dropTarget;
100: }
101:
102: public Component getComponent()
103: {
104: return dropTarget.getComponent();
105: }
106:
107: public void addNotify(java.awt.dnd.peer.DropTargetContextPeer dtcp)
108: {
109: this.dtcp = dtcp;
110: }
111:
112: public void removeNotify()
113: {
114: this.dtcp = null;
115: }
116:
117: protected void setTargetActions(int actions)
118: {
119: targetActions = actions;
120: }
121:
122: protected int getTargetActions()
123: {
124: return targetActions;
125: }
126:
127:
132: public void dropComplete(boolean success)
133: throws NotImplementedException
134: {
135:
136: }
137:
138: protected void acceptDrag(int dragOperation)
139: throws NotImplementedException
140: {
141:
142: }
143:
144: protected void rejectDrag()
145: throws NotImplementedException
146: {
147:
148: }
149:
150: protected void acceptDrop(int dropOperation)
151: throws NotImplementedException
152: {
153:
154: }
155:
156: protected void rejectDrop()
157: throws NotImplementedException
158: {
159:
160: }
161:
162: protected DataFlavor[] getCurrentDataFlavors()
163: throws NotImplementedException
164: {
165:
166: return null;
167: }
168:
169: protected List getCurrentDataFlavorsAsList()
170: {
171: return Arrays.asList(getCurrentDataFlavors());
172: }
173:
174: protected boolean isDataFlavorSupported(DataFlavor flavor)
175: {
176: return getCurrentDataFlavorsAsList().contains(flavor);
177: }
178:
179:
184: protected Transferable getTransferable()
185: throws InvalidDnDOperationException, NotImplementedException
186: {
187:
188: return null;
189: }
190:
191: protected Transferable createTransferableProxy(Transferable t, boolean local)
192: {
193: return new TransferableProxy(t, local);
194: }
195: }