GT-3461 - fix for recent drag-n-drop break

This commit is contained in:
dragonmacher 2020-01-15 18:06:44 -05:00
parent cf0c434d51
commit 638befbfd1
3 changed files with 19 additions and 18 deletions

View File

@ -155,10 +155,6 @@ public class DataTypeManagerPlugin extends ProgramPlugin
editorManager = new DataTypeEditorManager(this);
CodeViewerService codeViewerService = tool.getService(CodeViewerService.class);
if (codeViewerService != null) {
codeViewerService.addProgramDropProvider(new DataDropOnBrowserHandler(this));
}
tool.addPopupActionProvider(this);
tool.setMenuGroup(new String[] { SyncRefreshAction.MENU_NAME }, "SYNC");
tool.setMenuGroup(new String[] { UpdateAction.MENU_NAME }, "SYNC");

View File

@ -21,22 +21,25 @@ public class GhidraDataFlavorHandlerService {
public GhidraDataFlavorHandlerService() {
try {
DataFlavor linuxFileUrlFlavor =
new DataFlavor("application/x-java-serialized-object;class=java.lang.String");
DataTreeDragNDropHandler.addActiveDataFlavorHandler(linuxFileUrlFlavor,
new LinuxFileUrlHandler());
}
catch (ClassNotFoundException cnfe) {
// should never happen as it is using java.lang.String
}
//
// Note: the order of the file drop flavors/handlers is intentional. We wish to process
// objects first which we know to be transfered from within the current JVM. After
// that, then process objects given to us from the OS or another JVM.
//
LocalTreeNodeHandler localNodeHandler = new LocalTreeNodeHandler();
DataTreeDragNDropHandler.addActiveDataFlavorHandler(
DataTreeDragNDropHandler.localDomainFileTreeFlavor, localNodeHandler);
DataTreeDragNDropHandler.addActiveDataFlavorHandler(DataFlavor.javaFileListFlavor,
new JavaFileListHandler());
DataTreeDragNDropHandler.addActiveDataFlavorHandler(
VersionInfoTransferable.localVersionInfoFlavor, new LocalVersionInfoHandler());
DataTreeDragNDropHandler.addActiveDataFlavorHandler(DataFlavor.javaFileListFlavor,
new JavaFileListHandler());
DataFlavor linuxFileUrlFlavor =
new DataFlavor("application/x-java-serialized-object;class=java.lang.String",
"String file URL");
DataTreeDragNDropHandler.addActiveDataFlavorHandler(linuxFileUrlFlavor,
new LinuxFileUrlHandler());
}
}

View File

@ -21,7 +21,7 @@ import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.*;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;
import javax.swing.CellRendererPane;
@ -40,8 +40,10 @@ import ghidra.util.CascadedDropTarget;
* in order to properly support drag/drop with all components.
*/
public class FileOpenDropHandler implements DropTargetHandler, Droppable, ContainerListener {
private static HashMap<DataFlavor, FileOpenDataFlavorHandler> handlers =
new HashMap<DataFlavor, FileOpenDataFlavorHandler>();
// note: we wish to maintain insertion order
private static LinkedHashMap<DataFlavor, FileOpenDataFlavorHandler> handlers =
new LinkedHashMap<DataFlavor, FileOpenDataFlavorHandler>();
private DropTgtAdapter dropTargetAdapter;
private DropTarget globalDropTarget;