Lines 10-18
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.ui.navigator; |
11 |
package org.eclipse.ui.navigator; |
12 |
|
12 |
|
|
|
13 |
import org.eclipse.core.runtime.IStatus; |
14 |
import org.eclipse.core.runtime.Status; |
13 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
15 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
|
|
16 |
import org.eclipse.jface.viewers.IStructuredSelection; |
14 |
import org.eclipse.swt.dnd.DropTargetEvent; |
17 |
import org.eclipse.swt.dnd.DropTargetEvent; |
15 |
import org.eclipse.swt.dnd.TransferData; |
18 |
import org.eclipse.swt.dnd.TransferData; |
|
|
19 |
import org.eclipse.swt.widgets.Shell; |
20 |
import org.eclipse.ui.internal.navigator.NavigatorContentService; |
16 |
import org.eclipse.ui.part.PluginTransfer; |
21 |
import org.eclipse.ui.part.PluginTransfer; |
17 |
|
22 |
|
18 |
/** |
23 |
/** |
Lines 29-39
Link Here
|
29 |
* Whenever a match is found, the assistant will be given an opportunity to |
34 |
* Whenever a match is found, the assistant will be given an opportunity to |
30 |
* first {@link #validateDrop(Object, int, TransferData) }, and then if the |
35 |
* first {@link #validateDrop(Object, int, TransferData) }, and then if the |
31 |
* assistant returns true, the assist must |
36 |
* assistant returns true, the assist must |
32 |
* {@link #handleDrop(DropTargetEvent, Object) }. If multiple assistants match |
37 |
* {@link #handleDrop(CommonDropAdapter, DropTargetEvent, Object) }. If |
33 |
* the drop target, then the potential assistants are ordered based on priority |
38 |
* multiple assistants match the drop target, then the potential assistants are |
34 |
* and their override relationships and given an opportunity to validate the |
39 |
* ordered based on priority and their override relationships and given an |
35 |
* drop operation in turn. The first one to validate will have the opportunty to |
40 |
* opportunity to validate the drop operation in turn. The first one to validate |
36 |
* carry out the drop. |
41 |
* will have the opportunty to carry out the drop. |
37 |
* </p> |
42 |
* </p> |
38 |
* <p> |
43 |
* <p> |
39 |
* That is, if a content extension X overrides content extension Y (see |
44 |
* That is, if a content extension X overrides content extension Y (see |
Lines 42-47
Link Here
|
42 |
* than Y, then X will have an opportunity before Y, and Y will have an |
47 |
* than Y, then X will have an opportunity before Y, and Y will have an |
43 |
* opportunity before Z. |
48 |
* opportunity before Z. |
44 |
* </p> |
49 |
* </p> |
|
|
50 |
* |
51 |
* <p> |
52 |
* Clients may handle DND operations that begin and end in the current viewer by |
53 |
* overriding the following methods: |
54 |
* <ul> |
55 |
* <li>{@link #validateDrop(Object, int, TransferData)}: Indicate whether this |
56 |
* assistant can handle a drop onto the current viewer.</li> |
57 |
* <li>{@link #handleDrop(CommonDropAdapter, DropTargetEvent, Object)}: Handle |
58 |
* the drop operation onto the current viewer.</li> |
59 |
* </ul> |
60 |
* </p> |
61 |
* <p> |
62 |
* If a user originates a drag operation to another viewer that cannot handle |
63 |
* one of the available drag transfer types, drop assistants may handle the drop |
64 |
* operation for the target viewer. Clients must override : |
65 |
* <ul> |
66 |
* <li>{@link #validatePluginTransferDrop(IStructuredSelection, Object)}: |
67 |
* Indicate whether this assistant can handle the drop onto another viewer. |
68 |
* <li>{@link #handlePluginTransferDrop(IStructuredSelection, Object)}: Handle |
69 |
* the drop operation onto the other viewer.</li> |
70 |
* </ul> |
71 |
* </p> |
45 |
* <p> |
72 |
* <p> |
46 |
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as |
73 |
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as |
47 |
* part of a work in progress. There is a guarantee neither that this API will |
74 |
* part of a work in progress. There is a guarantee neither that this API will |
Lines 53-59
Link Here
|
53 |
* </p> |
80 |
* </p> |
54 |
* |
81 |
* |
55 |
* @see INavigatorDnDService |
82 |
* @see INavigatorDnDService |
56 |
* @see INavigatorDnDService#findCommonDropAdapterAssistants(Object) |
83 |
* @see INavigatorDnDService#findCommonDropAdapterAssistants(Object, |
|
|
84 |
* TransferData) |
57 |
* @since 3.2 |
85 |
* @since 3.2 |
58 |
* |
86 |
* |
59 |
*/ |
87 |
*/ |
Lines 76-82
Link Here
|
76 |
} |
104 |
} |
77 |
|
105 |
|
78 |
/** |
106 |
/** |
79 |
* Override to perform any one-time intialization. |
107 |
* Override to perform any one-time initialization. |
80 |
*/ |
108 |
*/ |
81 |
protected void doInit() { |
109 |
protected void doInit() { |
82 |
|
110 |
|
Lines 88-94
Link Here
|
88 |
* <p> |
116 |
* <p> |
89 |
* Subclasses must implement this method to define which drops make sense. |
117 |
* Subclasses must implement this method to define which drops make sense. |
90 |
* If clients return true, then they will be allowed to handle the drop in |
118 |
* If clients return true, then they will be allowed to handle the drop in |
91 |
* {@link #handleDrop(DropTargetEvent, Object) }. |
119 |
* {@link #handleDrop(CommonDropAdapter, DropTargetEvent, Object) }. |
92 |
* </p> |
120 |
* </p> |
93 |
* |
121 |
* |
94 |
* @param target |
122 |
* @param target |
Lines 98-138
Link Here
|
98 |
* the current drag operation (copy, move, etc.) |
126 |
* the current drag operation (copy, move, etc.) |
99 |
* @param transferType |
127 |
* @param transferType |
100 |
* the current transfer type |
128 |
* the current transfer type |
101 |
* @return <code>true</code> if the drop is valid, and <code>false</code> |
129 |
* @return A status indicating whether the drop is valid. |
102 |
* otherwise |
|
|
103 |
*/ |
130 |
*/ |
104 |
public abstract boolean validateDrop(Object target, int operation, |
131 |
public abstract IStatus validateDrop(Object target, int operation, |
105 |
TransferData transferType); |
132 |
TransferData transferType); |
106 |
|
133 |
|
107 |
/** |
134 |
/** |
108 |
* Carry out the DND operation |
135 |
* Carry out the DND operation. |
109 |
* |
136 |
* |
|
|
137 |
* @param aDropAdapter |
138 |
* The Drop Adapter contains information that has already been |
139 |
* parsed from the drop event. |
110 |
* @param aDropTargetEvent |
140 |
* @param aDropTargetEvent |
111 |
* The drop target event. |
141 |
* The drop target event. |
112 |
* @param aTarget |
142 |
* @param aTarget |
113 |
* The object being dragged onto |
143 |
* The object being dragged onto |
114 |
* @return True if the operation completed. |
144 |
* @return A status indicating whether the drop completed OK. |
115 |
*/ |
145 |
*/ |
116 |
public abstract boolean handleDrop(DropTargetEvent aDropTargetEvent, |
146 |
public abstract IStatus handleDrop(CommonDropAdapter aDropAdapter, |
117 |
Object aTarget); |
147 |
DropTargetEvent aDropTargetEvent, Object aTarget); |
|
|
148 |
|
149 |
/** |
150 |
* Clients may extend the supported transfer types beyond the default |
151 |
* {@link LocalSelectionTransfer#getTransfer()} and |
152 |
* {@link PluginTransfer#getInstance()} transfer types. When a transfer type |
153 |
* other than one of these is encountered, the DND Service will query the |
154 |
* <b>visible</b> and <b>active</b> descriptors that are <b>enabled</b> |
155 |
* for the drop target of the current operation. |
156 |
* |
157 |
* @param aTransferType |
158 |
* The transfer data from the drop operation |
159 |
* @return True if the given TransferData can be understood by this |
160 |
* assistant. |
161 |
*/ |
162 |
public boolean isSupportedType(TransferData aTransferType) { |
163 |
return LocalSelectionTransfer.getTransfer().isSupportedType( |
164 |
aTransferType); |
165 |
} |
118 |
|
166 |
|
119 |
/** |
167 |
/** |
120 |
* When a drop opportunity presents itself, the available TransferData types |
|
|
121 |
* will be supplied in the event. The DropAdapter must select one of these |
122 |
* TransferData types for the DragAdapter to provide. By default the Common |
123 |
* Navigator supports {@link LocalSelectionTransfer} and |
124 |
* {@link PluginTransfer}. Clients are required to indicate if they support |
125 |
* other TransferData types using this method. |
126 |
* |
168 |
* |
|
|
169 |
* Return true if the client can handle the drop onto the target viewer of |
170 |
* the drop operation. |
127 |
* <p> |
171 |
* <p> |
128 |
* If none of the given TransferData types are supported, return null. |
172 |
* The default behavior of this method is to return <b>Status.CANCEL_STATUS</b>. |
129 |
* </p> |
173 |
* </p> |
130 |
* |
174 |
* |
131 |
* @param theAvailableTransferData |
175 |
* @param aDragSelection |
132 |
* @return The supported TransferData from the set. |
176 |
* The selection dragged from the viewer. |
133 |
*/ |
177 |
* @param aDropTarget |
134 |
public abstract TransferData findSupportedTransferData( |
178 |
* The target of the drop operation. |
135 |
TransferData[] theAvailableTransferData); |
179 |
* |
|
|
180 |
* @return OK if the plugin transfer can be handled by this assistant. |
181 |
*/ |
182 |
public IStatus validatePluginTransferDrop( |
183 |
IStructuredSelection aDragSelection, Object aDropTarget) { |
184 |
return Status.CANCEL_STATUS; |
185 |
} |
186 |
|
187 |
/** |
188 |
* Handle the drop operation for the target viewer. |
189 |
* <p> |
190 |
* The default behavior of this method is to return <b>Status.CANCEL_STATUS</b>. |
191 |
* </p> |
192 |
* |
193 |
* @param aDragSelection |
194 |
* The selection dragged from the viewer. |
195 |
* @param aDropTarget |
196 |
* The target of the drop operation. |
197 |
* |
198 |
* @return OK if the drop operation succeeded. |
199 |
*/ |
200 |
public IStatus handlePluginTransferDrop( |
201 |
IStructuredSelection aDragSelection, Object aDropTarget) { |
202 |
return Status.CANCEL_STATUS; |
203 |
} |
136 |
|
204 |
|
137 |
/** |
205 |
/** |
138 |
* |
206 |
* |
Lines 142-145
Link Here
|
142 |
return contentService; |
210 |
return contentService; |
143 |
} |
211 |
} |
144 |
|
212 |
|
|
|
213 |
/** |
214 |
* |
215 |
* @return A shell for the viewer currently used by the |
216 |
* {@link INavigatorContentService}. |
217 |
*/ |
218 |
protected final Shell getShell() { |
219 |
return ((NavigatorContentService) contentService).getShell(); |
220 |
} |
221 |
|
145 |
} |
222 |
} |