Merge remote-tracking branch 'origin/GT-2869-dragonmacher-shared-action-keybindings'

This commit is contained in:
Ryan Kurtz
2019-06-12 14:56:08 -04:00
156 changed files with 2746 additions and 3082 deletions
@@ -113,7 +113,6 @@ src/main/help/help/topics/BookmarkPlugin/images/BookmarksFilter.png||GHIDRA||||E
src/main/help/help/topics/BookmarkPlugin/images/MarkerForBookmark.png||GHIDRA||||END| src/main/help/help/topics/BookmarkPlugin/images/MarkerForBookmark.png||GHIDRA||||END|
src/main/help/help/topics/BookmarkPlugin/images/NextSelectionBlock16.gif||GHIDRA||||END| src/main/help/help/topics/BookmarkPlugin/images/NextSelectionBlock16.gif||GHIDRA||||END|
src/main/help/help/topics/BookmarkPlugin/images/PreviousSelectionBlock16.gif||GHIDRA||||END| src/main/help/help/topics/BookmarkPlugin/images/PreviousSelectionBlock16.gif||GHIDRA||||END|
src/main/help/help/topics/BookmarkPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/CParserPlugin/CParser.htm||GHIDRA||||END| src/main/help/help/topics/CParserPlugin/CParser.htm||GHIDRA||||END|
src/main/help/help/topics/CParserPlugin/images/ParseCSource.png||GHIDRA||||END| src/main/help/help/topics/CParserPlugin/images/ParseCSource.png||GHIDRA||||END|
src/main/help/help/topics/CParserPlugin/images/ParseError.png||GHIDRA||||END| src/main/help/help/topics/CParserPlugin/images/ParseError.png||GHIDRA||||END|
@@ -167,7 +166,6 @@ src/main/help/help/topics/CodeBrowserPlugin/images/hoverOff.gif||GHIDRA||||END|
src/main/help/help/topics/CodeBrowserPlugin/images/hoverOn.gif||GHIDRA||||END| src/main/help/help/topics/CodeBrowserPlugin/images/hoverOn.gif||GHIDRA||||END|
src/main/help/help/topics/CommentWindowPlugin/comment_window.htm||GHIDRA||||END| src/main/help/help/topics/CommentWindowPlugin/comment_window.htm||GHIDRA||||END|
src/main/help/help/topics/CommentWindowPlugin/images/CommentsWindow.png||GHIDRA||||END| src/main/help/help/topics/CommentWindowPlugin/images/CommentsWindow.png||GHIDRA||||END|
src/main/help/help/topics/CommentWindowPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/CommentsPlugin/Comments.htm||GHIDRA||||END| src/main/help/help/topics/CommentsPlugin/Comments.htm||GHIDRA||||END|
src/main/help/help/topics/CommentsPlugin/images/Comment.png||GHIDRA||||END| src/main/help/help/topics/CommentsPlugin/images/Comment.png||GHIDRA||||END|
src/main/help/help/topics/CommentsPlugin/images/ShowCommentHistory.png||GHIDRA||||END| src/main/help/help/topics/CommentsPlugin/images/ShowCommentHistory.png||GHIDRA||||END|
@@ -264,7 +262,6 @@ src/main/help/help/topics/DataTypePreviewPlugin/images/edit-delete.png||Oxygen I
src/main/help/help/topics/DataWindowPlugin/data_window.htm||GHIDRA||||END| src/main/help/help/topics/DataWindowPlugin/data_window.htm||GHIDRA||||END|
src/main/help/help/topics/DataWindowPlugin/images/DataWindow.png||GHIDRA||||END| src/main/help/help/topics/DataWindowPlugin/images/DataWindow.png||GHIDRA||||END|
src/main/help/help/topics/DataWindowPlugin/images/DataWindowFilter.png||GHIDRA||||END| src/main/help/help/topics/DataWindowPlugin/images/DataWindowFilter.png||GHIDRA||||END|
src/main/help/help/topics/DataWindowPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/DbViewerPlugin/DbViewer.htm||GHIDRA||reviewed||END| src/main/help/help/topics/DbViewerPlugin/DbViewer.htm||GHIDRA||reviewed||END|
src/main/help/help/topics/DbViewerPlugin/images/DatabaseViewer.png||GHIDRA||||END| src/main/help/help/topics/DbViewerPlugin/images/DatabaseViewer.png||GHIDRA||||END|
src/main/help/help/topics/DisassembledViewPlugin/DisassembledViewPlugin.htm||GHIDRA||||END| src/main/help/help/topics/DisassembledViewPlugin/DisassembledViewPlugin.htm||GHIDRA||||END|
@@ -404,7 +401,6 @@ src/main/help/help/topics/FunctionTagPlugin/images/InputField.png||GHIDRA||||END
src/main/help/help/topics/FunctionWindowPlugin/function_window.htm||GHIDRA||||END| src/main/help/help/topics/FunctionWindowPlugin/function_window.htm||GHIDRA||||END|
src/main/help/help/topics/FunctionWindowPlugin/images/FunctionWindow.png||GHIDRA||||END| src/main/help/help/topics/FunctionWindowPlugin/images/FunctionWindow.png||GHIDRA||||END|
src/main/help/help/topics/FunctionWindowPlugin/images/page_white_c.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/help/help/topics/FunctionWindowPlugin/images/page_white_c.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/FunctionWindowPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/GhidraScriptMgrPlugin/GhidraScriptMgrPlugin.htm||GHIDRA||||END| src/main/help/help/topics/GhidraScriptMgrPlugin/GhidraScriptMgrPlugin.htm||GHIDRA||||END|
src/main/help/help/topics/GhidraScriptMgrPlugin/ScriptDevelopment.htm||GHIDRA||||END| src/main/help/help/topics/GhidraScriptMgrPlugin/ScriptDevelopment.htm||GHIDRA||||END|
src/main/help/help/topics/GhidraScriptMgrPlugin/images/Assign_Key_Binding.png||GHIDRA||||END| src/main/help/help/topics/GhidraScriptMgrPlugin/images/Assign_Key_Binding.png||GHIDRA||||END|
@@ -470,7 +466,6 @@ src/main/help/help/topics/LocationReferencesPlugin/images/ReferencesToDialog.png
src/main/help/help/topics/LocationReferencesPlugin/images/XRefLabelReferencesSample.png||GHIDRA||||END| src/main/help/help/topics/LocationReferencesPlugin/images/XRefLabelReferencesSample.png||GHIDRA||||END|
src/main/help/help/topics/LocationReferencesPlugin/images/go-home.png||Tango Icons - Public Domain|||Tango|END| src/main/help/help/topics/LocationReferencesPlugin/images/go-home.png||Tango Icons - Public Domain|||Tango|END|
src/main/help/help/topics/LocationReferencesPlugin/images/tag_yellow.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/help/help/topics/LocationReferencesPlugin/images/tag_yellow.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/LocationReferencesPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/MemoryMapPlugin/Memory_Map.htm||GHIDRA||||END| src/main/help/help/topics/MemoryMapPlugin/Memory_Map.htm||GHIDRA||||END|
src/main/help/help/topics/MemoryMapPlugin/images/AddMappedBlock.png||GHIDRA||||END| src/main/help/help/topics/MemoryMapPlugin/images/AddMappedBlock.png||GHIDRA||||END|
src/main/help/help/topics/MemoryMapPlugin/images/AddMemoryBlock.png||GHIDRA||||END| src/main/help/help/topics/MemoryMapPlugin/images/AddMemoryBlock.png||GHIDRA||||END|
@@ -598,7 +593,6 @@ src/main/help/help/topics/ReferencesPlugin/images/erase16.png||GHIDRA||||END|
src/main/help/help/topics/ReferencesPlugin/images/go-home.png||Tango Icons - Public Domain|||Tango|END| src/main/help/help/topics/ReferencesPlugin/images/go-home.png||Tango Icons - Public Domain|||Tango|END|
src/main/help/help/topics/ReferencesPlugin/images/locationIn.gif||GHIDRA||||END| src/main/help/help/topics/ReferencesPlugin/images/locationIn.gif||GHIDRA||||END|
src/main/help/help/topics/ReferencesPlugin/images/locationOut.gif||GHIDRA||||END| src/main/help/help/topics/ReferencesPlugin/images/locationOut.gif||GHIDRA||||END|
src/main/help/help/topics/ReferencesPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/ReferencesPlugin/images/unchecked.png||GHIDRA||||END| src/main/help/help/topics/ReferencesPlugin/images/unchecked.png||GHIDRA||||END|
src/main/help/help/topics/RegisterPlugin/Registers.htm||GHIDRA||||END| src/main/help/help/topics/RegisterPlugin/Registers.htm||GHIDRA||||END|
src/main/help/help/topics/RegisterPlugin/images/ClearRegisterValues.png||GHIDRA||||END| src/main/help/help/topics/RegisterPlugin/images/ClearRegisterValues.png||GHIDRA||||END|
@@ -609,7 +603,6 @@ src/main/help/help/topics/RegisterPlugin/images/edit-delete.png||Oxygen Icons -
src/main/help/help/topics/RegisterPlugin/images/locationIn.gif||GHIDRA||||END| src/main/help/help/topics/RegisterPlugin/images/locationIn.gif||GHIDRA||||END|
src/main/help/help/topics/RegisterPlugin/images/registerGroup.png||GHIDRA||||END| src/main/help/help/topics/RegisterPlugin/images/registerGroup.png||GHIDRA||||END|
src/main/help/help/topics/RegisterPlugin/images/registerIcon.png||GHIDRA||||END| src/main/help/help/topics/RegisterPlugin/images/registerIcon.png||GHIDRA||||END|
src/main/help/help/topics/RegisterPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/RegisterPlugin/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END| src/main/help/help/topics/RegisterPlugin/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/help/help/topics/RelocationTablePlugin/images/Relocation_Table.png||GHIDRA||||END| src/main/help/help/topics/RelocationTablePlugin/images/Relocation_Table.png||GHIDRA||||END|
src/main/help/help/topics/RelocationTablePlugin/relocation_table.htm||GHIDRA||||END| src/main/help/help/topics/RelocationTablePlugin/relocation_table.htm||GHIDRA||||END|
@@ -712,7 +705,6 @@ src/main/help/help/topics/Search/images/page_white_copy.png||FAMFAMFAM Icons - C
src/main/help/help/topics/Search/images/reload.png||Nuvola Icons - LGPL 2.1||||END| src/main/help/help/topics/Search/images/reload.png||Nuvola Icons - LGPL 2.1||||END|
src/main/help/help/topics/Search/images/searchm_obj.gif||GHIDRA||||END| src/main/help/help/topics/Search/images/searchm_obj.gif||GHIDRA||||END|
src/main/help/help/topics/Search/images/table_delete.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/help/help/topics/Search/images/table_delete.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/Search/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/Search/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END| src/main/help/help/topics/Search/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html||GHIDRA||||END| src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html||GHIDRA||||END|
src/main/help/help/topics/SelectBlockPlugin/images/Dialog.png||GHIDRA||||END| src/main/help/help/topics/SelectBlockPlugin/images/Dialog.png||GHIDRA||||END|
@@ -749,7 +741,6 @@ src/main/help/help/topics/SymbolTablePlugin/images/edit-delete.png||Oxygen Icons
src/main/help/help/topics/SymbolTablePlugin/images/references_to.gif||GHIDRA||||END| src/main/help/help/topics/SymbolTablePlugin/images/references_to.gif||GHIDRA||||END|
src/main/help/help/topics/SymbolTablePlugin/images/table.png||FAMFAMFAM Icons - CC 2.5|||silk|END| src/main/help/help/topics/SymbolTablePlugin/images/table.png||FAMFAMFAM Icons - CC 2.5|||silk|END|
src/main/help/help/topics/SymbolTablePlugin/images/table_go.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/help/help/topics/SymbolTablePlugin/images/table_go.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/SymbolTablePlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/help/help/topics/SymbolTablePlugin/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END| src/main/help/help/topics/SymbolTablePlugin/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/help/help/topics/SymbolTablePlugin/symbol_references.htm||GHIDRA||||END| src/main/help/help/topics/SymbolTablePlugin/symbol_references.htm||GHIDRA||||END|
src/main/help/help/topics/SymbolTablePlugin/symbol_table.htm||GHIDRA||||END| src/main/help/help/topics/SymbolTablePlugin/symbol_table.htm||GHIDRA||||END|
@@ -830,7 +821,6 @@ src/main/help/help/topics/VersionControl/images/vcUndoCheckOut.png||GHIDRA||||EN
src/main/help/help/topics/VersionControl/project_repository.htm||GHIDRA||||END| src/main/help/help/topics/VersionControl/project_repository.htm||GHIDRA||||END|
src/main/help/help/topics/ViewStringsPlugin/ViewStringsPlugin.htm||GHIDRA||||END| src/main/help/help/topics/ViewStringsPlugin/ViewStringsPlugin.htm||GHIDRA||||END|
src/main/help/help/topics/ViewStringsPlugin/images/Defined_String_Table.png||GHIDRA||||END| src/main/help/help/topics/ViewStringsPlugin/images/Defined_String_Table.png||GHIDRA||||END|
src/main/help/help/topics/ViewStringsPlugin/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/java/ghidra/app/cmd/comments/package.html||GHIDRA||reviewed||END| src/main/java/ghidra/app/cmd/comments/package.html||GHIDRA||reviewed||END|
src/main/java/ghidra/app/cmd/data/package.html||GHIDRA||||END| src/main/java/ghidra/app/cmd/data/package.html||GHIDRA||||END|
src/main/java/ghidra/app/cmd/disassemble/package.html||GHIDRA||||END| src/main/java/ghidra/app/cmd/disassemble/package.html||GHIDRA||||END|
@@ -1162,7 +1152,6 @@ src/main/resources/images/table_delete.png||FAMFAMFAM Icons - CC 2.5|||famfamfam
src/main/resources/images/table_go.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/resources/images/table_go.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/table_row_delete.png||FAMFAMFAM Icons - CC 2.5|||silk|END| src/main/resources/images/table_row_delete.png||FAMFAMFAM Icons - CC 2.5|||silk|END|
src/main/resources/images/tag_yellow.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/resources/images/tag_yellow.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/text_align_justify.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/text_list_bullets.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/resources/images/text_list_bullets.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/text_lowercase.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/resources/images/text_lowercase.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/textfield.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END| src/main/resources/images/textfield.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
@@ -20,6 +20,7 @@ import java.io.*;
import java.util.*; import java.util.*;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import docking.actions.KeyBindingUtils;
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.framework.plugintool.Plugin; import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
@@ -30,9 +31,9 @@ public class CreateHelpTemplateScript extends GhidraScript {
@Override @Override
protected void run() throws Exception { protected void run() throws Exception {
PluginTool tool = state.getTool(); PluginTool tool = state.getTool();
Plugin[] plugins = getSortedPlugins(tool); List<Plugin> plugins = getSortedPlugins(tool);
Plugin selectedPlugin = Plugin selectedPlugin =
askChoice("Select Plugin To Use To Generate Help", "Plugin", plugins, plugins[0]); askChoice("Select Plugin To Use To Generate Help", "Plugin", plugins, plugins.get(0));
if (selectedPlugin == null) { if (selectedPlugin == null) {
printerr("no plugin selected, no help template created."); printerr("no plugin selected, no help template created.");
return; return;
@@ -101,7 +102,8 @@ public class CreateHelpTemplateScript extends GhidraScript {
} }
private List<DockingActionIf> getActions(PluginTool tool, Plugin plugin) { private List<DockingActionIf> getActions(PluginTool tool, Plugin plugin) {
List<DockingActionIf> actions = tool.getDockingActionsByOwnerName(plugin.getName()); Set<DockingActionIf> actions = KeyBindingUtils.getKeyBindingActionsForOwner(tool, plugin.getName());
List<DockingActionIf> list = new ArrayList<>(actions);
Comparator<DockingActionIf> comparator = (action1, action2) -> { Comparator<DockingActionIf> comparator = (action1, action2) -> {
try { try {
return action1.getName().compareTo(action2.getName()); return action1.getName().compareTo(action2.getName());
@@ -110,14 +112,12 @@ public class CreateHelpTemplateScript extends GhidraScript {
return 0; return 0;
} }
}; };
Collections.sort(actions, comparator); Collections.sort(list, comparator);
return actions; return list;
} }
private Plugin[] getSortedPlugins(PluginTool tool) { private List<Plugin> getSortedPlugins(PluginTool tool) {
List<Plugin> list = tool.getManagedPlugins(); List<Plugin> list = tool.getManagedPlugins();
Plugin[] plugins = new Plugin[list.size()];
list.toArray(plugins);
Comparator<Plugin> comparator = (plugin1, plugin2) -> { Comparator<Plugin> comparator = (plugin1, plugin2) -> {
try { try {
return plugin1.getName().compareTo(plugin2.getName()); return plugin1.getName().compareTo(plugin2.getName());
@@ -126,8 +126,9 @@ public class CreateHelpTemplateScript extends GhidraScript {
return 0; return 0;
} }
}; };
Arrays.sort(plugins, comparator);
return plugins; Collections.sort(list, comparator);
return list;
} }
} }
@@ -305,7 +305,7 @@
<OL> <OL>
<LI>Select one or more rows in the Bookmarks table.</LI> <LI>Select one or more rows in the Bookmarks table.</LI>
<LI>Click the Select Bookmark Locations <IMG src="images/text_align_justify.png" alt=""> <LI>Click the Select Bookmark Locations <IMG src="Icons.MAKE_SELECTION_ICON" alt="">
button in the local toolbar.</LI> button in the local toolbar.</LI>
<LI>The corresponding addresses are selected in the browser.</LI> <LI>The corresponding addresses are selected in the browser.</LI>
@@ -42,7 +42,7 @@
"help/topics/Selection/Selecting.htm">select</A> all of the code units in the Code Browser "help/topics/Selection/Selecting.htm">select</A> all of the code units in the Code Browser
display corresponding to the selected rows&nbsp; in the table. Since the table allows for display corresponding to the selected rows&nbsp; in the table. Since the table allows for
multiple selections, any number of comment items may be selected. To make the selection, either multiple selections, any number of comment items may be selected. To make the selection, either
click on <IMG src="images/text_align_justify.png">, or right mouse click in the table and choose click on <IMG src="Icons.MAKE_SELECTION_ICON">, or right mouse click in the table and choose
<B>Make Selection</B>.</P> <B>Make Selection</B>.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -36,13 +36,13 @@
<H3><A name="Make_Selection"></A>Make Selection</H3> <H3><A name="Make_Selection"></A>Make Selection</H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P><IMG src="images/text_align_justify.png"></P> <P><IMG src="Icons.MAKE_SELECTION_ICON"></P>
<P>The data window's tool bar has a button that will <A href= <P>The data window's tool bar has a button that will <A href=
"help/topics/Selection/Selecting.htm">select</A> all of the code units in the Code Browser "help/topics/Selection/Selecting.htm">select</A> all of the code units in the Code Browser
display corresponding to the selected rows&nbsp; in the table. Since the table allows for display corresponding to the selected rows&nbsp; in the table. Since the table allows for
multiple selections, any number of data items may be selected. To make the selection, either multiple selections, any number of data items may be selected. To make the selection, either
click on <IMG src="images/text_align_justify.png">, or right mouse click in the table and choose click on <IMG src="Icons.MAKE_SELECTION_ICON">, or right mouse click in the table and choose
<B>Make Selection</B>.</P> <B>Make Selection</B>.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -30,12 +30,12 @@ function's signature. Click on the top of a column to sort the list by that col
<h3><a name="Make_Selection"></a>Make Selection</h3> <h3><a name="Make_Selection"></a>Make Selection</h3>
<blockquote> <blockquote>
<p>The Functions window has an icon (<img src="images/text_align_justify.png">) <p>The Functions window has an icon (<img src="Icons.MAKE_SELECTION_ICON">)
on the tool bar to make a selection in the Code Browser. To make a selection,</p> on the tool bar to make a selection in the Code Browser. To make a selection,</p>
<ol> <ol>
<li>&nbsp;Select the functions in the <b>Functions</b> window.</li> <li>&nbsp;Select the functions in the <b>Functions</b> window.</li>
<li>Right mouse click and select the <img src="images/text_align_justify.png"> <b>Make <li>Right mouse click and select the <img src="Icons.MAKE_SELECTION_ICON"> <b>Make
Selection</b> option, OR select the <img src="images/text_align_justify.png">button on Selection</b> option, OR select the <img src="Icons.MAKE_SELECTION_ICON">button on
the tool bar.</li> the tool bar.</li>
</ol> </ol>
</blockquote> </blockquote>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -121,7 +121,7 @@
become color filled, as it is here. You may push the button for a refresh in either become color filled, as it is here. You may push the button for a refresh in either
state.</P> state.</P>
<P align="left"><A name="Select"></A>The <IMG alt="" src="images/text_align_justify.png"> button <P align="left"><A name="Select"></A>The <IMG alt="" src="Icons.MAKE_SELECTION_ICON"> button
will create a selection in the code browser with the reference entries selected in the will create a selection in the code browser with the reference entries selected in the
table. You may also access this feature by right-clicking an item in the table and table. You may also access this feature by right-clicking an item in the table and
selecting <B>Make Selection</B>.</P> selecting <B>Make Selection</B>.</P>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -924,7 +924,7 @@
single reference row is selected.<BR> single reference row is selected.<BR>
</P> </P>
<P><A name="Select_Destinations"></A><IMG src="images/text_align_justify.png" alt=""> <I><B>Select <P><A name="Select_Destinations"></A><IMG src="Icons.MAKE_SELECTION_ICON" alt=""> <I><B>Select
Memory Reference Destination</B></I> - With one or more memory references selected in the Memory Reference Destination</B></I> - With one or more memory references selected in the
table, invoking this action will cause the corresponding locations within the&nbsp;<A href= table, invoking this action will cause the corresponding locations within the&nbsp;<A href=
"help/topics/CodeBrowserPlugin/CodeBrowser.htm">Listing</A> to become selected.<BR> "help/topics/CodeBrowserPlugin/CodeBrowser.htm">Listing</A> to become selected.<BR>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -85,7 +85,7 @@
<P><IMG src="images/edit-delete.png">Deletes the register value associations for all the <P><IMG src="images/edit-delete.png">Deletes the register value associations for all the
selected ranges in the table.</P> selected ranges in the table.</P>
<P><IMG src="images/text_align_justify.png">Creates a selection in the browser for all the address <P><IMG src="Icons.MAKE_SELECTION_ICON">Creates a selection in the browser for all the address
ranges selected in the register values table.</P> ranges selected in the register values table.</P>
<P><IMG src="images/view-filter.png">Filters out all registers in the register tree that <P><IMG src="images/view-filter.png">Filters out all registers in the register tree that
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -129,7 +129,7 @@
<BLOCKQUOTE> <BLOCKQUOTE>
<H3><A NAME="Make_Selection"></A>Make Selection <H3><A NAME="Make_Selection"></A>Make Selection
<IMG border="0" src="images/text_align_justify.png"></H3> <IMG border="0" src="Icons.MAKE_SELECTION_ICON"></H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P> <P>
@@ -65,7 +65,7 @@
were found.</P> were found.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3><A name="Make_Selection"></A>Make Selection <IMG border="0" src="images/text_align_justify.png"></H3> <H3><A name="Make_Selection"></A>Make Selection <IMG border="0" src="Icons.MAKE_SELECTION_ICON"></H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>A selection in the Listing can be created from the entries in the results table. <P>A selection in the Listing can be created from the entries in the results table.
@@ -79,7 +79,7 @@
<OL> <OL>
<LI>Click in the results table and press <TT><B>Ctrl+A</B></TT>.</LI> <LI>Click in the results table and press <TT><B>Ctrl+A</B></TT>.</LI>
<LI>Click on the <IMG border="0" src="images/text_align_justify.png" > in <LI>Click on the <IMG border="0" src="Icons.MAKE_SELECTION_ICON" > in
the tool bar, or right mouse click and choose <B>Make Selection</B>.</LI> the tool bar, or right mouse click and choose <B>Make Selection</B>.</LI>
<LI>The current selection will be set to the address of each result item.</LI> <LI>The current selection will be set to the address of each result item.</LI>
@@ -93,7 +93,7 @@
<LI>Press and hold the right mouse button over the results table.</LI> <LI>Press and hold the right mouse button over the results table.</LI>
<LI>Click on the <IMG border="0" src="images/text_align_justify.png" > in <LI>Click on the <IMG border="0" src="Icons.MAKE_SELECTION_ICON" > in
the tool bar, or right mouse click and choose <B>Make Selection</B>.</LI> the tool bar, or right mouse click and choose <B>Make Selection</B>.</LI>
<LI>The current selection will be set to the address of all the highlighted items.</LI> <LI>The current selection will be set to the address of all the highlighted items.</LI>
@@ -145,7 +145,7 @@
<BLOCKQUOTE> <BLOCKQUOTE>
<H3></A>Make Selection <IMG border="0" src="images/text_align_justify.png"></H3> <H3></A>Make Selection <IMG border="0" src="Icons.MAKE_SELECTION_ICON"></H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P> <P>
@@ -133,7 +133,7 @@
<BLOCKQUOTE> <BLOCKQUOTE>
<H3></A>Make Selection <IMG border="0" src="images/text_align_justify.png"></H3> <H3></A>Make Selection <IMG border="0" src="Icons.MAKE_SELECTION_ICON"></H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P> <P>
@@ -206,7 +206,7 @@
results.</P> results.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3>Make Selection <IMG alt="" border="0" src="images/text_align_justify.png"></H3> <H3>Make Selection <IMG alt="" border="0" src="Icons.MAKE_SELECTION_ICON"></H3>
<BLOCKQUOTE> <BLOCKQUOTE>
<P><I>See <A href="help/topics/Search/Query_Results_Dialog.htm#Make_Selection">Make <P><I>See <A href="help/topics/Search/Query_Results_Dialog.htm#Make_Selection">Make
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -189,7 +189,7 @@
for more discussion on the use of the edit dialog). for more discussion on the use of the edit dialog).
</BLOCKQUOTE> </BLOCKQUOTE>
<H2><A name="Make_Selection"></A>Making a Selection&nbsp;<IMG src="images/text_align_justify.png"></H2> <H2><A name="Make_Selection"></A>Making a Selection&nbsp;<IMG src="Icons.MAKE_SELECTION_ICON"></H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>You can make a selection that corresponds to the symbol addresses that are selected in the <P>You can make a selection that corresponds to the symbol addresses that are selected in the
@@ -205,7 +205,7 @@
Right-mouse-click and select "Make Selection" from the popup menu. Right-mouse-click and select "Make Selection" from the popup menu.
<UL> <UL>
<LI>Or, click the&nbsp;<IMG src="images/text_align_justify.png"> &nbsp;button in the <I>Symbol <LI>Or, click the&nbsp;<IMG src="Icons.MAKE_SELECTION_ICON"> &nbsp;button in the <I>Symbol
Table</I> toolbar.</LI> Table</I> toolbar.</LI>
</UL> </UL>
</LI> </LI>
@@ -53,12 +53,12 @@
<blockquote> <blockquote>
<h3><a name="Make_Selection"></a>Make Selection</h3> <h3><a name="Make_Selection"></a>Make Selection</h3>
<blockquote> <blockquote>
<p>The Defined Strings window has an icon (<img src="images/text_align_justify.png">) <p>The Defined Strings window has an icon (<img src="Icons.MAKE_SELECTION_ICON">)
on the tool bar to make a selection in the Code Browser. To make a selection,</p> on the tool bar to make a selection in the Code Browser. To make a selection,</p>
<ol> <ol>
<li>&nbsp;Select the rows containing the desired strings in the table.</li> <li>&nbsp;Select the rows containing the desired strings in the table.</li>
<li>Right mouse click and select the <img src="images/text_align_justify.png"> <b>Make <li>Right mouse click and select the <img src="Icons.MAKE_SELECTION_ICON"> <b>Make
Selection</b> option, OR select the <img src="images/text_align_justify.png">button on Selection</b> option, OR select the <img src="Icons.MAKE_SELECTION_ICON">button on
the tool bar.</li> the tool bar.</li>
</ol> </ol>
</blockquote> </blockquote>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

@@ -22,6 +22,8 @@ import javax.swing.KeyStroke;
import docking.ActionContext; import docking.ActionContext;
import docking.DockingUtils; import docking.DockingUtils;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import ghidra.app.plugin.core.navigation.FindAppliedDataTypesService; import ghidra.app.plugin.core.navigation.FindAppliedDataTypesService;
import ghidra.app.plugin.core.navigation.locationreferences.ReferenceUtils; import ghidra.app.plugin.core.navigation.locationreferences.ReferenceUtils;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
@@ -29,11 +31,12 @@ import ghidra.program.model.data.Composite;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.util.*; import ghidra.util.*;
public abstract class AbstractFindReferencesDataTypeAction extends AbstractSharedKeybindingAction { public abstract class AbstractFindReferencesDataTypeAction extends DockingAction {
public static final String NAME = "Find References To"; public static final String NAME = "Find References To";
public static final KeyStroke DEFAULT_KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_F, public static final KeyStroke DEFAULT_KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_F,
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK); DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK);
private PluginTool tool;
protected AbstractFindReferencesDataTypeAction(PluginTool tool, String name, String owner) { protected AbstractFindReferencesDataTypeAction(PluginTool tool, String name, String owner) {
this(tool, name, owner, null); this(tool, name, owner, null);
@@ -41,10 +44,13 @@ public abstract class AbstractFindReferencesDataTypeAction extends AbstractShare
protected AbstractFindReferencesDataTypeAction(PluginTool tool, String name, String owner, protected AbstractFindReferencesDataTypeAction(PluginTool tool, String name, String owner,
KeyStroke defaultKeyStroke) { KeyStroke defaultKeyStroke) {
super(tool, name, owner, defaultKeyStroke); super(name, owner);
this.tool = tool;
setHelpLocation(new HelpLocation("LocationReferencesPlugin", "Data_Types")); setHelpLocation(new HelpLocation("LocationReferencesPlugin", "Data_Types"));
setDescription("Shows all uses of the selected data type"); setDescription("Shows all uses of the selected data type");
initKeyStroke(defaultKeyStroke);
} }
protected abstract DataType getDataType(ActionContext context); protected abstract DataType getDataType(ActionContext context);
@@ -55,6 +61,19 @@ public abstract class AbstractFindReferencesDataTypeAction extends AbstractShare
return null; return null;
} }
private void initKeyStroke(KeyStroke keyStroke) {
if (keyStroke == null) {
return;
}
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
@Override @Override
public boolean isEnabledForContext(ActionContext context) { public boolean isEnabledForContext(ActionContext context) {
DataType dataType = getDataType(context); DataType dataType = getDataType(context);
@@ -80,17 +99,15 @@ public abstract class AbstractFindReferencesDataTypeAction extends AbstractShare
if (field != null && !(baseDataType instanceof Composite)) { if (field != null && !(baseDataType instanceof Composite)) {
Msg.error(this, "Somehow have a field without a Composite parent--searching " + Msg.error(this, "Somehow have a field without a Composite parent--searching " +
"only for the parent type '" + dataType + "'; field '" + field + "'"); "only for the parent type '" + dataType + "'; field '" + field + "'");
SystemUtilities.runSwingLater( Swing.runLater(() -> service.findAndDisplayAppliedDataTypeAddresses(dataType));
() -> service.findAndDisplayAppliedDataTypeAddresses(dataType));
return; return;
} }
if (field == null) { if (field == null) {
SystemUtilities.runSwingLater( Swing.runLater(() -> service.findAndDisplayAppliedDataTypeAddresses(dataType));
() -> service.findAndDisplayAppliedDataTypeAddresses(dataType));
} }
else { else {
SystemUtilities.runSwingLater(() -> service.findAndDisplayAppliedDataTypeAddresses( Swing.runLater(() -> service.findAndDisplayAppliedDataTypeAddresses(
(Composite) baseDataType, field)); (Composite) baseDataType, field));
} }
} }
@@ -1,83 +0,0 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.app.actions;
import javax.swing.KeyStroke;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
/**
* An action that can be extended in order to share keybindings.
* <p>
* Any group of actions that wish to share a keybinding must all use the same <tt>name</tt> and
* default <tt>keystroke</tt> value.
* <p>
* As the end-user assigns keybindings, each subclass will update accordingly.
*
* @see DummyKeyBindingsOptionsAction
*/
public abstract class AbstractSharedKeybindingAction extends DockingAction
implements OptionsChangeListener {
protected PluginTool tool;
protected AbstractSharedKeybindingAction(PluginTool tool, String name, String owner,
KeyStroke defaultkeyStroke) {
super(name, owner, false /* not keybinding managed--the dummy handles that */);
this.tool = tool;
DockingAction action = new DummyKeyBindingsOptionsAction(name, defaultkeyStroke);
tool.addAction(action);
// setup options to know when the dummy key binding is changed
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
KeyStroke optionsKeyStroke = options.getKeyStroke(action.getFullName(), defaultkeyStroke);
if (defaultkeyStroke != null) {
if (!defaultkeyStroke.equals(optionsKeyStroke)) {
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(optionsKeyStroke));
}
else {
setKeyBindingData(new KeyBindingData(optionsKeyStroke));
}
}
else {
if (optionsKeyStroke != null) {
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(optionsKeyStroke));
}
}
options.addOptionsChangeListener(this);
}
@Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
String actionName = getName();
if (name.startsWith(actionName)) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
}
@@ -834,12 +834,6 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
currentProgram = null; currentProgram = null;
} }
tool.removeLocalAction(this, recurseDepthAction);
tool.removeLocalAction(this, refreshAction);
tool.removeLocalAction(this, filterDuplicates);
tool.removeLocalAction(this, navigationOutgoingAction);
tool.removeLocalAction(this, navigateIncomingToggleAction);
recurseDepthAction.dispose(); recurseDepthAction.dispose();
refreshAction.dispose(); refreshAction.dispose();
filterDuplicates.dispose(); filterDuplicates.dispose();
@@ -15,28 +15,24 @@
*/ */
package ghidra.app.plugin.core.commentwindow; package ghidra.app.plugin.core.commentwindow;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.DockingAction;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin; import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.services.GoToService; import ghidra.app.services.GoToService;
import ghidra.framework.model.*; import ghidra.framework.model.*;
import ghidra.framework.options.*; import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.*; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.*; import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.util.*; import ghidra.program.util.*;
import ghidra.util.table.GhidraTable;
import ghidra.util.table.SelectionNavigationAction; import ghidra.util.table.SelectionNavigationAction;
import ghidra.util.table.actions.MakeProgramSelectionAction;
import ghidra.util.task.SwingUpdateManager; import ghidra.util.task.SwingUpdateManager;
import resources.ResourceManager;
/* /*
* This plugin shows a filterable Ghidra table containing all the comments in the active program * This plugin shows a filterable Ghidra table containing all the comments in the active program
@@ -53,8 +49,7 @@ import resources.ResourceManager;
servicesRequired = { GoToService.class } servicesRequired = { GoToService.class }
) )
//@formatter:on //@formatter:on
public class CommentWindowPlugin extends ProgramPlugin public class CommentWindowPlugin extends ProgramPlugin implements DomainObjectListener {
implements DomainObjectListener, OptionsChangeListener {
private DockingAction selectAction; private DockingAction selectAction;
private CommentWindowProvider provider; private CommentWindowProvider provider;
@@ -63,12 +58,7 @@ public class CommentWindowPlugin extends ProgramPlugin
public CommentWindowPlugin(PluginTool tool) { public CommentWindowPlugin(PluginTool tool) {
super(tool, true, true); super(tool, true, true);
reloadUpdateMgr = new SwingUpdateManager(1000, 60000, new Runnable() { reloadUpdateMgr = new SwingUpdateManager(1000, 60000, () -> doReload());
@Override
public void run() {
doReload();
}
});
} }
@Override @Override
@@ -89,12 +79,6 @@ public class CommentWindowPlugin extends ProgramPlugin
super.dispose(); super.dispose();
} }
////////////////////////////////////////////////////////////////////////////
//
// Implementation of DomainObjectListener
//
////////////////////////////////////////////////////////////////////////////
private int getCommentType(int type) { private int getCommentType(int type) {
if (type == ChangeManager.DOCR_PRE_COMMENT_CHANGED) { if (type == ChangeManager.DOCR_PRE_COMMENT_CHANGED) {
return CodeUnit.PRE_COMMENT; return CodeUnit.PRE_COMMENT;
@@ -169,9 +153,7 @@ public class CommentWindowPlugin extends ProgramPlugin
provider.getComponent().repaint(); provider.getComponent().repaint();
} }
} }
} }
} }
private void reload() { private void reload() {
@@ -198,39 +180,18 @@ public class CommentWindowPlugin extends ProgramPlugin
return currentProgram; return currentProgram;
} }
// Junit access
CommentWindowProvider getProvider() { CommentWindowProvider getProvider() {
return provider; return provider;
} }
/**
* Create the action objects for this plugin.
*/
private void createActions() { private void createActions() {
selectAction = new DockingAction("Make Selection", getName(), false) { selectAction = new MakeProgramSelectionAction(getName(), provider.getTable()) {
@Override @Override
public void actionPerformed(ActionContext context) { protected void makeSelection(ActionContext context) {
selectComment(provider.selectComment()); selectComment(provider.selectComment());
} }
@Override
public boolean isEnabledForContext(ActionContext context) {
if (!(context instanceof CommentWindowContext)) {
return false;
}
CommentWindowContext commentWindowContext = (CommentWindowContext) context;
GhidraTable table = commentWindowContext.getCommentTable();
return table.getSelectedRows().length > 0;
}
}; };
selectAction.setEnabled(false);
ImageIcon icon = ResourceManager.loadImage("images/text_align_justify.png");
selectAction.setPopupMenuData(new MenuData(new String[] { "Make Selection" }, icon));
selectAction.setDescription("Selects currently selected comment in table");
selectAction.setToolBarData(new ToolBarData(icon));
installDummyAction(selectAction);
tool.addLocalAction(provider, selectAction); tool.addLocalAction(provider, selectAction);
@@ -238,34 +199,10 @@ public class CommentWindowPlugin extends ProgramPlugin
tool.addLocalAction(provider, selectionAction); tool.addLocalAction(provider, selectionAction);
} }
private void installDummyAction(DockingAction action) { private void selectComment(ProgramSelection selection) {
DummyKeyBindingsOptionsAction dummyAction =
new DummyKeyBindingsOptionsAction(action.getName(), null);
tool.addAction(dummyAction);
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke = options.getKeyStroke(dummyAction.getFullName(), null);
if (keyStroke != null) {
action.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
if (optionName.startsWith(selectAction.getName())) {
KeyStroke keyStroke = (KeyStroke) newValue;
selectAction.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
void selectComment(ProgramSelection selection) {
ProgramSelectionPluginEvent pspe = ProgramSelectionPluginEvent pspe =
new ProgramSelectionPluginEvent("Selection", selection, currentProgram); new ProgramSelectionPluginEvent("Selection", selection, currentProgram);
firePluginEvent(pspe); firePluginEvent(pspe);
processEvent(pspe); processEvent(pspe);
} }
} }
@@ -21,9 +21,7 @@ import java.awt.datatransfer.Transferable;
import java.awt.dnd.*; import java.awt.dnd.*;
import java.awt.event.*; import java.awt.event.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Arrays; import java.util.*;
import java.util.EventObject;
import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
@@ -33,10 +31,10 @@ import javax.swing.table.*;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import docking.actions.KeyBindingUtils;
import docking.dnd.*; import docking.dnd.*;
import docking.help.Help; import docking.help.Help;
import docking.help.HelpService; import docking.help.HelpService;
import docking.util.KeyBindingUtils;
import docking.widgets.DropDownSelectionTextField; import docking.widgets.DropDownSelectionTextField;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.fieldpanel.support.FieldRange; import docking.widgets.fieldpanel.support.FieldRange;
@@ -1519,17 +1517,18 @@ public abstract class CompositeEditorPanel extends JPanel
@Override @Override
public boolean isKeyConsumed(KeyStroke keyStroke) { public boolean isKeyConsumed(KeyStroke keyStroke) {
if (isEditing()) { if (isEditing()) {
// don't let actions through when editing our table
return true; return true;
} }
// don't let actions through when editing our table // TODO this should no longer be needed
return !hasLocalActionForKeyStroke(keyStroke); return !hasLocalActionForKeyStroke(keyStroke);
} }
private boolean hasLocalActionForKeyStroke(KeyStroke keyStroke) { private boolean hasLocalActionForKeyStroke(KeyStroke keyStroke) {
Plugin plugin = provider.getPlugin(); Plugin plugin = provider.getPlugin();
PluginTool tool = plugin.getTool(); PluginTool tool = plugin.getTool();
List<DockingActionIf> actions = tool.getDockingActionsByOwnerName(plugin.getName()); Set<DockingActionIf> actions = tool.getDockingActionsByOwnerName(plugin.getName());
for (DockingActionIf action : actions) { for (DockingActionIf action : actions) {
if (!(action instanceof CompositeEditorTableAction)) { if (!(action instanceof CompositeEditorTableAction)) {
continue; continue;
@@ -206,11 +206,6 @@ public abstract class CompositeEditorProvider extends ComponentProviderAdapter
@Override @Override
public void dispose() { public void dispose() {
CompositeEditorTableAction[] allActions = actionMgr.getAllActions();
for (CompositeEditorTableAction allAction : allActions) {
tool.removeLocalAction(this, allAction);
}
tool.showComponentProvider(this, false);
tool.removeComponentProvider(this); tool.removeComponentProvider(this);
for (EditorListener el : listeners) { for (EditorListener el : listeners) {
el.closed(this); el.closed(this);
@@ -18,56 +18,39 @@ package ghidra.app.plugin.core.compositeeditor;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.ActionContext; import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.KeyBindingData; import docking.action.KeyBindingData;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.data.CycleGroup; import ghidra.program.model.data.CycleGroup;
/** /**
* Action to apply a data type cycle group. * Action to apply a data type cycle group. For use in the composite data type editor.
* For use in the composite data type editor.
* This action has help associated with it.
*/ */
public class CycleGroupAction extends CompositeEditorTableAction implements OptionsChangeListener { public class CycleGroupAction extends CompositeEditorTableAction {
private final static String GROUP_NAME = CYCLE_ACTION_GROUP; private final static String GROUP_NAME = CYCLE_ACTION_GROUP;
private CycleGroup cycleGroup; private CycleGroup cycleGroup;
/**
* Creates an action for applying a data type cycle group.
* @param owner the plugin that owns this action
* @param cycleGroup the data type cycle group
*/
public CycleGroupAction(CompositeEditorProvider provider, CycleGroup cycleGroup) { public CycleGroupAction(CompositeEditorProvider provider, CycleGroup cycleGroup) {
super(provider, cycleGroup.getName(), GROUP_NAME, super(provider, cycleGroup.getName(), GROUP_NAME,
new String[] { "Cycle", cycleGroup.getName() }, new String[] { "Cycle", cycleGroup.getName() },
new String[] { "Cycle", cycleGroup.getName() }, null); new String[] { "Cycle", cycleGroup.getName() }, null);
this.cycleGroup = cycleGroup; this.cycleGroup = cycleGroup;
// register an action that allows users to edit keystrokes initKeyStroke(cycleGroup.getDefaultKeyStroke());
DockingAction action = new DummyKeyBindingsOptionsAction(cycleGroup.getName(), }
cycleGroup.getDefaultKeyStroke());
tool.addAction(action); private void initKeyStroke(KeyStroke keyStroke) {
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS); if (keyStroke == null) {
KeyStroke defaultKeyStroke = cycleGroup.getDefaultKeyStroke(); return;
KeyStroke keyStroke = options.getKeyStroke(action.getFullName(), defaultKeyStroke); }
options.addOptionsChangeListener(this);
setKeyBindingData(new KeyBindingData(keyStroke));
if (!defaultKeyStroke.equals(keyStroke)) { }
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke)); @Override
} public boolean usesSharedKeyBinding() {
else { return true;
setKeyBindingData(new KeyBindingData(keyStroke));
}
adjustEnablement();
} }
/**
* Gets the data type cycle group for this action.
*/
public CycleGroup getCycleGroup() { public CycleGroup getCycleGroup() {
return cycleGroup; return cycleGroup;
} }
@@ -87,12 +70,4 @@ public class CycleGroupAction extends CompositeEditorTableAction implements Opti
public String getHelpName() { public String getHelpName() {
return "Cycle"; return "Cycle";
} }
@Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
if (name.startsWith(cycleGroup.getName())) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
} }
@@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,11 +15,16 @@
*/ */
package ghidra.app.plugin.core.data; package ghidra.app.plugin.core.data;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.util.datatype.DataTypeSelectionDialog; import ghidra.app.util.datatype.DataTypeSelectionDialog;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRange; import ghidra.program.model.address.AddressRange;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
@@ -29,18 +33,10 @@ import ghidra.program.util.*;
import ghidra.util.SystemUtilities; import ghidra.util.SystemUtilities;
import ghidra.util.data.DataTypeParser.AllowedDataTypes; import ghidra.util.data.DataTypeParser.AllowedDataTypes;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
/** /**
* An action that allows the user to change or select a data type. * An action that allows the user to change or select a data type.
*/ */
public class ChooseDataTypeAction extends DockingAction implements OptionsChangeListener { public class ChooseDataTypeAction extends DockingAction {
private DataPlugin plugin; private DataPlugin plugin;
private static final KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_T, 0); private static final KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_T, 0);
@@ -48,34 +44,22 @@ public class ChooseDataTypeAction extends DockingAction implements OptionsChange
public ChooseDataTypeAction(DataPlugin plugin) { public ChooseDataTypeAction(DataPlugin plugin) {
super(ACTION_NAME, plugin.getName(), false); super(ACTION_NAME, plugin.getName(), false);
this.plugin = plugin; this.plugin = plugin;
PluginTool tool = plugin.getTool(); initKeyStroke(KEY_BINDING);
DockingAction action = new DummyKeyBindingsOptionsAction(ACTION_NAME, KEY_BINDING); }
tool.addAction(action);
// setup options to know when the dummy key binding is changed private void initKeyStroke(KeyStroke keyStroke) {
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS); if (keyStroke == null) {
KeyStroke keyStroke = options.getKeyStroke(action.getFullName(), KEY_BINDING); return;
if (!KEY_BINDING.equals(keyStroke)) {
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
else {
setKeyBindingData(new KeyBindingData(keyStroke));
} }
options.addOptionsChangeListener(this); setKeyBindingData(new KeyBindingData(keyStroke));
} }
@Override @Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) { public boolean usesSharedKeyBinding() {
KeyStroke keyStroke = (KeyStroke) newValue; return true;
if (name.startsWith(ACTION_NAME)) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
} }
@Override @Override
@@ -191,9 +175,8 @@ public class ChooseDataTypeAction extends DockingAction implements OptionsChange
int defaultPointerSize) { int defaultPointerSize) {
PluginTool tool = plugin.getTool(); PluginTool tool = plugin.getTool();
Data data = plugin.getDataUnit(context); Data data = plugin.getDataUnit(context);
DataTypeSelectionDialog selectionDialog = DataTypeSelectionDialog selectionDialog = new DataTypeSelectionDialog(tool,
new DataTypeSelectionDialog(tool, data.getProgram().getDataTypeManager(), maxElements, data.getProgram().getDataTypeManager(), maxElements, AllowedDataTypes.ALL);
AllowedDataTypes.ALL);
DataType currentDataType = data.getBaseDataType(); DataType currentDataType = data.getBaseDataType();
selectionDialog.setInitialDataType(currentDataType); selectionDialog.setInitialDataType(currentDataType);
tool.showDialog(selectionDialog); tool.showDialog(selectionDialog);
@@ -27,16 +27,14 @@ import ghidra.app.cmd.data.CreateArrayCmd;
import ghidra.app.cmd.data.CreateArrayInStructureCmd; import ghidra.app.cmd.data.CreateArrayInStructureCmd;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.framework.cmd.Command; import ghidra.framework.cmd.Command;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.util.*; import ghidra.program.util.*;
class CreateArrayAction extends DockingAction implements OptionsChangeListener { class CreateArrayAction extends DockingAction {
private static final KeyStroke DEFAULT_KEY_STROKE = private static final KeyStroke DEFAULT_KEY_STROKE =
KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, 0); KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, 0);
@@ -51,26 +49,21 @@ class CreateArrayAction extends DockingAction implements OptionsChangeListener {
setPopupMenuData(new MenuData(CREATE_ARRAY_POPUP_MENU, "BasicData")); setPopupMenuData(new MenuData(CREATE_ARRAY_POPUP_MENU, "BasicData"));
setEnabled(true); setEnabled(true);
initializeKeybinding();
initKeyStroke(DEFAULT_KEY_STROKE);
} }
private void initializeKeybinding() { private void initKeyStroke(KeyStroke keyStroke) {
PluginTool tool = plugin.getTool(); if (keyStroke == null) {
DockingAction dummyKeybindingsAction = return;
new DummyKeyBindingsOptionsAction(getName(), DEFAULT_KEY_STROKE); }
tool.addAction(dummyKeybindingsAction);
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke =
options.getKeyStroke(dummyKeybindingsAction.getFullName(), DEFAULT_KEY_STROKE);
if (!DEFAULT_KEY_STROKE.equals(keyStroke)) { setKeyBindingData(new KeyBindingData(keyStroke));
// user-defined keystroke }
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
} @Override
else { public boolean usesSharedKeyBinding() {
setKeyBindingData(new KeyBindingData(keyStroke)); return true;
}
} }
@Override @Override
@@ -342,12 +335,4 @@ class CreateArrayAction extends DockingAction implements OptionsChangeListener {
return false; return false;
} }
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
if (optionName.startsWith(getName())) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
} }
@@ -18,13 +18,11 @@ package ghidra.app.plugin.core.data;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.DockingAction;
import docking.action.KeyBindingData;
import ghidra.app.cmd.data.*; import ghidra.app.cmd.data.*;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.framework.cmd.BackgroundCommand; import ghidra.framework.cmd.BackgroundCommand;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.CycleGroup; import ghidra.program.model.data.CycleGroup;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
@@ -37,48 +35,32 @@ import ghidra.util.Msg;
* <code>CycleGroupAction</code> cycles data through a series of data types * <code>CycleGroupAction</code> cycles data through a series of data types
* defined by a <code>CycleGroup</code>. * defined by a <code>CycleGroup</code>.
*/ */
public class CycleGroupAction extends DockingAction implements OptionsChangeListener { public class CycleGroupAction extends DockingAction {
private DataPlugin plugin; private DataPlugin plugin;
private CycleGroup cycleGroup; private CycleGroup cycleGroup;
/**
* Creates a new instance of the action.
*
* @param plugin Data Plugin instance
*/
CycleGroupAction(CycleGroup group, DataPlugin plugin) { CycleGroupAction(CycleGroup group, DataPlugin plugin) {
super(group.getName(), plugin.getName(), false); super(group.getName(), plugin.getName(), false);
this.plugin = plugin; this.plugin = plugin;
this.cycleGroup = group; this.cycleGroup = group;
// register an action that allows users to edit keystrokes initKeyStroke(cycleGroup.getDefaultKeyStroke());
PluginTool tool = plugin.getTool(); }
DockingAction action = new DummyKeyBindingsOptionsAction(cycleGroup.getName(),
cycleGroup.getDefaultKeyStroke()); private void initKeyStroke(KeyStroke keyStroke) {
tool.addAction(action); if (keyStroke == null) {
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS); return;
KeyStroke defaultKeyStroke = cycleGroup.getDefaultKeyStroke(); }
KeyStroke keyStroke = options.getKeyStroke(action.getFullName(), defaultKeyStroke);
options.addOptionsChangeListener(this); setKeyBindingData(new KeyBindingData(keyStroke));
}
setPopupMenuData(
new MenuData(new String[] { "Data", "Cycle", group.getName() }, null, null)); @Override
public boolean usesSharedKeyBinding() {
if (!defaultKeyStroke.equals(keyStroke)) { return true;
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
else {
setKeyBindingData(new KeyBindingData(keyStroke));
}
setEnabled(true);
} }
/**
* @see ghidra.framework.plugintool.DockingAction#dispose()
*/
@Override @Override
public void dispose() { public void dispose() {
cycleGroup = null; cycleGroup = null;
@@ -86,9 +68,6 @@ public class CycleGroupAction extends DockingAction implements OptionsChangeList
super.dispose(); super.dispose();
} }
/*
* @see docking.DockableAction#isValidContext(java.lang.Object)
*/
@Override @Override
public boolean isEnabledForContext(ActionContext context) { public boolean isEnabledForContext(ActionContext context) {
Object contextObject = context.getContextObject(); Object contextObject = context.getContextObject();
@@ -192,12 +171,4 @@ public class CycleGroupAction extends DockingAction implements OptionsChangeList
} }
} }
} }
@Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
if (name.startsWith(cycleGroup.getName())) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
} }
@@ -17,51 +17,46 @@ package ghidra.app.plugin.core.data;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.action.*; import docking.action.KeyBindingData;
import docking.tool.util.DockingToolConstants; import docking.action.MenuData;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction; import ghidra.app.context.ListingContextAction;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
/** /**
* Base class for actions to create data types * Base class for actions to create data types
*/ */
class DataAction extends ListingContextAction implements OptionsChangeListener { class DataAction extends ListingContextAction {
protected DataType dataType; protected DataType dataType;
protected DataPlugin plugin; protected DataPlugin plugin;
private String actionName;
private DummyKeyBindingsOptionsAction dummyKeybindingsAction;
public DataAction(DataType dataType, DataPlugin plugin) { public DataAction(DataType dataType, DataPlugin plugin) {
this("Define " + dataType.getDisplayName(), "Data", dataType, plugin); this("Define " + dataType.getDisplayName(), "Data", dataType, plugin);
} }
/**
* Constructor
*
* @param name action name
* @param group the action's group
* @param dataType the data type used by this action
* @param plugin the plugin that owns this action
*/
public DataAction(String name, String group, DataType dataType, DataPlugin plugin) { public DataAction(String name, String group, DataType dataType, DataPlugin plugin) {
super(name, plugin.getName(), false); super(name, plugin.getName(), false);
this.actionName = name;
this.plugin = plugin; this.plugin = plugin;
this.dataType = dataType; this.dataType = dataType;
setPopupMenuData(new MenuData(new String[] { "Data", dataType.getDisplayName() }, group)); setPopupMenuData(new MenuData(new String[] { "Data", dataType.getDisplayName() }, group));
assignHelpID(dataType); assignHelpID(dataType);
initKeyStroke(getDefaultKeyStroke());
initializeKeybinding();
} }
private void initializeKeybinding() { @Override
PluginTool tool = plugin.getTool(); public boolean usesSharedKeyBinding() {
dummyKeybindingsAction = return true;
new DummyKeyBindingsOptionsAction(actionName, getDefaultKeyStroke());
tool.addAction(dummyKeybindingsAction);
ToolOptions options = tool.getOptions(DockingToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke =
options.getKeyStroke(dummyKeybindingsAction.getFullName(), getDefaultKeyStroke());
initKeyStroke(keyStroke);
} }
protected KeyStroke getDefaultKeyStroke() { protected KeyStroke getDefaultKeyStroke() {
@@ -73,12 +68,11 @@ class DataAction extends ListingContextAction implements OptionsChangeListener {
return; return;
} }
// we don't have a default keybinding, so any value implies user-defined setKeyBindingData(new KeyBindingData(keyStroke));
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
} }
protected DockingAction getDummyKeyBindingAction() { DataType getDataType() {
return dummyKeybindingsAction; return dataType;
} }
@Override @Override
@@ -99,19 +93,6 @@ class DataAction extends ListingContextAction implements OptionsChangeListener {
return plugin.isCreateDataAllowed(context); return plugin.isCreateDataAllowed(context);
} }
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
if (optionName.startsWith(actionName)) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
DataType getDataType() {
return dataType;
}
// Set the help ID according to the data type // Set the help ID according to the data type
private void assignHelpID(DataType dt) { private void assignHelpID(DataType dt) {
String helpID = "Favorites"; String helpID = "Favorites";
@@ -15,13 +15,9 @@
*/ */
package ghidra.app.plugin.core.datamgr.actions; package ghidra.app.plugin.core.datamgr.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.ActionContext; import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.MenuData; import docking.action.MenuData;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
@@ -38,8 +34,6 @@ public class FindReferencesToDataTypeAction extends AbstractFindReferencesDataTy
String menuGroup = "ZVeryLast"; // it's own group; on the bottom String menuGroup = "ZVeryLast"; // it's own group; on the bottom
setPopupMenuData(new MenuData(new String[] { "Find Uses of" }, null, menuGroup)); setPopupMenuData(new MenuData(new String[] { "Find Uses of" }, null, menuGroup));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_F,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
} }
@Override @Override
@@ -18,11 +18,8 @@ package ghidra.app.plugin.core.datawindow;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.DockingAction;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.events.ProgramSelectionPluginEvent; import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.events.ViewChangedPluginEvent; import ghidra.app.events.ViewChangedPluginEvent;
@@ -31,10 +28,9 @@ import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.services.GoToService; import ghidra.app.services.GoToService;
import ghidra.app.services.ProgramTreeService; import ghidra.app.services.ProgramTreeService;
import ghidra.framework.model.*; import ghidra.framework.model.*;
import ghidra.framework.options.*; import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.*; import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus; import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.address.AddressRangeIterator; import ghidra.program.model.address.AddressRangeIterator;
import ghidra.program.model.address.AddressSet; import ghidra.program.model.address.AddressSet;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
@@ -42,10 +38,9 @@ import ghidra.program.model.data.DataTypeManager;
import ghidra.program.model.listing.Data; import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.util.*; import ghidra.program.util.*;
import ghidra.util.table.GhidraTable;
import ghidra.util.table.SelectionNavigationAction; import ghidra.util.table.SelectionNavigationAction;
import ghidra.util.table.actions.MakeProgramSelectionAction;
import ghidra.util.task.SwingUpdateManager; import ghidra.util.task.SwingUpdateManager;
import resources.ResourceManager;
//@formatter:off //@formatter:off
@PluginInfo( @PluginInfo(
@@ -60,10 +55,7 @@ import resources.ResourceManager;
eventsConsumed = { ViewChangedPluginEvent.class } eventsConsumed = { ViewChangedPluginEvent.class }
) )
//@formatter:on //@formatter:on
public class DataWindowPlugin extends ProgramPlugin public class DataWindowPlugin extends ProgramPlugin implements DomainObjectListener {
implements DomainObjectListener, OptionsChangeListener {
// private final static String[] DISPLAY_MENU_PATH = { ToolConstants.MENU_VIEW, "Defined Data..." };
private DockingAction selectAction; private DockingAction selectAction;
private FilterAction filterAction; private FilterAction filterAction;
@@ -73,24 +65,12 @@ public class DataWindowPlugin extends ProgramPlugin
private SwingUpdateManager reloadUpdateMgr; private SwingUpdateManager reloadUpdateMgr;
private boolean resetTypesNeeded; private boolean resetTypesNeeded;
///////////////////////////////////////////////////////////
public DataWindowPlugin(PluginTool tool) { public DataWindowPlugin(PluginTool tool) {
super(tool, true, true); super(tool, true, true);
resetUpdateMgr = new SwingUpdateManager(100, 60000, new Runnable() { resetUpdateMgr = new SwingUpdateManager(100, 60000, () -> doReset());
@Override
public void run() {
doReset();
}
});
reloadUpdateMgr = new SwingUpdateManager(100, 60000, new Runnable() { reloadUpdateMgr = new SwingUpdateManager(100, 60000, () -> doReload());
@Override
public void run() {
doReload();
}
});
} }
@Override @Override
@@ -112,12 +92,6 @@ public class DataWindowPlugin extends ProgramPlugin
super.dispose(); super.dispose();
} }
////////////////////////////////////////////////////////////////////////////
//
// Implementation of DomainObjectListener
//
////////////////////////////////////////////////////////////////////////////
@Override @Override
public void domainObjectChanged(DomainObjectChangedEvent ev) { public void domainObjectChanged(DomainObjectChangedEvent ev) {
if (ev.containsEvent(DomainObject.DO_OBJECT_RESTORED)) { if (ev.containsEvent(DomainObject.DO_OBJECT_RESTORED)) {
@@ -153,8 +127,6 @@ public class DataWindowPlugin extends ProgramPlugin
} }
} }
////////////////////////////////////////////////////////////////////////////
void reload() { void reload() {
reloadUpdateMgr.update(); reloadUpdateMgr.update();
} }
@@ -163,9 +135,6 @@ public class DataWindowPlugin extends ProgramPlugin
provider.reload(); provider.reload();
} }
/* (non-Javadoc)
* @see ghidra.framework.plugintool.Plugin#processEvent(ghidra.framework.plugintool.PluginEvent)
*/
@Override @Override
public void processEvent(PluginEvent event) { public void processEvent(PluginEvent event) {
if (event instanceof ViewChangedPluginEvent) { if (event instanceof ViewChangedPluginEvent) {
@@ -193,8 +162,6 @@ public class DataWindowPlugin extends ProgramPlugin
filterAction.programClosed(); filterAction.programClosed();
} }
////////////////////////////////////////////////////////////////////////////
Program getProgram() { Program getProgram() {
return currentProgram; return currentProgram;
} }
@@ -208,36 +175,17 @@ public class DataWindowPlugin extends ProgramPlugin
return provider; return provider;
} }
////////////////////////////////////////////////////////////////////////////
/** /**
* Create the action objects for this plugin. * Create the action objects for this plugin.
*/ */
private void createActions() { private void createActions() {
selectAction = new DockingAction("Make Selection", getName(), false) { selectAction = new MakeProgramSelectionAction(getName(), provider.getTable()) {
@Override @Override
public void actionPerformed(ActionContext context) { protected void makeSelection(ActionContext context) {
selectData(provider.selectData()); selectData(provider.selectData());
} }
@Override
public boolean isEnabledForContext(ActionContext context) {
if (!(context instanceof DataWindowContext)) {
return false;
}
DataWindowContext dataWindowContext = (DataWindowContext) context;
GhidraTable table = dataWindowContext.getDataTable();
return table.getSelectedRows().length > 0;
}
}; };
selectAction.setEnabled(false);
ImageIcon icon = ResourceManager.loadImage("images/text_align_justify.png");
selectAction.setPopupMenuData(new MenuData(new String[] { "Make Selection" }, icon));
selectAction.setDescription("Selects currently selected data in table");
selectAction.setToolBarData(new ToolBarData(icon));
installDummyAction(selectAction);
tool.addLocalAction(provider, selectAction); tool.addLocalAction(provider, selectAction);
@@ -249,28 +197,6 @@ public class DataWindowPlugin extends ProgramPlugin
tool.addLocalAction(provider, selectionAction); tool.addLocalAction(provider, selectionAction);
} }
private void installDummyAction(DockingAction action) {
DummyKeyBindingsOptionsAction dummyAction =
new DummyKeyBindingsOptionsAction(action.getName(), null);
tool.addAction(dummyAction);
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke = options.getKeyStroke(dummyAction.getFullName(), null);
if (keyStroke != null) {
action.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue, Object newValue) {
if (optionName.startsWith(selectAction.getName())) {
KeyStroke keyStroke = (KeyStroke) newValue;
selectAction.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
void selectData(ProgramSelection selection) { void selectData(ProgramSelection selection) {
ProgramSelectionPluginEvent pspe = ProgramSelectionPluginEvent pspe =
new ProgramSelectionPluginEvent("Selection", selection, currentProgram); new ProgramSelectionPluginEvent("Selection", selection, currentProgram);
@@ -32,8 +32,8 @@ import javax.swing.undo.UndoableEdit;
import docking.ActionContext; import docking.ActionContext;
import docking.ComponentProvider; import docking.ComponentProvider;
import docking.action.*; import docking.action.*;
import docking.actions.KeyBindingUtils;
import docking.options.editor.FontPropertyEditor; import docking.options.editor.FontPropertyEditor;
import docking.util.KeyBindingUtils;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.filechooser.GhidraFileChooser; import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.framework.options.SaveState; import ghidra.framework.options.SaveState;
@@ -23,9 +23,7 @@ import docking.ActionContext;
import docking.action.*; import docking.action.*;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.util.datatype.DataTypeSelectionDialog; import ghidra.app.util.datatype.DataTypeSelectionDialog;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeManager; import ghidra.program.model.data.DataTypeManager;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
@@ -36,7 +34,7 @@ import ghidra.util.data.DataTypeParser.AllowedDataTypes;
/** /**
* An action that allows the user to change or select a data type. * An action that allows the user to change or select a data type.
*/ */
public class ChooseDataTypeAction extends DockingAction implements OptionsChangeListener { public class ChooseDataTypeAction extends DockingAction {
private static final KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_T, 0); private static final KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_T, 0);
private final static String ACTION_NAME = "Choose Data Type"; private final static String ACTION_NAME = "Choose Data Type";
@@ -44,37 +42,24 @@ public class ChooseDataTypeAction extends DockingAction implements OptionsChange
public ChooseDataTypeAction(FunctionPlugin plugin) { public ChooseDataTypeAction(FunctionPlugin plugin) {
super(ACTION_NAME, plugin.getName(), false); super(ACTION_NAME, plugin.getName(), false);
this.plugin = plugin; this.plugin = plugin;
// setup key binding management
PluginTool tool = plugin.getTool();
DockingAction action = new DummyKeyBindingsOptionsAction(ACTION_NAME, KEY_BINDING);
tool.addAction(action);
// setup options to know when the dummy key binding is changed
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
KeyStroke keyStroke = options.getKeyStroke(action.getFullName(), KEY_BINDING);
setPopupMenu(plugin.getDataActionMenuName(null), true);
if (!KEY_BINDING.equals(keyStroke)) {
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
else {
setKeyBindingData(new KeyBindingData(keyStroke));
}
options.addOptionsChangeListener(this);
setHelpLocation(new HelpLocation("DataTypeEditors", "DataTypeSelectionDialog")); setHelpLocation(new HelpLocation("DataTypeEditors", "DataTypeSelectionDialog"));
initKeyStroke(KEY_BINDING);
}
private void initKeyStroke(KeyStroke keyStroke) {
if (keyStroke == null) {
return;
}
setKeyBindingData(new KeyBindingData(keyStroke));
} }
@Override @Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) { public boolean usesSharedKeyBinding() {
KeyStroke keyStroke = (KeyStroke) newValue; return true;
if (name.startsWith(ACTION_NAME)) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
} }
@Override @Override
@@ -19,20 +19,18 @@ import java.awt.event.KeyEvent;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.action.*; import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.dialogs.NumberInputDialog; import docking.widgets.dialogs.NumberInputDialog;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction; import ghidra.app.context.ListingContextAction;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.listing.Function; import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Variable; import ghidra.program.model.listing.Variable;
import ghidra.program.util.*; import ghidra.program.util.*;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
class CreateArrayAction extends ListingContextAction implements OptionsChangeListener { class CreateArrayAction extends ListingContextAction {
private static final KeyStroke DEFAULT_KEY_STROKE = private static final KeyStroke DEFAULT_KEY_STROKE =
KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, 0); KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, 0);
@@ -44,26 +42,21 @@ class CreateArrayAction extends ListingContextAction implements OptionsChangeLis
setPopupMenu(plugin.getDataActionMenuName(null)); setPopupMenu(plugin.getDataActionMenuName(null));
setHelpLocation(new HelpLocation(plugin.getName(), "DataType")); setHelpLocation(new HelpLocation(plugin.getName(), "DataType"));
initializeKeybinding();
initKeyStroke(DEFAULT_KEY_STROKE);
} }
private void initializeKeybinding() { private void initKeyStroke(KeyStroke keyStroke) {
PluginTool tool = plugin.getTool(); if (keyStroke == null) {
DockingAction dummyKeybindingsAction = return;
new DummyKeyBindingsOptionsAction(getName(), DEFAULT_KEY_STROKE); }
tool.addAction(dummyKeybindingsAction);
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke =
options.getKeyStroke(dummyKeybindingsAction.getFullName(), DEFAULT_KEY_STROKE);
if (!DEFAULT_KEY_STROKE.equals(keyStroke)) { setKeyBindingData(new KeyBindingData(keyStroke));
// user-defined keystroke }
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
} @Override
else { public boolean usesSharedKeyBinding() {
setKeyBindingData(new KeyBindingData(keyStroke)); return true;
}
} }
private void setPopupMenu(String name) { private void setPopupMenu(String name) {
@@ -141,13 +134,4 @@ class CreateArrayAction extends ListingContextAction implements OptionsChangeLis
return dialog.getValue(); return dialog.getValue();
} }
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
if (optionName.startsWith(getName())) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
} }
@@ -17,13 +17,11 @@ package ghidra.app.plugin.core.function;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.action.*; import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction; import ghidra.app.context.ListingContextAction;
import ghidra.app.util.HelpTopics; import ghidra.app.util.HelpTopics;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.data.CycleGroup; import ghidra.program.model.data.CycleGroup;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
@@ -34,42 +32,33 @@ import ghidra.util.HelpLocation;
* <code>CycleGroupAction</code> cycles data through a series * <code>CycleGroupAction</code> cycles data through a series
* of data types defined by a <code>CycleGroup</code>. * of data types defined by a <code>CycleGroup</code>.
*/ */
public class CycleGroupAction extends ListingContextAction implements OptionsChangeListener { public class CycleGroupAction extends ListingContextAction {
private FunctionPlugin plugin; private FunctionPlugin plugin;
private CycleGroup cycleGroup; private CycleGroup cycleGroup;
/**
* Creates a new instance of the action.
*
* @param plugin Data Plugin instance
*/
CycleGroupAction(CycleGroup group, FunctionPlugin plugin) { CycleGroupAction(CycleGroup group, FunctionPlugin plugin) {
super(group.getName(), plugin.getName(), false); super(group.getName(), plugin.getName(), false);
this.plugin = plugin; this.plugin = plugin;
this.cycleGroup = group; this.cycleGroup = group;
setPopupMenu(plugin.getDataActionMenuName(null), true); setPopupMenu(plugin.getDataActionMenuName(null), true);
// register an action that allows users to edit keystrokes
PluginTool tool = plugin.getTool();
DockingAction action = new DummyKeyBindingsOptionsAction(cycleGroup.getName(),
cycleGroup.getDefaultKeyStroke());
tool.addAction(action);
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
KeyStroke defaultKeyStroke = cycleGroup.getDefaultKeyStroke();
KeyStroke keyStroke = options.getKeyStroke(action.getFullName(), defaultKeyStroke);
if (!defaultKeyStroke.equals(keyStroke)) {
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
else {
setKeyBindingData(new KeyBindingData(keyStroke));
}
options.addOptionsChangeListener(this);
setHelpLocation(new HelpLocation(HelpTopics.DATA, group.getName())); setHelpLocation(new HelpLocation(HelpTopics.DATA, group.getName()));
initKeyStroke(cycleGroup.getDefaultKeyStroke());
}
private void initKeyStroke(KeyStroke keyStroke) {
if (keyStroke == null) {
return;
}
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
} }
private void setPopupMenu(String name, boolean isSignatureAction) { private void setPopupMenu(String name, boolean isSignatureAction) {
@@ -95,9 +84,6 @@ public class CycleGroupAction extends ListingContextAction implements OptionsCha
return false; return false;
} }
/**
* @see ghidra.framework.plugintool.DockingAction#dispose()
*/
@Override @Override
public void dispose() { public void dispose() {
cycleGroup = null; cycleGroup = null;
@@ -115,12 +101,4 @@ public class CycleGroupAction extends ListingContextAction implements OptionsCha
} }
} }
} }
@Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) {
KeyStroke keyStroke = (KeyStroke) newValue;
if (name.startsWith(cycleGroup.getName())) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
} }
@@ -17,12 +17,10 @@ package ghidra.app.plugin.core.function;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.action.*; import docking.action.KeyBindingData;
import docking.tool.util.DockingToolConstants; import docking.action.MenuData;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction; import ghidra.app.context.ListingContextAction;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.program.util.VariableLocation; import ghidra.program.util.VariableLocation;
@@ -31,13 +29,11 @@ import ghidra.util.HelpLocation;
/** /**
* Base class for actions to create data types * Base class for actions to create data types
*/ */
class DataAction extends ListingContextAction implements OptionsChangeListener { class DataAction extends ListingContextAction {
private final String group; private final String group;
protected DataType dataType; protected DataType dataType;
protected FunctionPlugin plugin; protected FunctionPlugin plugin;
private String actionName;
private DummyKeyBindingsOptionsAction dummyKeybindingsAction;
public DataAction(DataType dataType, FunctionPlugin plugin) { public DataAction(DataType dataType, FunctionPlugin plugin) {
this("Define " + dataType.getDisplayName(), "Function", dataType, plugin); this("Define " + dataType.getDisplayName(), "Function", dataType, plugin);
@@ -46,26 +42,19 @@ class DataAction extends ListingContextAction implements OptionsChangeListener {
public DataAction(String name, String group, DataType dataType, FunctionPlugin plugin) { public DataAction(String name, String group, DataType dataType, FunctionPlugin plugin) {
super(name, plugin.getName(), false); super(name, plugin.getName(), false);
this.actionName = name;
this.group = group; this.group = group;
this.plugin = plugin; this.plugin = plugin;
this.dataType = dataType; this.dataType = dataType;
setPopupMenu(plugin.getDataActionMenuName(null), true); setPopupMenu(plugin.getDataActionMenuName(null), true);
setHelpLocation(new HelpLocation(plugin.getName(), "DataType")); setHelpLocation(new HelpLocation(plugin.getName(), "DataType"));
initializeKeybinding();
initKeyStroke(getDefaultKeyStroke());
} }
private void initializeKeybinding() { @Override
PluginTool tool = plugin.getTool(); public boolean usesSharedKeyBinding() {
dummyKeybindingsAction = return true;
new DummyKeyBindingsOptionsAction(actionName, getDefaultKeyStroke());
tool.addAction(dummyKeybindingsAction);
ToolOptions options = tool.getOptions(DockingToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke =
options.getKeyStroke(dummyKeybindingsAction.getFullName(), getDefaultKeyStroke());
initKeyStroke(keyStroke);
} }
protected KeyStroke getDefaultKeyStroke() { protected KeyStroke getDefaultKeyStroke() {
@@ -77,12 +66,7 @@ class DataAction extends ListingContextAction implements OptionsChangeListener {
return; return;
} }
// we don't have a default keybinding, so any value implies user-defined setKeyBindingData(new KeyBindingData(keyStroke));
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
protected DockingAction getDummyKeyBindingAction() {
return dummyKeybindingsAction;
} }
void setPopupMenu(String name, boolean isSignatureAction) { void setPopupMenu(String name, boolean isSignatureAction) {
@@ -98,11 +82,6 @@ class DataAction extends ListingContextAction implements OptionsChangeListener {
super.dispose(); super.dispose();
} }
@Override
public void actionPerformed(ListingActionContext context) {
plugin.createData(dataType, context, true);
}
@Override @Override
protected boolean isEnabledForContext(ListingActionContext context) { protected boolean isEnabledForContext(ListingActionContext context) {
if (context.hasSelection() || context.getAddress() == null) { if (context.hasSelection() || context.getAddress() == null) {
@@ -121,11 +100,7 @@ class DataAction extends ListingContextAction implements OptionsChangeListener {
} }
@Override @Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue, public void actionPerformed(ListingActionContext context) {
Object newValue) { plugin.createData(dataType, context, true);
KeyStroke keyStroke = (KeyStroke) newValue;
if (optionName.startsWith(actionName)) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
} }
} }
@@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -28,7 +27,7 @@ import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.text.*; import javax.swing.text.*;
import docking.util.KeyBindingUtils; import docking.actions.KeyBindingUtils;
class FunctionSignatureTextField extends JTextPane { class FunctionSignatureTextField extends JTextPane {
private static final String ENTER_ACTION_NAME = "ENTER"; private static final String ENTER_ACTION_NAME = "ENTER";
@@ -15,13 +15,9 @@
*/ */
package ghidra.app.plugin.core.functioncompare; package ghidra.app.plugin.core.functioncompare;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList; import java.util.ArrayList;
import docking.ActionContext; import docking.ActionContext;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData; import docking.action.MenuData;
import ghidra.app.context.*; import ghidra.app.context.*;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
@@ -52,12 +48,6 @@ public class CompareFunctionsAction extends ProgramContextAction {
FunctionComparisonPlugin.FUNCTION_MENU_SUBGROUP, MenuData.NO_MNEMONIC, FunctionComparisonPlugin.FUNCTION_MENU_SUBGROUP, MenuData.NO_MNEMONIC,
"Z_End" /* See the FunctionPlugin for this value */)); "Z_End" /* See the FunctionPlugin for this value */));
// TODO this binding needs to be revisited; probably needs to be more modified, like
// Ctrl-Shift-F; it currently interferes with other uses of Ctrl-F, usually when
// performing a find function.
setKeyBindingData(new KeyBindingData(KeyEvent.VK_F,
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
setHelpLocation(new HelpLocation("FunctionComparison", "Compare_Selected_Functions")); setHelpLocation(new HelpLocation("FunctionComparison", "Compare_Selected_Functions"));
} }
@@ -18,7 +18,6 @@ package ghidra.app.plugin.core.functionwindow;
import java.util.List; import java.util.List;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.*;
@@ -30,11 +29,9 @@ import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.plugin.core.functioncompare.FunctionComparisonProvider; import ghidra.app.plugin.core.functioncompare.FunctionComparisonProvider;
import ghidra.app.plugin.core.functioncompare.FunctionComparisonProviderManager; import ghidra.app.plugin.core.functioncompare.FunctionComparisonProviderManager;
import ghidra.framework.model.*; import ghidra.framework.model.*;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginInfo; import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginStatus; import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.Symbol; import ghidra.program.model.symbol.Symbol;
@@ -42,6 +39,7 @@ import ghidra.program.util.*;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.table.GhidraTable; import ghidra.util.table.GhidraTable;
import ghidra.util.table.SelectionNavigationAction; import ghidra.util.table.SelectionNavigationAction;
import ghidra.util.table.actions.MakeProgramSelectionAction;
import ghidra.util.task.SwingUpdateManager; import ghidra.util.task.SwingUpdateManager;
import resources.ResourceManager; import resources.ResourceManager;
@@ -55,8 +53,7 @@ import resources.ResourceManager;
eventsConsumed = { ProgramClosedPluginEvent.class } eventsConsumed = { ProgramClosedPluginEvent.class }
) )
//@formatter:on //@formatter:on
public class FunctionWindowPlugin extends ProgramPlugin public class FunctionWindowPlugin extends ProgramPlugin implements DomainObjectListener {
implements DomainObjectListener, OptionsChangeListener {
private DockingAction selectAction; private DockingAction selectAction;
private DockingAction compareAction; private DockingAction compareAction;
@@ -64,19 +61,12 @@ public class FunctionWindowPlugin extends ProgramPlugin
private SwingUpdateManager swingMgr; private SwingUpdateManager swingMgr;
private FunctionComparisonProviderManager functionComparisonManager; private FunctionComparisonProviderManager functionComparisonManager;
///////////////////////////////////////////////////////////
public FunctionWindowPlugin(PluginTool tool) { public FunctionWindowPlugin(PluginTool tool) {
super(tool, true, false); super(tool, true, false);
functionComparisonManager = new FunctionComparisonProviderManager(this); functionComparisonManager = new FunctionComparisonProviderManager(this);
swingMgr = new SwingUpdateManager(1000, new Runnable() { swingMgr = new SwingUpdateManager(1000, () -> provider.reload());
@Override
public void run() {
provider.reload();
}
});
} }
@@ -98,12 +88,6 @@ public class FunctionWindowPlugin extends ProgramPlugin
super.dispose(); super.dispose();
} }
////////////////////////////////////////////////////////////////////////////
//
// Implementation of DomainObjectListener
//
////////////////////////////////////////////////////////////////////////////
@Override @Override
public void domainObjectChanged(DomainObjectChangedEvent ev) { public void domainObjectChanged(DomainObjectChangedEvent ev) {
if (ev.containsEvent(DomainObject.DO_OBJECT_RESTORED)) { if (ev.containsEvent(DomainObject.DO_OBJECT_RESTORED)) {
@@ -168,20 +152,18 @@ public class FunctionWindowPlugin extends ProgramPlugin
provider.update(function); provider.update(function);
} }
break; break;
/*case ChangeManager.DOCR_SYMBOL_REMOVED: /*case ChangeManager.DOCR_SYMBOL_REMOVED:
rec = (ProgramChangeRecord)ev.getChangeRecord(i); rec = (ProgramChangeRecord)ev.getChangeRecord(i);
addr = (Address)rec.getObject(); addr = (Address)rec.getObject();
function = currentProgram.getListing().getFunctionAt(addr); function = currentProgram.getListing().getFunctionAt(addr);
if (function != null) { if (function != null) {
provider.functionChanged(function); provider.functionChanged(function);
} }
break;*/ break;*/
} }
} }
} }
////////////////////////////////////////////////////////////////////////////
@Override @Override
protected void programActivated(Program program) { protected void programActivated(Program program) {
program.addListener(this); program.addListener(this);
@@ -194,17 +176,10 @@ public class FunctionWindowPlugin extends ProgramPlugin
provider.programClosed(); provider.programClosed();
} }
////////////////////////////////////////////////////////////////////////////
Program getProgram() { Program getProgram() {
return currentProgram; return currentProgram;
} }
////////////////////////////////////////////////////////////////////////////
/**
* Create the action objects for this plugin.
*/
private void createActions() { private void createActions() {
addSelectAction(); addSelectAction();
addCompareAction(); addCompareAction();
@@ -214,19 +189,13 @@ public class FunctionWindowPlugin extends ProgramPlugin
} }
private void addSelectAction() { private void addSelectAction() {
selectAction = new DockingAction("Make Selection", getName(), false) {
selectAction = new MakeProgramSelectionAction(getName(), provider.getTable()) {
@Override @Override
public void actionPerformed(ActionContext context) { protected void makeSelection(ActionContext context) {
selectFunctions(provider.selectFunctions()); selectFunctions(provider.selectFunctions());
} }
}; };
selectAction.setEnabled(false);
ImageIcon icon = ResourceManager.loadImage("images/text_align_justify.png");
selectAction.setPopupMenuData(new MenuData(new String[] { "Make Selection" }, icon));
selectAction.setDescription("Selects currently selected function(s) in table");
selectAction.setToolBarData(new ToolBarData(icon));
installDummyAction(selectAction);
tool.addLocalAction(provider, selectAction); tool.addLocalAction(provider, selectAction);
} }
@@ -238,43 +207,15 @@ public class FunctionWindowPlugin extends ProgramPlugin
compareSelectedFunctions(); compareSelectedFunctions();
} }
}; };
compareAction.setEnabled(false);
ImageIcon icon = ResourceManager.loadImage("images/page_white_c.png"); ImageIcon icon = ResourceManager.loadImage("images/page_white_c.png");
compareAction.setPopupMenuData(new MenuData(new String[] { "Compare Functions" }, icon)); compareAction.setPopupMenuData(new MenuData(new String[] { "Compare Functions" }, icon));
compareAction.setDescription("Compares the currently selected function(s) in the table."); compareAction.setDescription("Compares the currently selected function(s) in the table.");
compareAction.setToolBarData(new ToolBarData(icon)); compareAction.setToolBarData(new ToolBarData(icon));
installDummyAction(compareAction);
tool.addLocalAction(provider, compareAction); tool.addLocalAction(provider, compareAction);
} }
private void installDummyAction(DockingAction action) {
DummyKeyBindingsOptionsAction dummyAction =
new DummyKeyBindingsOptionsAction(action.getName(), null);
tool.addAction(dummyAction);
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS);
options.addOptionsChangeListener(this);
KeyStroke keyStroke = options.getKeyStroke(dummyAction.getFullName(), null);
if (keyStroke != null) {
action.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue, Object newValue) {
if (optionName.startsWith(selectAction.getName())) {
KeyStroke keyStroke = (KeyStroke) newValue;
selectAction.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
if (optionName.startsWith(compareAction.getName())) {
KeyStroke keyStroke = (KeyStroke) newValue;
compareAction.setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
}
void setActionsEnabled(boolean enabled) { void setActionsEnabled(boolean enabled) {
selectAction.setEnabled(enabled); selectAction.setEnabled(enabled);
compareAction.setEnabled(enabled); compareAction.setEnabled(enabled);
@@ -17,20 +17,18 @@ package ghidra.app.plugin.core.navigation.locationreferences;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import docking.action.*; import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.actions.AbstractFindReferencesDataTypeAction; import ghidra.app.actions.AbstractFindReferencesDataTypeAction;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction; import ghidra.app.context.ListingContextAction;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.ToolConstants;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
/** /**
* {@link LocationReferencesPlugin}'s action for finding references to a thing. * {@link LocationReferencesPlugin}'s action for finding references to a thing.
*/ */
public class FindReferencesToAction extends ListingContextAction implements OptionsChangeListener { public class FindReferencesToAction extends ListingContextAction {
private LocationReferencesPlugin plugin; private LocationReferencesPlugin plugin;
private int subGroupPosition; private int subGroupPosition;
@@ -44,37 +42,21 @@ public class FindReferencesToAction extends ListingContextAction implements Opti
setDescription("Shows references to the item under the cursor"); setDescription("Shows references to the item under the cursor");
//
// Shared keybinding setup
//
KeyStroke defaultkeyStroke = AbstractFindReferencesDataTypeAction.DEFAULT_KEY_STROKE; KeyStroke defaultkeyStroke = AbstractFindReferencesDataTypeAction.DEFAULT_KEY_STROKE;
PluginTool tool = plugin.getTool(); initKeyStroke(defaultkeyStroke);
DockingAction action = new DummyKeyBindingsOptionsAction( }
AbstractFindReferencesDataTypeAction.NAME, defaultkeyStroke);
tool.addAction(action);
// setup options to know when the dummy key binding is changed private void initKeyStroke(KeyStroke keyStroke) {
ToolOptions options = tool.getOptions(ToolConstants.KEY_BINDINGS); if (keyStroke == null) {
KeyStroke optionsKeyStroke = options.getKeyStroke(action.getFullName(), defaultkeyStroke); return;
if (!defaultkeyStroke.equals(optionsKeyStroke)) {
// user-defined keystroke
setUnvalidatedKeyBindingData(new KeyBindingData(optionsKeyStroke));
}
else {
setKeyBindingData(new KeyBindingData(optionsKeyStroke));
} }
options.addOptionsChangeListener(this); setKeyBindingData(new KeyBindingData(keyStroke));
} }
@Override @Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) { public boolean usesSharedKeyBinding() {
KeyStroke keyStroke = (KeyStroke) newValue; return true;
String actionName = getName();
if (name.startsWith(actionName)) {
setUnvalidatedKeyBindingData(new KeyBindingData(keyStroke));
}
} }
@Override @Override
@@ -35,7 +35,7 @@ import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.table.DeleteTableRowAction; import ghidra.util.table.actions.DeleteTableRowAction;
/** /**
* Plugin to show a list of references to the item represented by the location of the cursor. * Plugin to show a list of references to the item represented by the location of the cursor.
@@ -38,7 +38,9 @@ import ghidra.program.model.address.AddressSet;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import ghidra.util.table.*; import ghidra.util.table.GhidraTable;
import ghidra.util.table.SelectionNavigationAction;
import ghidra.util.table.actions.DeleteTableRowAction;
import ghidra.util.task.SwingUpdateManager; import ghidra.util.task.SwingUpdateManager;
import resources.Icons; import resources.Icons;
import resources.ResourceManager; import resources.ResourceManager;
@@ -207,11 +209,6 @@ public class LocationReferencesProvider extends ComponentProviderAdapter
tool.removeComponentProvider(this); tool.removeComponentProvider(this);
tool.removeLocalAction(this, homeAction);
tool.removeLocalAction(this, refreshAction);
tool.removeLocalAction(this, selectionAction);
tool.removeLocalAction(this, highlightAction);
homeAction.dispose(); homeAction.dispose();
refreshAction.dispose(); refreshAction.dispose();
highlightAction.dispose(); highlightAction.dispose();
@@ -441,7 +438,7 @@ public class LocationReferencesProvider extends ComponentProviderAdapter
private class DeleteAction extends DeleteTableRowAction { private class DeleteAction extends DeleteTableRowAction {
DeleteAction(PluginTool tool, GTable table) { DeleteAction(PluginTool tool, GTable table) {
super(tool, table, locationReferencesPlugin.getName()); super(table, locationReferencesPlugin.getName());
} }
@Override @Override
@@ -24,7 +24,7 @@ import java.util.Map.Entry;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import docking.util.KeyBindingUtils; import docking.actions.KeyBindingUtils;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
import docking.widgets.label.GIconLabel; import docking.widgets.label.GIconLabel;
import generic.util.WindowUtilities; import generic.util.WindowUtilities;

Some files were not shown because too many files have changed in this diff Show More