### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.navigator Index: src/org/eclipse/ui/navigator/INavigatorDnDService.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/INavigatorDnDService.java,v retrieving revision 1.3 diff -u -r1.3 INavigatorDnDService.java --- src/org/eclipse/ui/navigator/INavigatorDnDService.java 22 Feb 2006 20:39:48 -0000 1.3 +++ src/org/eclipse/ui/navigator/INavigatorDnDService.java 24 Feb 2006 04:44:38 -0000 @@ -14,7 +14,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.dnd.TransferData; - /** * * Provides instances of {@link CommonDragAdapterAssistant} and @@ -31,7 +30,7 @@ * *

* This interface is not intended to be implemented by clients. - *

+ *

* * @see CommonDragAdapter * @see CommonDragAdapterAssistant @@ -59,19 +58,29 @@ * viewer using the dragAssistant element. This element defines a * class which extends {@link CommonDragAdapterAssistant} and can direct the * viewer on how to provide different kinds of DND Transfer Types. The array - * is returned in no particular order. + * is returned in no particular order. * * @return An array of {@link CommonDragAdapterAssistant} or an empty array. */ CommonDragAdapterAssistant[] getCommonDragAssistants(); /** + * Clients may choose to programmatically bind drag assistants to an + * instance of the DND Service. A programmatic binding is not persisted + * between sessions and is not propagated to other instances of + * {@link INavigatorContentService} with the same id. + * + * @param anAssistant The assistant to bind. + */ + void bindDragAssistant(CommonDragAdapterAssistant anAssistant); + + /** * * This method returns an array of {@link CommonDropAdapterAssistant} from * content extensions that are visible and active for the * associated {@link INavigatorContentService}. The array is sorted by * priority, with overrides taken into account. - * + * *

* The array should be processed from the first element to the last, asking * each extension to @@ -83,8 +92,8 @@ * * @param aDropTarget * The target element in the viewer of the drop operation. - * @param theTransferType - * The transfer type of the current drop operation. + * @param theTransferType + * The transfer type of the current drop operation. * @return An array of {@link CommonDropAdapterAssistant}s that are defined * by the set of * org.eclipse.ui.navigator.navigatorContent/navigatorContent @@ -93,13 +102,13 @@ */ CommonDropAdapterAssistant[] findCommonDropAdapterAssistants( Object aDropTarget, TransferData theTransferType); - + /** * * This method returns an array of {@link CommonDropAdapterAssistant} from * content extensions that are visible and active for the - * associated {@link INavigatorContentService}. - * + * associated {@link INavigatorContentService}. + * *

* The array should be processed from the first element to the last, asking * each extension to @@ -111,8 +120,8 @@ * * @param aDropTarget * The target element in the viewer of the drop operation. - * @param theDragSelection - * The drag selection of the current drop operation. + * @param theDragSelection + * The drag selection of the current drop operation. * @return An array of {@link CommonDropAdapterAssistant}s that are defined * by the set of * org.eclipse.ui.navigator.navigatorContent/navigatorContent Index: src/org/eclipse/ui/internal/navigator/dnd/NavigatorDnDService.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/dnd/NavigatorDnDService.java,v retrieving revision 1.2 diff -u -r1.2 NavigatorDnDService.java --- src/org/eclipse/ui/internal/navigator/dnd/NavigatorDnDService.java 22 Feb 2006 17:11:25 -0000 1.2 +++ src/org/eclipse/ui/internal/navigator/dnd/NavigatorDnDService.java 24 Feb 2006 04:44:36 -0000 @@ -62,20 +62,33 @@ public synchronized CommonDragAdapterAssistant[] getCommonDragAssistants() { - if (dragAssistants == null) { - int i = 0; - Set dragDescriptors = ((NavigatorViewerDescriptor) contentService - .getViewerDescriptor()).getDragAssistants(); - dragAssistants = new CommonDragAdapterAssistant[dragDescriptors - .size()]; - for (Iterator iter = dragDescriptors.iterator(); iter.hasNext();) { - CommonDragAssistantDescriptor descriptor = (CommonDragAssistantDescriptor) iter - .next(); - dragAssistants[i++] = descriptor.createDragAssistant(); - } - } + if (dragAssistants == null) + initializeDragAssistants(); return dragAssistants; } + + private void initializeDragAssistants() { + int i = 0; + Set dragDescriptors = ((NavigatorViewerDescriptor) contentService + .getViewerDescriptor()).getDragAssistants(); + dragAssistants = new CommonDragAdapterAssistant[dragDescriptors + .size()]; + for (Iterator iter = dragDescriptors.iterator(); iter.hasNext();) { + CommonDragAssistantDescriptor descriptor = (CommonDragAssistantDescriptor) iter + .next(); + dragAssistants[i++] = descriptor.createDragAssistant(); + } + } + + + public synchronized void bindDragAssistant(CommonDragAdapterAssistant anAssistant) { + if(dragAssistants == null) + initializeDragAssistants(); + CommonDragAdapterAssistant[] newDragAssistants = new CommonDragAdapterAssistant[dragAssistants.length + 1]; + System.arraycopy(dragAssistants, 0, newDragAssistants, 0, dragAssistants.length); + newDragAssistants[dragAssistants.length] = anAssistant; + dragAssistants = newDragAssistants; + } public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants( Object aDropTarget, TransferData aTransferType) {