This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | ExternalDropHandler instances registered at the global lookup are ignored. | ||
---|---|---|---|
Product: | platform | Reporter: | tschlegl <tschlegl> |
Component: | Window System | Assignee: | Stanislav Aubrecht <saubrecht> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | elena_regs |
Priority: | P3 | ||
Version: | 7.0 | ||
Hardware: | PC | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
tschlegl
2011-04-08 10:30:06 UTC
I've seen that I can influence the order of the instances delivered from the lookup which helps a lot. But I haven't found a way to get all my registered handlers called when performing a mouse drop. If the code in question is in core.windows/src/org/netbeans/core/windows/view/EditorView.java then the proper component is Window System. Btw. consider donating patch with test. reporter, is this the behavior you're looking for? # This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -237,24 +237,27 @@ public void dragExit(DropTargetEvent dte) { } public void dragOver(DropTargetDragEvent dtde) { - ExternalDropHandler handler = (ExternalDropHandler)Lookup.getDefault().lookup( ExternalDropHandler.class ); + for( ExternalDropHandler handler : Lookup.getDefault().lookupAll( ExternalDropHandler.class ) ) { //check if a file is being dragged over and if anybody can process it - if( null != handler && handler.canDrop( dtde ) ) { + if( handler.canDrop( dtde ) ) { dtde.acceptDrag( DnDConstants.ACTION_COPY ); - } else { - dtde.rejectDrag(); + return; } } + dtde.rejectDrag(); + } public void drop(DropTargetDropEvent dtde) { boolean dropRes = false; try { - ExternalDropHandler handler = (ExternalDropHandler)Lookup.getDefault().lookup( ExternalDropHandler.class ); + for( ExternalDropHandler handler : Lookup.getDefault().lookupAll( ExternalDropHandler.class ) ) { if( handler.canDrop( dtde ) ) { //file is being dragged over dtde.acceptDrop( DnDConstants.ACTION_COPY ); //let the handler to take care of it dropRes = handler.handleDrop( dtde ); + break; } + } } finally { dtde.dropComplete( dropRes ); } I'm not completely sure what the patched code will look like but I'm thinking it is working, as it's the best solution to pass the DropTargetDropEvent only to the first handler that canDrop it. As i remember correctly the collection returned by the the lookupAll() call is implemented as a List so the handlers asked in the dragOver() and the drop() methods are always in the same order. Thank you, Tobias core-main d91dcdf2705e Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/d91dcdf2705e User: S. Aubrecht <saubrecht@netbeans.org> Log: #197559 - check all ExternalDropHandlers registered in the global Lookup *** Bug 201814 has been marked as a duplicate of this bug. *** |