mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-4066: Drag and drop fix
This commit is contained in:
parent
f31445fd7f
commit
d5cc4050c7
6 changed files with 23 additions and 10 deletions
|
@ -78,19 +78,19 @@ public class DataTreeDragNDropHandler implements GTreeDragNDropHandler {
|
|||
DataFlavor[] transferDataFlavors = transferable.getTransferDataFlavors();
|
||||
for (DataFlavor dataFlavor : transferDataFlavors) {
|
||||
DataTreeFlavorHandler flavorHandler = getFlavorHandler(dataFlavor);
|
||||
if (flavorHandler != null) {
|
||||
handleDrop(destination, transferable, dropAction, dataFlavor, flavorHandler);
|
||||
if (flavorHandler != null &&
|
||||
handleDrop(destination, transferable, dropAction, dataFlavor, flavorHandler)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDrop(GTreeNode destination, Transferable transferable, int dropAction,
|
||||
private boolean handleDrop(GTreeNode destination, Transferable transferable, int dropAction,
|
||||
DataFlavor dataFlavor, DataTreeFlavorHandler flavorHandler) {
|
||||
|
||||
try {
|
||||
Object transferData = transferable.getTransferData(dataFlavor);
|
||||
flavorHandler.handle(tool, tree, destination, transferData, dropAction);
|
||||
return flavorHandler.handle(tool, tree, destination, transferData, dropAction);
|
||||
}
|
||||
catch (UnsupportedFlavorException e) {
|
||||
throw new AssertException("Got unsupported flavor from using a supported flavor");
|
||||
|
@ -98,6 +98,7 @@ public class DataTreeDragNDropHandler implements GTreeDragNDropHandler {
|
|||
catch (IOException e) {
|
||||
Msg.showError(this, null, "IO Error", "Error during drop", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private DataTreeFlavorHandler getFlavorHandler(DataFlavor flavor) {
|
||||
|
|
|
@ -22,6 +22,6 @@ import ghidra.framework.plugintool.PluginTool;
|
|||
* Interface for classes that will handle drop actions for {@link DataTree}s.
|
||||
*/
|
||||
public interface DataTreeFlavorHandler {
|
||||
public void handle(PluginTool tool, DataTree dataTree, GTreeNode destinationNode,
|
||||
public boolean handle(PluginTool tool, DataTree dataTree, GTreeNode destinationNode,
|
||||
Object transferData, int dropAction);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public final class LocalTreeNodeHandler
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handle(PluginTool tool, DataTree tree, GTreeNode destinationNode,
|
||||
public boolean handle(PluginTool tool, DataTree tree, GTreeNode destinationNode,
|
||||
Object transferData, int dropAction) {
|
||||
|
||||
this.dataTree = tree;
|
||||
|
@ -71,7 +71,7 @@ public final class LocalTreeNodeHandler
|
|||
|
||||
List<GTreeNode> list = (List<GTreeNode>) transferData;
|
||||
if (list.size() == 0) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
CopyAllTask task = new CopyAllTask(list, destinationNode, dropAction);
|
||||
|
@ -83,6 +83,8 @@ public final class LocalTreeNodeHandler
|
|||
dataTree.restoreTreeState(treeState);
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void add(GTreeNode destNode, GTreeNode draggedNode, int dropAction,
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class LocalVersionInfoHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(PluginTool tool, DataTree dataTree, GTreeNode destinationNode,
|
||||
public boolean handle(PluginTool tool, DataTree dataTree, GTreeNode destinationNode,
|
||||
Object transferData, int dropAction) {
|
||||
DomainFolder folder = getDomainFolder(destinationNode);
|
||||
|
||||
|
@ -65,6 +65,7 @@ public final class LocalVersionInfoHandler
|
|||
if (file != null) {
|
||||
new TaskLauncher(new CopyFileVersionTask(file, info.getVersionNumber(), folder),
|
||||
dataTree, 500);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NotConnectedException exc) {
|
||||
|
@ -73,6 +74,7 @@ public final class LocalVersionInfoHandler
|
|||
catch (IOException exc) {
|
||||
ClientUtil.handleException(rep, exc, "Repository Connection", tool.getToolFrame());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private DomainFolder getDomainFolder(GTreeNode destinationNode) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue