Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2887 - Updated the Equates Table to allow multiple selection; Updated the default style sheet to define a class for images

dragonmacher3bb026acc24d
diff --git a/Ghidra/Features/Base/data/base.theme.properties b/Ghidra/Features/Base/data/base.theme.properties
index 4e2fcbd03f..74c9b0b196 100644
--- a/Ghidra/Features/Base/data/base.theme.properties
+++ b/Ghidra/Features/Base/data/base.theme.properties
@@ -81,7 +81,7 @@ color.bg.plugin.editors.compositeeditor.bit.active = green
color.bg.plugin.editors.compositeeditor.bit.conflict = yellow
color.bg.plugin.editors.compositeeditor.non.bit = #A0A0FF
-color.fg.plugin.equate.enum = lightskyblue
+color.fg.plugin.equate.enum = royalblue
color.fg.plugin.function.editor.dialog.textfield.default = color.fg
color.fg.plugin.function.editor.dialog.textfield.error = color.fg.error
@@ -204,4 +204,6 @@ color.bg.plugin.datamgr.edge.default = deepskyblue
color.bg.plugin.datamgr.edge.composite = plum
color.bg.plugin.datamgr.edge.reference = deepskyblue
+color.fg.plugin.equate.enum = deepskyblue
+
color.bg.plugin.programdiff.highlight = darkRed
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm b/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm
index 06663f5430..336a2674f3 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm
@@ -2,67 +2,58 @@
<HTML>
<HEAD>
- <META name="generator" content=
- "HTML Tidy for Java (vers. 2009-12-01), see jtidy.sourceforge.net">
-
<TITLE>Equates</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<LINK rel="stylesheet" type="text/css" href="help/shared/DefaultStyle.css">
- <META name="generator" content="Microsoft FrontPage 4.0">
</HEAD>
- <BODY lang="EN-US">
+ <BODY>
<H1>Equates</H1>
- <P>
- An Equate is a string substitution for <A href=
- "help/topics/Glossary/glossary.htm#Scalar">scalar</A> (a numeric value) in any code unit (instruction
- operand or data). For example, consider the instruction below:</P>
+ <P>An Equate is a string substitution for <A href=
+ "help/topics/Glossary/glossary.htm#Scalar">scalar</A> (a numeric value) in any code unit
+ (instruction operand or data). For example, consider the instruction below:</P>
- <P style="margin-left:100px">
- <TT>MOV R2, $0xb</TT>
- </P>
+ <P style="margin-left:100px"><TT>MOV R2, $0xb</TT></P>
- <P>The scalar <I>$0xb</I> can be replaced with the string <I>BATTERY_FLAG_CRITICAL</I>.
- This will yield the following:</P>
+ <P>The scalar <I>$0xb</I> can be replaced with the string <I>BATTERY_FLAG_CRITICAL</I>. This
+ will yield the following:</P>
- <P style="margin-left:100px">
- <TT>MOV R2, BATTERY_FLAG_CRITICAL</TT>
- </P>
+ <P style="margin-left:100px"><TT>MOV R2, BATTERY_FLAG_CRITICAL</TT></P>
<P>The substitution of "BATTERY_FLAG_CRITICAL" for <I>$0xb</I> is called an equate. That is,
- <I>$0xb</I> is equated to "BATTERY_FLAG_CRITICAL". Note that the default choice for the new
- equate application is your current location. "BATTERY_FLAG_CRITICAL" will
- replace the scalar value <I>$0xb</I> only at the current cursor location unless you choose a
- different option. However, when replacing another scalar of the same value,
- a list of previously declared Equates for that
- scalar value is presented.</P>
-
- <P>Scalars can only be equated to strings. The string can be of any length and may
- contain spaces and special characters. Duplicate equate names are not allowed.</P>
-
+ <I>$0xb</I> is equated to "BATTERY_FLAG_CRITICAL". Note that the default choice for the new
+ equate application is your current location. "BATTERY_FLAG_CRITICAL" will replace the scalar
+ value <I>$0xb</I> only at the current cursor location unless you choose a different option.
+ However, when replacing another scalar of the same value, a list of previously declared Equates
+ for that scalar value is presented.</P>
+
+ <P>Scalars can only be equated to strings. The string can be of any length and may contain
+ spaces and special characters. Duplicate equate names are not allowed.</P>
+
<BLOCKQUOTE>
- <P><IMG alt="Note" src="help/shared/note.png">It should be noted that for the purposes of this document, "scalars" refers to scalar values
- contained in <i>code units</i>. A code unit is an instruction operand or other data element.</P>
+ <P><IMG alt="Note" src="help/shared/note.png">It should be noted that for the purposes of
+ this document, "scalars" refers to scalar values contained in <I>code units</I>. A code unit
+ is an instruction operand or other data element.</P>
</BLOCKQUOTE>
<P>There are several operations that are associated with Equates. They are:</P>
- <DIV style="margin-left: 2em" type="disc">
- <UL type="disc">
+ <BLOCKQUOTE>
+ <UL>
<LI><A href="#Set_Equate">Set Equate</A></LI>
-
+
<LI><A href="#Rename_Equate">Rename Equate</A></LI>
- <LI><A href="#CBAnnotationEquateRemoveEquate">Remove Equate</A></LI>
-
+ <LI><A href="#Remove_Equate">Remove Equate</A></LI>
+
<LI><A href="#Apply_Enum">Apply Enum</A></LI>
<LI><A href="#Equate_Table">View Equates</A></LI>
- <LI><A href="#CBAnnotationEquateConvertSignedDecimal">Convert</A></LI>
+ <LI><A href="#Convert">Convert</A></LI>
</UL>
- </DIV>
+ </BLOCKQUOTE>
<H2><A name="Set_Equate"></A>Set Equate</H2>
@@ -70,291 +61,263 @@
<P>The <I>Set Equate</I> action will create one or more Equates in the Listing.</P>
<P>To set an Equate:</P>
- </BLOCKQUOTE>
- <DIV style="margin-left: 2em" type="">
- <OL type="1">
+ <OL>
<LI>
- Right-mouse-click on the target scalar value<B>,</B> and select <B>Set Equate</B> or press
- <B>&lt;E&gt;</B>.<BR>
-
-
- <BR><BR>
- <P align="center"><IMG src="images/SetEquate.png" alt="Set Equate Dialog"><BR>
- </P>
- <BR><BR>
+ Right-mouse-click on the target scalar value<B>,</B> and select <B>Set Equate</B> or
+ press <B>&lt;E&gt;</B>.
+
+
+ <DIV class="image"><IMG src="images/SetEquate.png" alt="Set Equate Dialog" /></DIV>
+
</LI>
<LI>When the dialog appears, either type in an equate string or choose one from the list of
- strings that are known to be associated with the given value. As you type in the
- "Equate String" field, the list will be narrowed down to show only the strings that contain
- the text that has been typed.<BR>
+ strings that are known to be associated with the given value. As you type in the "Equate
+ String" fi1eld, the list will be narrowed down to show only the strings that contain the
+ text that has been typed.
</LI>
- <LI>
- Select one of the choices from the "Apply To" list. <B>Current Location</B> is
- the default choice unless a selection is made, in which case the <B>Current Selection</B> option
- will be set. The other option is <B>Entire Program.</B>
-
- <OL type="a">
- <LI>
- <B>Current Location</B>: When selected the equate will be applied to the scalar
- value at the current location of your cursor only.
- </LI>
- <LI>
- <B>Current Selection</B>: When selected the equate will be applied to all of
- the scalar values in your current selection that match the value
- of the scalar that you originally clicked. When you make a
- selection in your program this button will become enabled. If you do not make a
- selection then it will not be enabled and the option will be grayed out. Note that
- scalars in your selection that already have an equate set will not be affected
- by this unless you also select the overwrite option.
- </LI>
- <LI>
- <B>Entire Program</B>: When selected the equate will be applied to all of the
- scalar values in the entire program that also match the value of the scalar that
- you originally right-mouse-clicked on.
- </LI>
- <LI>
- <B>Overwrite existing equates</B>: This option is only enabled when setting equates in a selection or the whole program. If this
- option is selected, all scalars and all named equates in the selection or entire program, depending on which option is selected, will be
- set with the user-given equate name. If the overwrite option is not selected, only scalars not already with equates set will be assigned the user-given equate name.
- </LI>
- </OL>
- </LI>
-
- <LI>Double-click on an entry in the list, or select an entry in the list and press <SPAN
- style="font-weight: bold;">OK,</SPAN> or type in the string and press OK. If any item
- in the list is selected it will be used, otherwise the text in the "Equate String" field
- will be used.</LI>
-
-
-
- </OL><SPAN style="font-family: times new roman;"><BR>
- </SPAN>
- </DIV>
+ <LI>
+ Select one of the choices from the "Apply To" list. <B>Current Location</B> is the
+ default choice unless a selection is made, in which case the <B>Current Selection</B>
+ option will be set. The other option is <B>Entire Program.</B>
+
+ <OL type="a">
+ <LI><B>Current Location</B>: When selected the equate will be applied to the scalar
+ value at the current location of your cursor only.</LI>
+
+ <LI><B>Current Selection</B>: When selected the equate will be applied to all of the
+ scalar values in your current selection that match the value of the scalar that you
+ originally clicked. When you make a selection in your program this button will become
+ enabled. If you do not make a selection then it will not be enabled and the option will
+ be grayed out. Note that scalars in your selection that already have an equate set will
+ not be affected by this unless you also select the overwrite option.</LI>
+
+ <LI><B>Entire Program</B>: When selected the equate will be applied to all of the
+ scalar values in the entire program that also match the value of the scalar that you
+ originally right-mouse-clicked on.</LI>
+
+ <LI><B>Overwrite existing equates</B>: This option is only enabled when setting equates
+ in a selection or the whole program. If this option is selected, all scalars and all
+ named equates in the selection or entire program, depending on which option is
+ selected, will be set with the user-given equate name. If the overwrite option is not
+ selected, only scalars not already with equates set will be assigned the user-given
+ equate name.</LI>
+ </OL>
+ </LI>
- <BLOCKQUOTE>
- <P style="margin-left: 40px;"><SPAN style="font-family: times new roman;"><IMG alt="Note" src=
- "help/shared/note.png"> The list of strings shown in the <SPAN style="font-weight: bold;">Set
- Equate</SPAN> dialog are generated from two sources. The first source is all the currently
- assigned equates to the given value. The other source is all the Enum datatypes that
- exist in all the <SPAN style="font-weight: bold;">open</SPAN> datatype archives. If an
- Enum datatype exists that has a member value equal to the given equate value, then that string
- will be included.<BR>
- </SPAN></P>
-
- <P style="margin-left: 40px;"><SPAN style="font-family: times new roman;"><IMG alt="Note" src=
- "help/shared/note.png">The <SPAN style="font-weight: bold;">open</SPAN> data type archives
- contain valid enums and "fake" enums. The fake enums are created from #define values
- (parsed from .h files), specifically so that they will be available in the <SPAN style=
- "font-weight: bold;">Set Equate</SPAN> dialog.</SPAN></P>
-
- <P style="margin-left: 40px;"><SPAN style="font-family: times new roman;"><IMG alt="Note" src=
- "help/shared/note.png"> Each entry in the dialog is color-coded based upon how it is being used
- as an equate.<BR>
-
- <OL type="a" style="margin-left: 80px;">
- <LI>
- <B>Blue</B>: Blue entries are existing user-defined string equates that are being used
- for that scalar.
- </LI>
-
- <LI>
- <B>Black</B>: Black entries are existing enum field equates being used for that scalar.
- </LI>
-
- <LI>
- <B>Gray</B>: Gray entries are suggested enum fields that have the same value as the
- scalar. These entries are only suggestions, and have not yet been made equates.
- </LI>
- </OL>
-
- </SPAN></P>
+ <LI>Double-click on an entry in the list, or select an entry in the list and press
+ <B>OK</B>, or type in the string and press OK. If any item in the list is selected it will
+ be used, otherwise the text in the "Equate String" field will be used.</LI>
+ </OL>
</BLOCKQUOTE>
- <H2><A name="Rename_Equate"></A>Rename Equate</H2>
-
- <BLOCKQUOTE>
- <P>The <I>Rename Equate</I> action will rename one or more instances of a named Equate in the Listing.</P>
+ <BLOCKQUOTE>
+ <P><IMG alt="Note" src="help/shared/note.png"> The list of strings shown in the <B>Set
+ Equate</B> dialog are generated from two sources. The first source is all the currently
+ assigned equates to the given value. The other source is all the Enum datatypes that exist in
+ all the <B>open</B> datatype archives. If an Enum datatype exists that has a member value
+ equal to the given equate value, then that string will be included.</P>
- <P>To rename an Equate:</P>
+ <P><IMG alt="Note" src="help/shared/note.png">The <B>open</B> data type archives contain
+ valid enums and "fake" enums. The fake enums are created from #define values (parsed from .h
+ files), specifically so that they will be available in the <B>Set Equate</B>
+ dialog./P&gt;</P>
+
+ <P><IMG alt="Note" src="help/shared/note.png"> Each entry in the dialog is color-coded based
+ upon how it is being used as an equate.</P>
+
+ <OL type="a">
+ <LI><B>Blue</B>: Blue entries are existing user-defined string equates that are being used
+ for that scalar.</LI>
+
+ <LI><B>Black</B>: Black entries are existing enum field equates being used for that
+ scalar.</LI>
+
+ <LI><B>Gray</B>: Gray entries are suggested enum fields that have the same value as the
+ scalar. These entries are only suggestions, and have not yet been made equates.</LI>
+ </OL>
</BLOCKQUOTE>
- <DIV style="margin-left: 2em" type="">
+ <H2><A name="Rename_Equate"></A>Rename Equate</H2>
+
+ <BLOCKQUOTE>
+ <P>The <I>Rename Equate</I> action will rename one or more instances of a named Equate in the
+ Listing.</P>
+
+ <P>To rename an Equate:</P>
+
<OL type="1">
<LI>
Right-mouse-click on the current Equate<B>,</B> and select <B>Rename Equate</B> or press
<B>&lt;E&gt;</B>.<BR>
-
- <BR><BR>
- <P align="center"><IMG src="images/RenameEquate.png" alt="Rename Equate Dialog"><BR>
- </P>
- <BR><BR>
+ <DIV class="image">
+ <IMG src="images/RenameEquate.png" alt="Rename Equate Dialog">
+ </DIV>
</LI>
- <LI>
- Select one of the choices from the "Apply To" list. <B>Current Location</B> is
- the default choice unless a selection is made, in which case the <B>Current Selection</B> option
- will be set. The other option is <B>Entire Program.</B>
-
- <OL type="a">
- <LI>
- <B>Current Location</B>: When selected the equate will be applied to the scalar
- value at the current location of your cursor only.
- </LI>
- <LI>
- <B>Current Selection</B>: When selected the equate will be applied to all of
- the scalar values in your current selection that match the value
- of the scalar that you originally clicked. When you make a
- selection in your program this button will become enabled. If you do not make a
- selection then it will not be enabled and the option will be grayed out.
- </LI>
- <LI>
- <B>Entire Program</B>: When selected the equate will be applied to all of the
- scalar values in the entire program that match the value of the scalar that you
- originally clicked. Scalars that already have an equate set that
- is different from the one you selected will not be affected.
- </LI>
- </OL>
- </LI>
-
- <LI>Double-click an entry in the list, select an entry in the list and press <SPAN
- style="font-weight: bold;">OK,</SPAN> or type in the string and press <b>OK</b>. If any item
- in the list is selected it will be used, otherwise the text in the "Equate String" field
- will be used.</LI>
- </DIV>
- <H2><A name="CBAnnotationEquateRemoveEquate"></A><A name="Delete_Equate"></A><A name=
- "Remove_Equate"></A>Remove Equate</H2>
-
+ <LI>
+ Select one of the choices from the "Apply To" list. <B>Current Location</B> is the
+ default choice unless a selection is made, in which case the <B>Current Selection</B>
+ option will be set. The other option is <B>Entire Program.</B>
+
+ <OL type="a">
+ <LI><B>Current Location</B>: When selected the equate will be applied to the scalar
+ value at the current location of your cursor only.</LI>
+
+ <LI><B>Current Selection</B>: When selected the equate will be applied to all of the
+ scalar values in your current selection that match the value of the scalar that you
+ originally clicked. When you make a selection in your program this button will become
+ enabled. If you do not make a selection then it will not be enabled and the option will
+ be grayed out.</LI>
+
+ <LI><B>Entire Program</B>: When selected the equate will be applied to all of the
+ scalar values in the entire program that match the value of the scalar that you
+ originally clicked. Scalars that already have an equate set that is different from the
+ one you selected will not be affected.</LI>
+ </OL>
+ </LI>
+
+ <LI>Double-click an entry in the list, select an entry in the list and press <B>OK</B>, or
+ type in the string and press <B>OK</B>. If any item in the list is selected it will be
+ used, otherwise the text in the "Equate String" field will be used.</LI>
+ </OL>
+ </BLOCKQUOTE>
+
+ <H2><A name="Delete_Equate"></A><A name="Remove_Equate"></A>Remove Equate</H2>
+
<BLOCKQUOTE>
- <P>The <I>Remove Equate</I> action will remove an Equate(s) from a listing; effectively returning the operand to its original scalar value.</P>
+ <P>The <I>Remove Equate</I> action will remove an Equate(s) from a listing; effectively
+ returning the operand to its original scalar value.</P>
<P>To remove references to an Equate via the context popup menu:</P>
- </BLOCKQUOTE>
- <DIV style="margin-left: 2em" type="">
<OL>
- <LI>Right-mouse-click on an existing Equate, or select a group of equates and right-click on an equate within that selection, then choose <B>Remove Equate</B> or press
+ <LI>Right-mouse-click on an existing Equate, or select a group of equates and right-click
+ on an equate within that selection, then choose <B>Remove Equate</B> or press
&lt;<B>Delete</B>&gt;.</LI>
-
- <LI>If you made a group selection, a confirmation dialog will appear to ensure you want to remove all equates in the selection; equates within the selection
- matching the one you clicked will be removed.
-
- <P align="center"><BR>
- <IMG src="images/RemoveSelection.png" alt="Confirm Equate Remove Dialog"></P>
-
- <P align="center"></P>
+
+ <LI>
+ If you made a group selection, a confirmation dialog will appear to ensure you want to
+ remove all equates in the selection; equates within the selection matching the one you
+ clicked will be removed.
+
+ <DIV class="image">
+ <IMG src="images/RemoveSelection.png" alt="Confirm Equate Remove Dialog">
+ </DIV>
</LI>
</OL>
- </DIV>
- <BLOCKQUOTE>
<P>To remove all references of an Equate via the <I>Equates Table</I> window:</P>
- </BLOCKQUOTE>
- <DIV style="margin-left: 2em" type="">
<OL>
- <LI>Select the Code Browser menu option <B>Window<IMG src="help/shared/arrow.gif" border=
- "0">Equates Table</B> to bring up the <I>Equates Table</I> window.</LI>
+ <LI>Select the Code Browser menu option <B>Window<IMG alt="" src="help/shared/arrow.gif"
+ border="0">Equates Table</B> to bring up the <I>Equates Table</I> window.</LI>
<LI>Right-mouse-click on the Equate to be deleted and select <B>Delete</B>.</LI>
<LI>
A confirmation dialog will appear.
- <P align="center"><BR>
- <IMG src="images/ConfirmEquateDelete.png" alt="Confirm Equate Delete Dialog"></P>
-
- <P align="center"></P>
+ <DIV class="image">
+ <IMG src="images/ConfirmEquateDelete.png" alt="Confirm Equate Delete Dialog">
+ </DIV>
</LI>
<LI>Select <B>Delete</B> to remove all references to the equate and the Equate's definition
itself.<BR>
</LI>
</OL>
- </DIV>
-
- <H2><A name="Apply_Enum"></A> Apply Enum</H2>
-
+ </BLOCKQUOTE>
+
+
+
+ <H2><A name="Edit_Enum"></A>Edit Enum</H2>
+
+ <BLOCKQUOTE>
+ <P>The <I>Edit Enum</I> action is available from the <I>Equates Table</I> window.
+ Right-mouse-click on an existing Equate in the table. If that equate is part of an enum,
+ then this action will show the enum in an editor window.
+ </P>
+ </BLOCKQUOTE>
+
+
+ <H2><A name="Show_Enum"></A>Show Enum</H2>
+
+ <BLOCKQUOTE>
+ <P>The <I>Show Enum</I> action is available from the <I>Equates Table</I> window.
+ Right-mouse-click on an existing Equate in the table. If that equate is part of an enum,
+ then this action will show that enum in the Data Type Manager window.
+ </P>
+ </BLOCKQUOTE>
+
+
+
+ <H2><A name="Apply_Enum"></A> Apply Enum</H2>
+
<BLOCKQUOTE>
- <P>The <I>Apply Enum</I> action (only available when there is a selection), will apply
- enum member names to scalars in the current selection if any of the enum values match
- those scalars.</P>
+ <P>The <I>Apply Enum</I> action (only available when there is a selection), will apply enum
+ member names to scalars in the current selection if any of the enum values match those
+ scalars.</P>
<P>To apply an enum to the selection:</P>
- </BLOCKQUOTE>
- <DIV style="margin-left: 2em" type="">
<OL>
- <LI> Make a selection and then Right-mouse-click, then choose <B>Apply Enum</B>.
-
- <P align="center"><BR>
- <IMG src="images/BeforeApplyEnum.png" alt="Apply Enum Popup"></P>
+ <LI>
+ Make a selection and then Right-mouse-click, then choose <B>Apply Enum</B>.
- <P align="center"></P>
+ <DIV class="image">
+ <IMG src="images/BeforeApplyEnum.png" alt="Apply Enum Popup">
+ </DIV>
</LI>
-
- <LI>A dialog similar to the one below should appear. Select the enum that
- you want to be applied to the selection. The data type must be an enum for the action
- to work.
-
- <P align="center"><BR>
- <IMG src="images/ApplyEnum.png" alt="Apply Enum Popup"></P>
-
- <P align="center"></P>
-
- <UL>
-
- <LI><I>Apply to sub-operands</I> - Applies the enum to scalars within operands.</LI>
- </UL>
-
- <P>Once the data type is selected, the scalars in the selection will have equates
- applied to them as shown below.</P>
-
- <P align="center"><BR>
- <IMG src="images/AfterApplyEnum.png" alt="Apply Enum Popup"></P>
- <P align="center"></P>
-
+ <LI>
+ A dialog similar to the one below should appear. Select the enum that you want to be
+ applied to the selection. The data type must be an enum for the action to work.
+
+ <DIV class="image">
+ <IMG src="images/ApplyEnum.png" alt="Apply Enum Popup">
+ </DIV>
+
+ <UL>
+ <LI><I>Apply to sub-operands</I> - Applies the enum to scalars within operands.</LI>
+ </UL>
+
+ <P>Once the data type is selected, the scalars in the selection will have equates applied
+ to them as shown below.</P>
+
+ <DIV class="image">
+ <IMG src="images/AfterApplyEnum.png" alt="Apply Enum Popup">
+ </DIV>
</LI>
</OL>
- </DIV>
+ </BLOCKQUOTE>
<H2><A name="Equate_Table"></A> <A name="Display_Equates_Table"></A> View Equates</H2>
<BLOCKQUOTE>
<P>The <I>Display Equates Table</I> action displays a window which lists all of the Equates
and their references in a tabular format.</P>
- </BLOCKQUOTE>
- <DIV align="center">
- <CENTER>
- <TABLE border="0" width="100%">
- <TBODY>
- <TR>
- <TD align="center" width="100%"><IMG src="images/EquatesTable.png" alt=
- "Equates Table" border="0"></TD>
- </TR>
- </TBODY>
- </TABLE>
- </CENTER>
- </DIV>
+ <DIV class="image">
+ <IMG src="images/EquatesTable.png" alt="Equates Table" border="0">
+ </DIV>
+ </BLOCKQUOTE>
<BLOCKQUOTE>
<P>The left panel, <I>Equates,</I> lists name, value, and number of references for all
- Equates. The right panel, <I>References,</I> lists the address and operand index of
- each location that references the Equate selected in the left panel. Selecting an
- address on the <I>References</I> panel will cause the Code Browser to go to that address in
- the listing. The <I>Equates</I> panel and the <I>References</I> panel can each be
- sorted by any column. The ascending and descending indicator displays the sort order of
- the information.</P>
+ Equates. The right panel, <I>References,</I> lists the address and operand index of each
+ location that references the Equate selected in the left panel. Selecting an address on the
+ <I>References</I> panel will cause the Code Browser to go to that address in the listing. The
+ <I>Equates</I> panel and the <I>References</I> panel can each be sorted by any column. The
+ ascending and descending indicator displays the sort order of the information.</P>
</BLOCKQUOTE>
<BLOCKQUOTE>
- <P>To view the <I>Equates Table</I> select the Code Browser menu option <B>Window<IMG src=
- "help/shared/arrow.gif" border="0">Equates Table</B> to bring up the <I>Equates Table</I>
+ <P>To view the <I>Equates Table</I> select the Code Browser menu option <B>Window<IMG alt=""
+ src="help/shared/arrow.gif" border="0">Equates Table</B> to bring up the <I>Equates Table</I>
window.</P>
<P>You can re-order the columns in the Equates table by dragging the header to another
@@ -363,118 +326,114 @@
Op Index. By default, the references are sorted by reference address in ascending order.<BR>
</P>
- <P>You can also rename the equate by double clicking in the name field and entering a
- new name. If the equate is based off of an enum, then an enum editor dialog will appear.
- Changing the matching field name will also change the equate name.<BR>
+ <P>You can rename an equate by double-clicking the name field and entering a new
+ name. If the equate is based off of an enum, then double-clicking will not trigger an edit.
+ Instead, you can right-click and edit the containing enum. In the enum editor, changing
+ the matching field name will also change the equate name.<BR>
</P>
-
- <P style="margin-left: 40px;"><SPAN style="font-family: times new roman;"><IMG alt="Note" src=
- "help/shared/note.png"> Each equate is color-coded based upon how it is being used.<BR>
-
- <OL type="a" style="margin-left: 80px;">
- <LI>
- <B>Blue</B>: Blue equates are existing user-defined string equates that are being used
- for that scalar.
- </LI>
-
- <LI>
- <B>Black</B>: Black equates are existing enum field equates being used for that scalar.
- </LI>
-
- <LI>
- <B>Red</B>: Red entries are bad equates. A bad equate could either mean that the enum
- that this equate is based off of was deleted, the field inside the enum was deleted, or
- the field's value was changed.
- </LI>
- </OL>
-
- </SPAN></P>
+
+ <P><IMG alt="Note" src="help/shared/note.png"> Each equate is color-coded based upon how it
+ is being used.</P>
+
+ <BLOCKQUOTE>
+ <OL type="a">
+ <LI><B>Blue</B>: Blue equates are existing user-defined string equates that are being
+ used for that scalar.</LI>
+
+ <LI><B>Black</B>: Black equates are existing enum field equates being used for that
+ scalar.</LI>
+
+ <LI><B>Red</B>: Red entries are bad equates. A bad equate could either mean that the enum
+ that this equate is based off of was deleted, the field inside the enum was deleted, or
+ the field's value was changed.</LI>
+ </OL>
+ </BLOCKQUOTE>
</BLOCKQUOTE>
- <H2><A name="CBAnnotationEquateConvertSignedDecimal"></A><A name="Convert"></A>Convert</H2>
-
- <DIV style="margin-left: 40px;">
- <P>The various convert actions are used to change the number format display of scalars
- displayed in the code browser. These actions are available whenever the cursor is on a number
- in the operand field, or the value field of a data item (byte, word, dword, qword). Note that
- these actions and equates are not currently supported for composite and array data.
- For instruction operands, the scalar number is converted visually by replacing the number with an
- appropriately named equate. Such a conversion can be cleared by removing the equate
- from the operand. For data value fields, a combination of data format settings and signed/unsigned
- data type alteration is used to reflect a conversion. The available formats are as follows.<BR>
- </P>
- </DIV>
+ <H2><A name="Convert"></A>Convert</H2>
+
+ <P>The various convert actions are used to change the number format display of scalars
+ displayed in the code browser. These actions are available whenever the cursor is on a number
+ in the operand field, or the value field of a data item (byte, word, dword, qword). Note that
+ these actions and equates are not currently supported for composite and array data. For
+ instruction operands, the scalar number is converted visually by replacing the number with an
+ appropriately named equate. Such a conversion can be cleared by removing the equate from the
+ operand. For data value fields, a combination of data format settings and signed/unsigned data
+ type alteration is used to reflect a conversion. The available formats are as follows.</P>
<BLOCKQUOTE>
<H3><A name="Convert_To_Signed_Decimal"></A>Signed Decimal</H3>
- <P>The existing scalar value will be displayed as a signed decimal number. This action
- is only available if the value can be interpreted as a negative value.<BR>
+ <P>The existing scalar value will be displayed as a signed decimal number. This action is
+ only available if the value can be interpreted as a negative value.<BR>
</P>
<H3><A name="Convert_To_Unsigned_Decimal"></A>Unsigned Decimal</H3>
- <P>The existing scalar value will be displayed as an unsigned decimal number. If the
- value would be positive even if the signed decimal format was selected, the action will
- simply be name <SPAN style="font-weight: bold;">Decimal</SPAN> instead of <SPAN style=
- "font-weight: bold;">Unsigned Decimal</SPAN>.</P>
+ <P>The existing scalar value will be displayed as an unsigned decimal number. If the value
+ would be positive even if the signed decimal format was selected, the action will simply be
+ name <B>Decimal</B> instead of <B>Unsigned Decimal</B>.</P>
<H3><A name="Convert_To_Unsigned_Octal"></A>Unsigned Octal</H3>
<P>The existing scalar value will be displayed as an unsigned octal number.</P>
- <H3><A name="Convert_To_Signed_Hex"></A>Signed Hex</H3>
+ <H3><A name="Convert_To_Signed_Hex"></A>Signed Hex</H3>
+
+ <P>The existing scalar value will be displayed as a signed hexadecimal number. This action is
+ only available if the value can be interpreted as a negative value, and is only supported on
+ instruction operands since the data hex format currently supports unsigned rendering
+ only.</P>
- <P>The existing scalar value will be displayed as a signed hexadecimal number. This action
- is only available if the value can be interpreted as a negative value, and
- is only supported on instruction operands since the data hex format
- currently supports unsigned rendering only.</P>
-
<H3><A name="Convert_To_Unsigned_Hex"></A>Unsigned Hex</H3>
<P>The existing scalar value will be displayed as an unsigned hexadecimal number.</P>
-
+
<H3><A name="Convert_To_Char"></A>Char / Char Sequence</H3>
<P>The existing scalar value will be displayed as either a single ASCII character or a
- sequence of ASCII characters, whichever is more appropriate. Invalid and non-printable
- ASCII characters will be rendered in hex (e.g., \x20).<BR>
- </P>
+ sequence of ASCII characters, whichever is more appropriate. Invalid and non-printable ASCII
+ characters will be rendered in hex (e.g., \x20).</P>
<H3><A name="Convert_To_Unsigned_Binary"></A>Unsigned Binary</H3>
- <P>The existing scalar value will be displayed as an unsigned binary number.<BR>
- </P>
-
+ <P>The existing scalar value will be displayed as an unsigned binary number.</P>
+
<H3><A name="Convert_To_Float"></A>Float</H3>
- <P>The existing scalar value will be displayed as a IEEE 754 single
- precision floating point number. The floating point size is processor specific
- and will match the size of the Float data type. This action is only supported on instruction
- operands.<BR>
- </P>
-
+
+ <P>The existing scalar value will be displayed as a IEEE 754 single precision floating point
+ number. The floating point size is processor specific and will match the size of the Float
+ data type. This action is only supported on instruction operands.</P>
+
<H3><A name="Convert_To_Double"></A>Double</H3>
- <P>The existing scalar value will be displayed as a IEEE 754 double
- precision floating point number. The floating point size is processor specific
- and will match the size of the Double data type. This action is only supported on instruction
- operands.<BR>
- </P>
-
- <P><IMG src="help/shared/tip.png" alt="" border="0"> The convert actions also work on an
- instruction selection. Just make a selection then choose an operand scalar value to convert.
- All matching instruction scalar values in the selection will be converted.</P>
-
- <P><IMG src="help/shared/tip.png" alt="" border="0"> Based upon how an instruction
- is implemented by its' associated language module, a hexadecimal operand which appears
- to be negative may in fact be a positive scalar with negative sign '-' character prepended.
- In such cases, the convert action may not produce the expected result.</P>
-
- <P><IMG src="help/shared/tip.png" alt="" border="0"> The presence of a primary reference
- on an operand may prevent rendering of the converted scalar value since reference
- markup takes precedence over equates and data formatting.</P>
- </BLOCKQUOTE>
+
+ <P>The existing scalar value will be displayed as a IEEE 754 double precision floating point
+ number. The floating point size is processor specific and will match the size of the Double
+ data type. This action is only supported on instruction operands.</P>
+
+ <P><IMG src="help/shared/tip.png" alt="" border="0"> The convert actions also work on an
+ instruction selection. Just make a selection then choose an operand scalar value to convert.
+ All matching instruction scalar values in the selection will be converted.</P>
+
+ <P><IMG src="help/shared/tip.png" alt="" border="0"> Based upon how an instruction is
+ implemented by its' associated language module, a hexadecimal operand which appears to be
+ negative may in fact be a positive scalar with negative sign '-' character prepended. In such
+ cases, the convert action may not produce the expected result.</P>
+
+ <P><IMG src="help/shared/tip.png" alt="" border="0"> The presence of a primary reference on
+ an operand may prevent rendering of the converted scalar value since reference markup takes
+ precedence over equates and data formatting.</P>
+ </BLOCKQUOTE>
<P class="providedbyplugin">Provided By: <I>EquatePlugin</I> and <I>EquateTablePlugin</I></P>
- <BR>
+
+ <P class="relatedtopic">Related Topics:</P>
+
+ <UL>
+ <LI><A href="help/topics/CodeBrowserPlugin/CodeBrowser.htm">Code Browser</A></LI>
+
+ <LI><A href="help/topics/DataTypeManagerPlugin/data_type_manager_window.html">Data Type Manager</A></LI>
+ </UL><BR>
+ <BR>
</BODY>
</HTML>
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateReferenceTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateReferenceTableModel.java
index 4d705c4fef..ea93373fa2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateReferenceTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateReferenceTableModel.java
@@ -32,7 +32,6 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
private EquateTablePlugin plugin;
private List<EquateReference> referenceList = new ArrayList<>();
- private Equate currentEquate = null;
EquateReferenceTableModel(EquateTablePlugin plugin) {
super(plugin.getTool());
@@ -70,18 +69,11 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
return null;
}
- Equate getEquate() {
- return currentEquate;
- }
-
void setEquate(Equate equate) {
- this.currentEquate = equate;
-
- populateReferences();
+ populateReferences(equate);
}
-
- private void populateReferences() {
+ private void populateReferences(Equate equate) {
referenceList.clear();
Program program = getProgram();
@@ -90,14 +82,11 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
}
EquateTable equateTable = program.getEquateTable();
- if (equateTable == null || currentEquate == null) {
+ if (equateTable == null || equate == null) {
return;
}
- // @formatter:off
- Arrays.asList(currentEquate.getReferences())
- .forEach(r -> referenceList.add(r));
- // @formatter:on
+ referenceList.addAll(Arrays.asList(equate.getReferences()));
fireTableDataChanged();
}
@@ -131,7 +120,7 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
@Override
public Address getValue(EquateReference rowObject, Settings settings, Object data,
- ServiceProvider serviceProvider) throws IllegalArgumentException {
+ ServiceProvider sp) throws IllegalArgumentException {
return rowObject.getAddress();
}
@@ -147,7 +136,7 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
@Override
public Short getValue(EquateReference rowObject, Settings settings, Object data,
- ServiceProvider serviceProvider) throws IllegalArgumentException {
+ ServiceProvider sp) throws IllegalArgumentException {
return rowObject.getOpIndex();
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableModel.java
index 95fc54972a..1c83de28e2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableModel.java
@@ -200,8 +200,8 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
}
@Override
- public String getValue(Equate rowObject, Settings settings, Object data,
- ServiceProvider sp) throws IllegalArgumentException {
+ public String getValue(Equate rowObject, Settings settings, Object data, ServiceProvider sp)
+ throws IllegalArgumentException {
return rowObject.getDisplayName();
}
@@ -251,8 +251,8 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
}
@Override
- public Long getValue(Equate rowObject, Settings settings, Object data,
- ServiceProvider sp) throws IllegalArgumentException {
+ public Long getValue(Equate rowObject, Settings settings, Object data, ServiceProvider sp)
+ throws IllegalArgumentException {
FormatSettingsDefinition formatDef = FormatSettingsDefinition.DEF;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableProvider.java
index 56f30a71fe..2d51af030d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquateTableProvider.java
@@ -26,7 +26,7 @@ import javax.swing.table.TableCellEditor;
import docking.ActionContext;
import docking.action.*;
-import docking.widgets.OptionDialog;
+import docking.action.builder.ActionBuilder;
import docking.widgets.label.GLabel;
import ghidra.app.context.ProgramActionContext;
import ghidra.app.services.DataTypeManagerService;
@@ -61,7 +61,7 @@ public class EquateTableProvider extends ComponentProviderAdapter {
this.plugin = plugin;
mainPanel = createWorkPanel();
addToTool();
- createAction();
+ createActions();
}
@Override
@@ -107,18 +107,12 @@ public class EquateTableProvider extends ComponentProviderAdapter {
void updateEquates() {
// restore selection after update
- int row = equatesTable.getSelectedRow();
+ List<Equate> selectedItems = equatesFilterPanel.getSelectedItems();
equatesModel.update();
- int rows = equatesTable.getRowCount();
- if (row < 0 || row >= rows) {
- row = 0;
- }
+ equatesFilterPanel.setSelectedItems(selectedItems);
- if (rows > 0) {
- equatesTable.setRowSelectionInterval(row, row);
- }
handleEquateTableSelection();
}
@@ -165,43 +159,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
}
});
- // Allows for the user to double click on an equate to rename it from a data type editor
- // dialog if the equate is based off of an enum data type.
- equatesTable.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent evt) {
- if (evt.getClickCount() == 2) {
- DataTypeManager dtm = plugin.getProgram().getDataTypeManager();
- Object obj = evt.getSource();
- if (obj instanceof GhidraTable) {
- GhidraTable table = (GhidraTable) obj;
- int row = table.rowAtPoint(evt.getPoint());
- int column = table.columnAtPoint(evt.getPoint());
-
- if (!table.isCellEditable(row, column)) {
- return;
- }
-
- DataTypeManagerService dtms = tool.getService(DataTypeManagerService.class);
- if (dtms == null) {
- return;
- }
- Equate equate = (Equate) table.getValueAt(row, column);
-
- UniversalID id =
- new UniversalID(Long.parseLong(equate.getName().split(":")[1]));
- Enum enoom = (Enum) dtm.findDataTypeForID(id);
- if (enoom != null) {
- dtms.edit(enoom);
- }
- else {
- showDeleteEquateOptionDialog();
- }
- }
- }
- }
- });
-
equatesTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting()) {
return;
@@ -212,7 +169,7 @@ public class EquateTableProvider extends ComponentProviderAdapter {
equatesTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
equatesTable.setPreferredScrollableViewportSize(new Dimension(350, 150));
equatesTable.setRowSelectionAllowed(true);
- equatesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ equatesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
equatesFilterPanel = new GhidraTableFilterPanel<>(equatesTable, equatesModel);
@@ -223,8 +180,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
equatesPanel.add(equatesTablePane, BorderLayout.CENTER);
equatesPanel.add(equatesFilterPanel, BorderLayout.SOUTH);
- //////////////////////////////////////////////////////////////
-
referencesModel = new EquateReferenceTableModel(plugin);
referencesTable = new GhidraTable(referencesModel);
@@ -248,8 +203,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
referencesPanel.add(new GLabel("References", SwingConstants.CENTER), "North");
referencesPanel.add(referencesTablePane, "Center");
- //////////////////////////////////////////////////////////////
-
JPanel workPanel = new JPanel(new BorderLayout());
JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, equatesPanel, referencesPanel);
@@ -260,12 +213,47 @@ public class EquateTableProvider extends ComponentProviderAdapter {
}
private void handleEquateTableSelection() {
+
+ int[] rows = equatesTable.getSelectedRows();
+ if (rows.length > 1) {
+ referencesTable.clearSelection();
+ referencesModel.setEquate(null);
+ return;
+ }
+
Equate equate = equatesFilterPanel.getSelectedItem();
referencesTable.clearSelection();
referencesModel.setEquate(equate);
}
- private void createAction() {
+ private void createActions() {
+
+ //@formatter:off
+ String group = "Popup Group";
+ new ActionBuilder("Show Enum", plugin.getName())
+ .popupMenuGroup(group)
+ .popupMenuPath("Show Enum")
+ .popupWhen(c -> true)
+ .enabledWhen(c -> getEnum(getSelectedEquate()) != null)
+ .onAction(c -> {
+ DataTypeManagerService dtms = tool.getService(DataTypeManagerService.class);
+ if (dtms != null) {
+ dtms.setDataTypeSelected(getEnum(getSelectedEquate()));
+ }
+ })
+ .helpLocation(new HelpLocation("EquatePlugin", "Show_Enum"))
+ .buildAndInstallLocal(this);
+
+ new ActionBuilder("Edit Enum", plugin.getName())
+ .popupMenuGroup(group)
+ .popupMenuPath("Edit Enum")
+ .popupWhen(c -> true)
+ .enabledWhen(c -> getEnum(getSelectedEquate()) != null)
+ .onAction(c -> edit(getEnum(getSelectedEquate())))
+ .helpLocation(new HelpLocation("EquatePlugin", "Edit_Enum"))
+ .buildAndInstallLocal(this);
+
+ //@formatter:on
Icon deleteImage = Icons.DELETE_ICON;
deleteAction = new DockingAction("Delete Equate", plugin.getName()) {
@@ -290,22 +278,56 @@ public class EquateTableProvider extends ComponentProviderAdapter {
SelectionNavigationAction selectionNavigationAction =
new SelectionNavigationAction(plugin, referencesTable);
- selectionNavigationAction.setHelpLocation(
- new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation"));
+ selectionNavigationAction
+ .setHelpLocation(new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation"));
tool.addLocalAction(this, deleteAction);
tool.addLocalAction(this, selectionNavigationAction);
}
- private void delete() {
+ private Equate getSelectedEquate() {
+ if (equatesTable.getSelectedRowCount() != 1) {
+ return null;
+ }
- List<Equate> equates = equatesFilterPanel.getSelectedItems();
+ return equatesFilterPanel.getSelectedItem();
+ }
+
+ private Enum getEnum(Equate equate) {
+ if (equate == null) {
+ return null;
+ }
+
+ if (!equate.isEnumBased()) {
+ return null;
+ }
+
+ DataTypeManagerService dtms = tool.getService(DataTypeManagerService.class);
+ if (dtms == null) {
+ return null;
+ }
+
+ DataTypeManager dtm = plugin.getProgram().getDataTypeManager();
+ UniversalID id = equate.getEnumUUID();
+ Enum enoom = (Enum) dtm.findDataTypeForID(id);
+ return enoom;
+ }
+
+ private void edit(Enum enoom) {
+ DataTypeManagerService dtms = tool.getService(DataTypeManagerService.class);
+ if (dtms != null) {
+ dtms.edit(enoom);
+ }
+ }
+
+ private void delete() {
TableCellEditor cellEditor = equatesTable.getCellEditor();
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
+ List<Equate> equates = equatesFilterPanel.getSelectedItems();
plugin.deleteEquates(equates);
}
@@ -318,15 +340,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
}
}
- private void showDeleteEquateOptionDialog() {
- String message = "Data type not found. Would you like to delete this equate?";
- int choice = OptionDialog.showOptionDialogWithCancelAsDefaultButton(equatesFilterPanel,
- "Delete Equate", message, "Delete Equate", OptionDialog.ERROR_MESSAGE);
- if (choice == OptionDialog.OPTION_ONE) {
- delete();
- }
- }
-
EquateTableModel getEquatesModel() {
return equatesModel;
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin1Test.java
index aab736caa9..537921988e 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin1Test.java
@@ -646,7 +646,7 @@ public class EquatePlugin1Test extends AbstractGhidraHeadedIntegrationTest {
/*
* Tests that the user is prompted before attempting to remove an equate within
* a selection.
- *
+ *
* @throws Exception
*/
@Test
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquateTablePluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquateTablePluginTest.java
index 5cc1426c7f..b627b3cf15 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquateTablePluginTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquateTablePluginTest.java
@@ -17,9 +17,6 @@ package ghidra.app.plugin.core.equate;
import static org.junit.Assert.*;
-import java.awt.Rectangle;
-import java.util.*;
-
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
@@ -40,7 +37,6 @@ import ghidra.program.util.OperandFieldLocation;
import ghidra.program.util.ProgramLocation;
import ghidra.test.*;
import ghidra.util.table.GhidraTable;
-import util.CollectionUtils;
/**
* Tests for the equate table plugin.
@@ -114,16 +110,6 @@ public class EquateTablePluginTest extends AbstractGhidraHeadedIntegrationTest {
env.dispose();
}
- @Test
- public void testEquateTableView() throws Exception {
- // verify that the equate table shows the equates and the references
- assertNotNull(refsTable);
- assertNotNull(refsModel);
- assertEquals(1, refsModel.getRowCount());
-
- checkTableValues();
- }
-
@Test
public void testShowReferences() {
setRowSelection(equatesTable, 1, 1);// this triggers the refs table to update
@@ -370,37 +356,6 @@ public class EquateTablePluginTest extends AbstractGhidraHeadedIntegrationTest {
waitForProgram(program);
}
- private void checkTableValues() throws Exception {
- Iterator<Equate> iter = et.getEquates();
- List<Equate> list = CollectionUtils.asList(iter);
-
- Collections.sort(list, (e1, e2) -> e1.getName().compareTo(e2.getName()));
- assertEquals(list.size(), equatesModel.getRowCount());
-
- TableCellRenderer nameRenderer = getRenderer(EquateTableModel.NAME_COL);
- TableCellRenderer valueRenderer = getRenderer(EquateTableModel.VALUE_COL);
- TableCellRenderer refCountRenderer = getRenderer(EquateTableModel.REFS_COL);
-
- for (int i = 0; i < list.size(); i++) {
-
- Equate eq = list.get(i);
- Rectangle rect = equatesTable.getCellRect(i, EquateTableModel.NAME_COL, true);
- runSwing(() -> equatesTable.scrollRectToVisible(rect));
-
- String value = getRenderedValue(nameRenderer, i, EquateTableModel.NAME_COL);
- assertEquals("Name not equal at index: " + i, eq.getName(), value);
-
- // The value column is default-rendered as hex
- value = getRenderedValue(valueRenderer, i, EquateTableModel.VALUE_COL);
- assertEquals("Value not equal at index: " + i, Long.toHexString(eq.getValue()) + "h",
- value);
-
- value = getRenderedValue(refCountRenderer, i, EquateTableModel.REFS_COL);
- assertEquals("Reference count not equal at index: " + i,
- Integer.toString(eq.getReferenceCount()), value);
- }
- }
-
private String getRenderedValue(TableCellRenderer renderer, int row, int column) {
return runSwing(() -> {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java
index a230b8f752..fdc644ee66 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java
@@ -26,6 +26,7 @@ import javax.swing.event.*;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
+import org.apache.commons.collections4.CollectionUtils;
import org.jdom.Element;
import docking.DockingWindowManager;
@@ -67,7 +68,7 @@ import utility.function.Callback;
* <p>
*
* <u>Filtering</u><br>
- * The filtering behavior is controlled by the filter button displayed to the right of this
+ * The filtering behavior is controlled by the filter button displayed to the right of this
* panel's text field.
* <p>
*
@@ -104,7 +105,7 @@ import utility.function.Callback;
* To get a row count that is always all of the model's data, call
* {@link #getUnfilteredRowCount()}.
* </ul>
- *
+ *
* @param <ROW_OBJECT> the row object type for this given table and model
*/
public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
@@ -690,11 +691,16 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
/**
* Select the given row object. No selection will be made if the object is filtered out of
- * view.
+ * view. Passing {@code null} will clear the selection.
*
* @param t the row object to select
*/
public void setSelectedItem(ROW_OBJECT t) {
+ if (t == null) {
+ table.clearSelection();
+ return;
+ }
+
int viewRow = textFilterModel.getViewIndex(t);
if (viewRow >= 0) {
table.setRowSelectionInterval(viewRow, viewRow);
@@ -702,6 +708,52 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
}
}
+ /**
+ * Select the given row objects. No selection will be made if the objects are filtered out of
+ * view. Passing a {@code null} list or an empty list will clear the selection.
+ *
+ * @param items the row objects to select
+ */
+ public void setSelectedItems(List<ROW_OBJECT> items) {
+
+ if (CollectionUtils.isEmpty(items)) {
+ table.clearSelection();
+ return;
+ }
+
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ int mode = selectionModel.getSelectionMode();
+ if (mode == ListSelectionModel.SINGLE_SELECTION) {
+ // take the last item to mimic what the selection model does internally
+ ROW_OBJECT item = items.get(items.size() - 1);
+ int viewRow = textFilterModel.getViewIndex(item);
+ table.setRowSelectionInterval(viewRow, viewRow);
+ return;
+ }
+
+ //
+ // For ListSelectionModel SINGLE_INTERVAL_SELECTION and MULTIPLE_INTERVAL_SELECTION, the
+ // model will update any selection given to it to match the current mode.
+ //
+ List<Integer> rows = new ArrayList<>();
+ for (ROW_OBJECT item : items) {
+ int viewRow = textFilterModel.getViewIndex(item);
+ if (viewRow >= 0) {
+ rows.add(viewRow);
+ }
+ }
+ if (rows.isEmpty()) {
+ return; // items may be filtered out of view
+ }
+
+ selectionModel.setValueIsAdjusting(true);
+ selectionModel.clearSelection();
+ for (int row : rows) {
+ selectionModel.addSelectionInterval(row, row);
+ }
+ selectionModel.setValueIsAdjusting(false);
+ }
+
/**
* Scrolls the view to the currently selected item.
*/
@@ -915,7 +967,7 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
* a filter panel, then each provider will share the same filter settings when that provider
* is created. If this is not what you want, then you need to override this method to
* generate a unique key for each provider.
- *
+ *
* @param jTable the table
* @return a key used to store user filter configuration state.
*/
@@ -992,7 +1044,7 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
//==================================================================================================
// Inner Classes
-//==================================================================================================
+//==================================================================================================
private abstract class ColumnFilterActionState
extends ActionState<ColumnBasedTableFilter<ROW_OBJECT>> {
diff --git a/Ghidra/Framework/Help/src/main/resources/help/shared/DefaultStyle.css b/Ghidra/Framework/Help/src/main/resources/help/shared/DefaultStyle.css
index 557c37ca39..b45630ae27 100644
--- a/Ghidra/Framework/Help/src/main/resources/help/shared/DefaultStyle.css
+++ b/Ghidra/Framework/Help/src/main/resources/help/shared/DefaultStyle.css
@@ -15,22 +15,49 @@
*/
/*
WARNING!
- This file is copied to all help directories. If you change this file, you must copy it
- to each src/main/help/help/shared directory.
-
-
Java Help Note: JavaHelp does not accept sizes (like in 'margin-top') in anything but
px (pixel) or with no type marking.
+ The blockquote tag is used heavily to control indentation throughout the help docs. Place the
+ blockquote tag around other elements to create a standard indentation. The default values of
+ blockquote are:
+
+ blockquote {
+ display: block;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ margin-left: 40px;
+ margin-right: 40px;
+ }
+
*/
body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 10px; } /* some padding to improve readability */
-li { font-family:times new roman; font-size:14pt; }
+
+/*
+ Add some indentation for lists to show their relation to the preceding text. The value is
+ chosen based on the left margin of the body and the blockquote.
+*/
+ul { margin-left: 50px; }
+ol { margin-left: 50px; }
+li { font-family:times new roman; font-size:14pt; margin-left: 5px; }
+
+
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
+
+/*
+ A class to be used for showing screenshot style images. These images will have padding above
+ and below the image and will be centered. To apply this to a file path, use this syntax:
+ <DIV class="image"><IMG src="..." /></DIV>
+*/
+div.image { margin-top: 20px; margin-bottom: 40px; text-align: center; }
+
+
+
/*
P tag code. Most of the help files nest P tags inside of blockquote tags (the was the
way it had been done in the beginning). The net effect is that the text is indented. In
@@ -40,11 +67,10 @@ h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size
*/
p { margin-left: 40px; font-family:times new roman; font-size:14pt; }
blockquote p { margin-left: 10px; }
-
p.providedbyplugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
-p.ProvidedByPlugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
p.relatedtopic { color:#800080; margin-left: 10px; font-size:14pt; }
-p.RelatedTopic { color:#800080; margin-left: 10px; font-size:14pt; }
+p.image { margin-top: 100; margin-bottom: 100; }
+
/*
We wish for a tables to have space between it and the preceding element, so that text
@@ -55,6 +81,8 @@ table { margin-left: 20px; margin-top: 10px; width: 80%;}
td { font-family:times new roman; font-size:14pt; vertical-align: top; }
th { font-family:times new roman; font-size:14pt; font-weight:bold; background-color: #EDF3FE; }
+
+
/*
Code-like formatting for things such as file system paths and proper names of classes,
methods, etc. To apply this to a file path, use this syntax: