mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GT-3472 - Fixed action enablement on BuiltIn archive node; fixed
spelling issue
This commit is contained in:
parent
13caf91a21
commit
163881be29
6 changed files with 42 additions and 50 deletions
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,14 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.datamgr.actions;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.archive.Archive;
|
||||
import ghidra.app.plugin.core.datamgr.tree.*;
|
||||
import ghidra.program.model.data.Category;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.util.InvalidNameException;
|
||||
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.ActionContext;
|
||||
|
@ -31,6 +22,13 @@ import docking.action.DockingAction;
|
|||
import docking.action.MenuData;
|
||||
import docking.widgets.tree.GTree;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.archive.Archive;
|
||||
import ghidra.app.plugin.core.datamgr.tree.*;
|
||||
import ghidra.program.model.data.Category;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.util.InvalidNameException;
|
||||
|
||||
public class CreateCategoryAction extends DockingAction {
|
||||
|
||||
|
@ -47,10 +45,12 @@ public class CreateCategoryAction extends DockingAction {
|
|||
@Override
|
||||
public boolean isAddToPopup(ActionContext context) {
|
||||
CategoryNode categoryNode = getSelectedCategoryNode(context);
|
||||
if ((categoryNode == null) || !categoryNode.isEnabled()) {
|
||||
if (categoryNode == null || !categoryNode.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (categoryNode instanceof BuiltInArchiveNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.datamgr.actions;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.editor.DataTypeEditorManager;
|
||||
import ghidra.app.plugin.core.datamgr.tree.CategoryNode;
|
||||
import ghidra.program.model.data.Category;
|
||||
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.ActionContext;
|
||||
|
@ -29,6 +22,12 @@ import docking.action.DockingAction;
|
|||
import docking.action.MenuData;
|
||||
import docking.widgets.tree.GTree;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.editor.DataTypeEditorManager;
|
||||
import ghidra.app.plugin.core.datamgr.tree.BuiltInArchiveNode;
|
||||
import ghidra.app.plugin.core.datamgr.tree.CategoryNode;
|
||||
import ghidra.program.model.data.Category;
|
||||
|
||||
public abstract class CreateDataTypeAction extends DockingAction {
|
||||
protected final DataTypeManagerPlugin plugin;
|
||||
|
@ -43,7 +42,10 @@ public abstract class CreateDataTypeAction extends DockingAction {
|
|||
@Override
|
||||
public boolean isAddToPopup(ActionContext context) {
|
||||
CategoryNode categoryNode = getSelectedCategoryNode(context);
|
||||
if ((categoryNode == null) || !categoryNode.isEnabled()) {
|
||||
if (categoryNode == null || !categoryNode.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (categoryNode instanceof BuiltInArchiveNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -86,5 +88,6 @@ public abstract class CreateDataTypeAction extends DockingAction {
|
|||
createNewDataType(editorManager, category);
|
||||
}
|
||||
|
||||
protected abstract void createNewDataType(DataTypeEditorManager editorManager, Category category);
|
||||
protected abstract void createNewDataType(DataTypeEditorManager editorManager,
|
||||
Category category);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.datamgr.actions;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.ActionContext;
|
||||
|
@ -27,6 +26,7 @@ import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
|||
import ghidra.app.plugin.core.datamgr.tree.*;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Swing;
|
||||
|
||||
public class CreateTypeDefFromDialogAction extends AbstractTypeDefAction {
|
||||
|
||||
|
@ -67,28 +67,27 @@ public class CreateTypeDefFromDialogAction extends AbstractTypeDefAction {
|
|||
|
||||
final GTreeNode parentNode = categoryNode;
|
||||
final String newNodeName = newTypeDef.getName();
|
||||
SwingUtilities.invokeLater(() -> gTree.setSeletedNodeByName(parentNode, newNodeName));
|
||||
Swing.runLater(() -> gTree.setSeletedNodeByName(parentNode, newNodeName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
CategoryNode categoryNode = getCategoryNode(context);
|
||||
ArchiveNode archiveNode = getArchiveNode(categoryNode);
|
||||
if (archiveNode instanceof BuiltInArchiveNode) {
|
||||
// these will be put into the program archive
|
||||
return true;
|
||||
if (categoryNode instanceof BuiltInArchiveNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return categoryNode != null && categoryNode.isModifiable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddToPopup(ActionContext context) {
|
||||
CategoryNode categoryNode = getCategoryNode(context);
|
||||
if ((categoryNode == null) || !categoryNode.isEnabled()) {
|
||||
if (categoryNode == null || !categoryNode.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (categoryNode instanceof BuiltInArchiveNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -115,15 +114,4 @@ public class CreateTypeDefFromDialogAction extends AbstractTypeDefAction {
|
|||
}
|
||||
return (CategoryNode) node;
|
||||
}
|
||||
|
||||
private ArchiveNode getArchiveNode(CategoryNode categoryNode) {
|
||||
GTreeNode node = categoryNode;
|
||||
while (node != null) {
|
||||
if (node instanceof ArchiveNode) {
|
||||
return (ArchiveNode) node;
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.datamgr.actions;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.*;
|
||||
import ghidra.app.plugin.core.datamgr.tree.*;
|
||||
import ghidra.app.plugin.core.datamgr.util.DataTypeTreeCopyMoveTask;
|
||||
import ghidra.app.plugin.core.datamgr.util.DataTypeTreeCopyMoveTask.ActionType;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.event.InputEvent;
|
||||
|
@ -38,6 +31,11 @@ import docking.action.*;
|
|||
import docking.widgets.tree.GTree;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import docking.widgets.tree.support.GTreeNodeTransferable;
|
||||
import ghidra.app.plugin.core.datamgr.*;
|
||||
import ghidra.app.plugin.core.datamgr.tree.*;
|
||||
import ghidra.app.plugin.core.datamgr.util.DataTypeTreeCopyMoveTask;
|
||||
import ghidra.app.plugin.core.datamgr.util.DataTypeTreeCopyMoveTask.ActionType;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
|
||||
public class PasteAction extends DockingAction {
|
||||
private PluginTool tool;
|
||||
|
@ -58,6 +56,9 @@ public class PasteAction extends DockingAction {
|
|||
@Override
|
||||
public boolean isAddToPopup(ActionContext context) {
|
||||
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
|
||||
if (node instanceof BuiltInArchiveNode) {
|
||||
return false;
|
||||
}
|
||||
return (node != null);
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,7 @@ public class PasteAction extends DockingAction {
|
|||
}
|
||||
|
||||
DataFlavor[] flavors = handler.getSupportedDataFlavors(transferNodeList);
|
||||
return handler.isDropSiteOk((GTreeNode) destinationNode, flavors, DnDConstants.ACTION_COPY);
|
||||
return handler.isDropSiteOk(destinationNode, flavors, DnDConstants.ACTION_COPY);
|
||||
}
|
||||
|
||||
private boolean invalidCutNodes(DataTypeTreeNode destinationNode, List<GTreeNode> nodeList) {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class MakeProgramSelectionAction extends DockingAction {
|
|||
setPopupMenuData(
|
||||
new MenuData(new String[] { "Make Selection" }, Icons.MAKE_SELECTION_ICON));
|
||||
setToolBarData(new ToolBarData(Icons.MAKE_SELECTION_ICON));
|
||||
setDescription("Make a program selection from the seleted rows");
|
||||
setDescription("Make a program selection from the selected rows");
|
||||
|
||||
// this help location provides generic help; clients can override to point to their help
|
||||
setHelpLocation(new HelpLocation("Search", "Make_Selection"));
|
||||
|
|
|
@ -240,7 +240,7 @@ public class DataTypeWriter {
|
|||
if (throwExceptionOnInvalidType) {
|
||||
throw iae;
|
||||
}
|
||||
Msg.error(this, "Factory data types may not be written - type: " + dt, iae);
|
||||
Msg.error(this, "Factory data types may not be written - type: " + dt);
|
||||
}
|
||||
if (dt instanceof Pointer || dt instanceof Array || dt instanceof BitFieldDataType) {
|
||||
write(getBaseDataType(dt), monitor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue