GP-2887 - Updated the Equates Table to allow multiple selection; Updated

the default style sheet to define a class for images
This commit is contained in:
dragonmacher 2022-12-22 11:12:40 -05:00
parent d3fdc6d66d
commit 3bb026acc2
9 changed files with 478 additions and 480 deletions

View file

@ -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.bit.conflict = yellow
color.bg.plugin.editors.compositeeditor.non.bit = #A0A0FF 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.default = color.fg
color.fg.plugin.function.editor.dialog.textfield.error = color.fg.error 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.composite = plum
color.bg.plugin.datamgr.edge.reference = deepskyblue color.bg.plugin.datamgr.edge.reference = deepskyblue
color.fg.plugin.equate.enum = deepskyblue
color.bg.plugin.programdiff.highlight = darkRed color.bg.plugin.programdiff.highlight = darkRed

View file

@ -2,67 +2,58 @@
<HTML> <HTML>
<HEAD> <HEAD>
<META name="generator" content=
"HTML Tidy for Java (vers. 2009-12-01), see jtidy.sourceforge.net">
<TITLE>Equates</TITLE> <TITLE>Equates</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<LINK rel="stylesheet" type="text/css" href="help/shared/DefaultStyle.css"> <LINK rel="stylesheet" type="text/css" href="help/shared/DefaultStyle.css">
<META name="generator" content="Microsoft FrontPage 4.0">
</HEAD> </HEAD>
<BODY lang="EN-US"> <BODY>
<H1>Equates</H1> <H1>Equates</H1>
<P> <P>An Equate is a string substitution for <A href=
An Equate is a string substitution for <A href= "help/topics/Glossary/glossary.htm#Scalar">scalar</A> (a numeric value) in any code unit
"help/topics/Glossary/glossary.htm#Scalar">scalar</A> (a numeric value) in any code unit (instruction (instruction operand or data). For example, consider the instruction below:</P>
operand or data). For example, consider the instruction below:</P>
<P style="margin-left:100px"> <P style="margin-left:100px"><TT>MOV R2, $0xb</TT></P>
<TT>MOV R2, $0xb</TT>
</P>
<P>The scalar <I>$0xb</I> can be replaced with the string <I>BATTERY_FLAG_CRITICAL</I>. <P>The scalar <I>$0xb</I> can be replaced with the string <I>BATTERY_FLAG_CRITICAL</I>. This
This will yield the following:</P> will yield the following:</P>
<P style="margin-left:100px"> <P style="margin-left:100px"><TT>MOV R2, BATTERY_FLAG_CRITICAL</TT></P>
<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, <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 <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 equate application is your current location. "BATTERY_FLAG_CRITICAL" will replace the scalar
replace the scalar value <I>$0xb</I> only at the current cursor location unless you choose a value <I>$0xb</I> only at the current cursor location unless you choose a different option.
different option. However, when replacing another scalar of the same value, However, when replacing another scalar of the same value, a list of previously declared Equates
a list of previously declared Equates for that for that scalar value is presented.</P>
scalar value is presented.</P>
<P>Scalars can only be equated to strings. The string can be of any length and may <P>Scalars can only be equated to strings. The string can be of any length and may contain
contain spaces and special characters. Duplicate equate names are not allowed.</P> spaces and special characters. Duplicate equate names are not allowed.</P>
<BLOCKQUOTE> <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 <P><IMG alt="Note" src="help/shared/note.png">It should be noted that for the purposes of
contained in <i>code units</i>. A code unit is an instruction operand or other data element.</P> 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> </BLOCKQUOTE>
<P>There are several operations that are associated with Equates. They are:</P> <P>There are several operations that are associated with Equates. They are:</P>
<DIV style="margin-left: 2em" type="disc"> <BLOCKQUOTE>
<UL type="disc"> <UL>
<LI><A href="#Set_Equate">Set Equate</A></LI> <LI><A href="#Set_Equate">Set Equate</A></LI>
<LI><A href="#Rename_Equate">Rename 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="#Apply_Enum">Apply Enum</A></LI>
<LI><A href="#Equate_Table">View Equates</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> </UL>
</DIV> </BLOCKQUOTE>
<H2><A name="Set_Equate"></A>Set Equate</H2> <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>The <I>Set Equate</I> action will create one or more Equates in the Listing.</P>
<P>To set an Equate:</P> <P>To set an Equate:</P>
</BLOCKQUOTE>
<DIV style="margin-left: 2em" type=""> <OL>
<OL type="1">
<LI> <LI>
Right-mouse-click on the target scalar value<B>,</B> and select <B>Set Equate</B> or press Right-mouse-click on the target scalar value<B>,</B> and select <B>Set Equate</B> or
<B>&lt;E&gt;</B>.<BR> press <B>&lt;E&gt;</B>.
<BR><BR> <DIV class="image"><IMG src="images/SetEquate.png" alt="Set Equate Dialog" /></DIV>
<P align="center"><IMG src="images/SetEquate.png" alt="Set Equate Dialog"><BR>
</P>
<BR><BR>
</LI> </LI>
<LI>When the dialog appears, either type in an equate string or choose one from the list of <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 strings that are known to be associated with the given value. As you type in the "Equate
"Equate String" field, the list will be narrowed down to show only the strings that contain String" fi1eld, the list will be narrowed down to show only the strings that contain the
the text that has been typed.<BR> text that has been typed.
</LI> </LI>
<LI> <LI>
Select one of the choices from the "Apply To" list. <B>Current Location</B> is Select one of the choices from the "Apply To" list. <B>Current Location</B> is the
the default choice unless a selection is made, in which case the <B>Current Selection</B> option default choice unless a selection is made, in which case the <B>Current Selection</B>
will be set. The other option is <B>Entire Program.</B> option will be set. The other option is <B>Entire Program.</B>
<OL type="a"> <OL type="a">
<LI> <LI><B>Current Location</B>: When selected the equate will be applied to the scalar
<B>Current Location</B>: When selected the equate will be applied to the scalar value at the current location of your cursor only.</LI>
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
<LI> scalar values in your current selection that match the value of the scalar that you
<B>Current Selection</B>: When selected the equate will be applied to all of originally clicked. When you make a selection in your program this button will become
the scalar values in your current selection that match the value enabled. If you do not make a selection then it will not be enabled and the option will
of the scalar that you originally clicked. When you make a be grayed out. Note that scalars in your selection that already have an equate set will
selection in your program this button will become enabled. If you do not make a not be affected by this unless you also select the overwrite option.</LI>
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 <LI><B>Entire Program</B>: When selected the equate will be applied to all of the
by this unless you also select the overwrite option. scalar values in the entire program that also match the value of the scalar that you
</LI> originally right-mouse-clicked on.</LI>
<LI>
<B>Entire Program</B>: When selected the equate will be applied to all of the <LI><B>Overwrite existing equates</B>: This option is only enabled when setting equates
scalar values in the entire program that also match the value of the scalar that in a selection or the whole program. If this option is selected, all scalars and all
you originally right-mouse-clicked on. named equates in the selection or entire program, depending on which option is
</LI> selected, will be set with the user-given equate name. If the overwrite option is not
<LI> selected, only scalars not already with equates set will be assigned the user-given
<B>Overwrite existing equates</B>: This option is only enabled when setting equates in a selection or the whole program. If this equate name.</LI>
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> </OL>
</LI> </LI>
<LI>Double-click on an entry in the list, or select an entry in the list and press <SPAN <LI>Double-click on an entry in the list, or select an entry in the list and press
style="font-weight: bold;">OK,</SPAN> or type in the string and press OK. If any item <B>OK</B>, or type in the string and press OK. If any item in the list is selected it will
in the list is selected it will be used, otherwise the text in the "Equate String" field be used, otherwise the text in the "Equate String" field will be used.</LI>
will be used.</LI> </OL>
</BLOCKQUOTE>
</OL><SPAN style="font-family: times new roman;"><BR>
</SPAN>
</DIV>
<BLOCKQUOTE> <BLOCKQUOTE>
<P style="margin-left: 40px;"><SPAN style="font-family: times new roman;"><IMG alt="Note" src= <P><IMG alt="Note" src="help/shared/note.png"> The list of strings shown in the <B>Set
"help/shared/note.png"> The list of strings shown in the <SPAN style="font-weight: bold;">Set Equate</B> dialog are generated from two sources. The first source is all the currently
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
assigned equates to the given value. The other source is all the Enum datatypes that all the <B>open</B> datatype archives. If an Enum datatype exists that has a member value
exist in all the <SPAN style="font-weight: bold;">open</SPAN> datatype archives. If an equal to the given equate value, then that string will be included.</P>
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= <P><IMG alt="Note" src="help/shared/note.png">The <B>open</B> data type archives contain
"help/shared/note.png">The <SPAN style="font-weight: bold;">open</SPAN> data type archives valid enums and "fake" enums. The fake enums are created from #define values (parsed from .h
contain valid enums and "fake" enums. The fake enums are created from #define values files), specifically so that they will be available in the <B>Set Equate</B>
(parsed from .h files), specifically so that they will be available in the <SPAN style= dialog./P&gt;</P>
"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= <P><IMG alt="Note" src="help/shared/note.png"> Each entry in the dialog is color-coded based
"help/shared/note.png"> Each entry in the dialog is color-coded based upon how it is being used upon how it is being used as an equate.</P>
as an equate.<BR>
<OL type="a" style="margin-left: 80px;"> <OL type="a">
<LI> <LI><B>Blue</B>: Blue entries are existing user-defined string equates that are being used
<B>Blue</B>: Blue entries are existing user-defined string equates that are being used for that scalar.</LI>
for that scalar.
</LI>
<LI> <LI><B>Black</B>: Black entries are existing enum field equates being used for that
<B>Black</B>: Black entries are existing enum field equates being used for that scalar. scalar.</LI>
</LI>
<LI> <LI><B>Gray</B>: Gray entries are suggested enum fields that have the same value as the
<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>
scalar. These entries are only suggestions, and have not yet been made equates.
</LI>
</OL> </OL>
</SPAN></P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H2><A name="Rename_Equate"></A>Rename Equate</H2> <H2><A name="Rename_Equate"></A>Rename Equate</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>The <I>Rename Equate</I> action will rename one or more instances of a named Equate in the Listing.</P> <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> <P>To rename an Equate:</P>
</BLOCKQUOTE>
<DIV style="margin-left: 2em" type="">
<OL type="1"> <OL type="1">
<LI> <LI>
Right-mouse-click on the current Equate<B>,</B> and select <B>Rename Equate</B> or press Right-mouse-click on the current Equate<B>,</B> and select <B>Rename Equate</B> or press
<B>&lt;E&gt;</B>.<BR> <B>&lt;E&gt;</B>.<BR>
<DIV class="image">
<BR><BR> <IMG src="images/RenameEquate.png" alt="Rename Equate Dialog">
<P align="center"><IMG src="images/RenameEquate.png" alt="Rename Equate Dialog"><BR> </DIV>
</P>
<BR><BR>
</LI> </LI>
<LI> <LI>
Select one of the choices from the "Apply To" list. <B>Current Location</B> is Select one of the choices from the "Apply To" list. <B>Current Location</B> is the
the default choice unless a selection is made, in which case the <B>Current Selection</B> option default choice unless a selection is made, in which case the <B>Current Selection</B>
will be set. The other option is <B>Entire Program.</B> option will be set. The other option is <B>Entire Program.</B>
<OL type="a"> <OL type="a">
<LI> <LI><B>Current Location</B>: When selected the equate will be applied to the scalar
<B>Current Location</B>: When selected the equate will be applied to the scalar value at the current location of your cursor only.</LI>
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
<LI> scalar values in your current selection that match the value of the scalar that you
<B>Current Selection</B>: When selected the equate will be applied to all of originally clicked. When you make a selection in your program this button will become
the scalar values in your current selection that match the value enabled. If you do not make a selection then it will not be enabled and the option will
of the scalar that you originally clicked. When you make a be grayed out.</LI>
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><B>Entire Program</B>: When selected the equate will be applied to all of the
</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 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 originally clicked. Scalars that already have an equate set that is different from the
is different from the one you selected will not be affected. one you selected will not be affected.</LI>
</LI>
</OL> </OL>
</LI> </LI>
<LI>Double-click an entry in the list, select an entry in the list and press <SPAN <LI>Double-click an entry in the list, select an entry in the list and press <B>OK</B>, or
style="font-weight: bold;">OK,</SPAN> or type in the string and press <b>OK</b>. If any item type in the string and press <B>OK</B>. If any item in the list is selected it will be
in the list is selected it will be used, otherwise the text in the "Equate String" field used, otherwise the text in the "Equate String" field will be used.</LI>
will be used.</LI> </OL>
</DIV> </BLOCKQUOTE>
<H2><A name="CBAnnotationEquateRemoveEquate"></A><A name="Delete_Equate"></A><A name=
"Remove_Equate"></A>Remove Equate</H2> <H2><A name="Delete_Equate"></A><A name="Remove_Equate"></A>Remove Equate</H2>
<BLOCKQUOTE> <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> <P>To remove references to an Equate via the context popup menu:</P>
</BLOCKQUOTE>
<DIV style="margin-left: 2em" type="">
<OL> <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> &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 <LI>
matching the one you clicked will be removed. 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> <DIV class="image">
<IMG src="images/RemoveSelection.png" alt="Confirm Equate Remove Dialog"></P> <IMG src="images/RemoveSelection.png" alt="Confirm Equate Remove Dialog">
</DIV>
<P align="center"></P>
</LI> </LI>
</OL> </OL>
</DIV>
<BLOCKQUOTE>
<P>To remove all references of an Equate via the <I>Equates Table</I> window:</P> <P>To remove all references of an Equate via the <I>Equates Table</I> window:</P>
</BLOCKQUOTE>
<DIV style="margin-left: 2em" type="">
<OL> <OL>
<LI>Select the Code Browser menu option <B>Window<IMG src="help/shared/arrow.gif" border= <LI>Select the Code Browser menu option <B>Window<IMG alt="" src="help/shared/arrow.gif"
"0">Equates Table</B> to bring up the <I>Equates Table</I> window.</LI> 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>Right-mouse-click on the Equate to be deleted and select <B>Delete</B>.</LI>
<LI> <LI>
A confirmation dialog will appear. A confirmation dialog will appear.
<P align="center"><BR> <DIV class="image">
<IMG src="images/ConfirmEquateDelete.png" alt="Confirm Equate Delete Dialog"></P> <IMG src="images/ConfirmEquateDelete.png" alt="Confirm Equate Delete Dialog">
</DIV>
<P align="center"></P>
</LI> </LI>
<LI>Select <B>Delete</B> to remove all references to the equate and the Equate's definition <LI>Select <B>Delete</B> to remove all references to the equate and the Equate's definition
itself.<BR> itself.<BR>
</LI> </LI>
</OL> </OL>
</DIV> </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> <H2><A name="Apply_Enum"></A> Apply Enum</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>The <I>Apply Enum</I> action (only available when there is a selection), will apply <P>The <I>Apply Enum</I> action (only available when there is a selection), will apply enum
enum member names to scalars in the current selection if any of the enum values match member names to scalars in the current selection if any of the enum values match those
those scalars.</P> scalars.</P>
<P>To apply an enum to the selection:</P> <P>To apply an enum to the selection:</P>
</BLOCKQUOTE>
<DIV style="margin-left: 2em" type="">
<OL> <OL>
<LI> Make a selection and then Right-mouse-click, then choose <B>Apply Enum</B>. <LI>
Make a selection and then Right-mouse-click, then choose <B>Apply Enum</B>.
<P align="center"><BR> <DIV class="image">
<IMG src="images/BeforeApplyEnum.png" alt="Apply Enum Popup"></P> <IMG src="images/BeforeApplyEnum.png" alt="Apply Enum Popup">
</DIV>
<P align="center"></P>
</LI> </LI>
<LI>A dialog similar to the one below should appear. Select the enum that <LI>
you want to be applied to the selection. The data type must be an enum for the action A dialog similar to the one below should appear. Select the enum that you want to be
to work. applied to the selection. The data type must be an enum for the action to work.
<P align="center"><BR> <DIV class="image">
<IMG src="images/ApplyEnum.png" alt="Apply Enum Popup"></P> <IMG src="images/ApplyEnum.png" alt="Apply Enum Popup">
</DIV>
<P align="center"></P>
<UL> <UL>
<LI><I>Apply to sub-operands</I> - Applies the enum to scalars within operands.</LI> <LI><I>Apply to sub-operands</I> - Applies the enum to scalars within operands.</LI>
</UL> </UL>
<P>Once the data type is selected, the scalars in the selection will have equates <P>Once the data type is selected, the scalars in the selection will have equates applied
applied to them as shown below.</P> to them as shown below.</P>
<P align="center"><BR>
<IMG src="images/AfterApplyEnum.png" alt="Apply Enum Popup"></P>
<P align="center"></P>
<DIV class="image">
<IMG src="images/AfterApplyEnum.png" alt="Apply Enum Popup">
</DIV>
</LI> </LI>
</OL> </OL>
</DIV> </BLOCKQUOTE>
<H2><A name="Equate_Table"></A> <A name="Display_Equates_Table"></A> View Equates</H2> <H2><A name="Equate_Table"></A> <A name="Display_Equates_Table"></A> View Equates</H2>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>The <I>Display Equates Table</I> action displays a window which lists all of the Equates <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> and their references in a tabular format.</P>
</BLOCKQUOTE>
<DIV align="center"> <DIV class="image">
<CENTER> <IMG src="images/EquatesTable.png" alt="Equates Table" border="0">
<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>
</BLOCKQUOTE>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>The left panel, <I>Equates,</I> lists name, value, and number of references for all <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 Equates. The right panel, <I>References,</I> lists the address and operand index of each
each location that references the Equate selected in the left panel. Selecting an location that references the Equate selected in the left panel. Selecting an address on the
address on the <I>References</I> panel will cause the Code Browser to go to that address in <I>References</I> panel will cause the Code Browser to go to that address in the listing. The
the listing. The <I>Equates</I> panel and the <I>References</I> panel can each be <I>Equates</I> panel and the <I>References</I> panel can each be sorted by any column. The
sorted by any column. The ascending and descending indicator displays the sort order of ascending and descending indicator displays the sort order of the information.</P>
the information.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<BLOCKQUOTE> <BLOCKQUOTE>
<P>To view the <I>Equates Table</I> select the Code Browser menu option <B>Window<IMG src= <P>To view the <I>Equates Table</I> select the Code Browser menu option <B>Window<IMG alt=""
"help/shared/arrow.gif" border="0">Equates Table</B> to bring up the <I>Equates Table</I> src="help/shared/arrow.gif" border="0">Equates Table</B> to bring up the <I>Equates Table</I>
window.</P> window.</P>
<P>You can re-order the columns in the Equates table by dragging the header to another <P>You can re-order the columns in the Equates table by dragging the header to another
@ -363,61 +326,53 @@
Op Index. By default, the references are sorted by reference address in ascending order.<BR> Op Index. By default, the references are sorted by reference address in ascending order.<BR>
</P> </P>
<P>You can also rename the equate by double clicking in the name field and entering a <P>You can rename an equate by double-clicking the name field and entering a new
new name. If the equate is based off of an enum, then an enum editor dialog will appear. name. If the equate is based off of an enum, then double-clicking will not trigger an edit.
Changing the matching field name will also change the equate name.<BR> 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>
<P style="margin-left: 40px;"><SPAN style="font-family: times new roman;"><IMG alt="Note" src= <P><IMG alt="Note" src="help/shared/note.png"> Each equate is color-coded based upon how it
"help/shared/note.png"> Each equate is color-coded based upon how it is being used.<BR> is being used.</P>
<OL type="a" style="margin-left: 80px;"> <BLOCKQUOTE>
<LI> <OL type="a">
<B>Blue</B>: Blue equates are existing user-defined string equates that are being used <LI><B>Blue</B>: Blue equates are existing user-defined string equates that are being
for that scalar. used for that scalar.</LI>
</LI>
<LI> <LI><B>Black</B>: Black equates are existing enum field equates being used for that
<B>Black</B>: Black equates are existing enum field equates being used for that scalar. scalar.</LI>
</LI>
<LI> <LI><B>Red</B>: Red entries are bad equates. A bad equate could either mean that the enum
<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 that this equate is based off of was deleted, the field inside the enum was deleted, or
the field's value was changed. the field's value was changed.</LI>
</LI>
</OL> </OL>
</BLOCKQUOTE>
</SPAN></P>
</BLOCKQUOTE> </BLOCKQUOTE>
<H2><A name="CBAnnotationEquateConvertSignedDecimal"></A><A name="Convert"></A>Convert</H2> <H2><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 <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 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 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. these actions and equates are not currently supported for composite and array data. For
For instruction operands, the scalar number is converted visually by replacing the number with an 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 appropriately named equate. Such a conversion can be cleared by removing the equate from the
from the operand. For data value fields, a combination of data format settings and signed/unsigned operand. For data value fields, a combination of data format settings and signed/unsigned data
data type alteration is used to reflect a conversion. The available formats are as follows.<BR> type alteration is used to reflect a conversion. The available formats are as follows.</P>
</P>
</DIV>
<BLOCKQUOTE> <BLOCKQUOTE>
<H3><A name="Convert_To_Signed_Decimal"></A>Signed Decimal</H3> <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 <P>The existing scalar value will be displayed as a signed decimal number. This action is
is only available if the value can be interpreted as a negative value.<BR> only available if the value can be interpreted as a negative value.<BR>
</P> </P>
<H3><A name="Convert_To_Unsigned_Decimal"></A>Unsigned Decimal</H3> <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 <P>The existing scalar value will be displayed as an unsigned decimal number. If the value
value would be positive even if the signed decimal format was selected, the action will would be positive even if the signed decimal format was selected, the action will simply be
simply be name <SPAN style="font-weight: bold;">Decimal</SPAN> instead of <SPAN style= name <B>Decimal</B> instead of <B>Unsigned Decimal</B>.</P>
"font-weight: bold;">Unsigned Decimal</SPAN>.</P>
<H3><A name="Convert_To_Unsigned_Octal"></A>Unsigned Octal</H3> <H3><A name="Convert_To_Unsigned_Octal"></A>Unsigned Octal</H3>
@ -425,10 +380,10 @@
<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 <P>The existing scalar value will be displayed as a signed hexadecimal number. This action is
is only available if the value can be interpreted as a negative value, and only available if the value can be interpreted as a negative value, and is only supported on
is only supported on instruction operands since the data hex format instruction operands since the data hex format currently supports unsigned rendering
currently supports unsigned rendering only.</P> only.</P>
<H3><A name="Convert_To_Unsigned_Hex"></A>Unsigned Hex</H3> <H3><A name="Convert_To_Unsigned_Hex"></A>Unsigned Hex</H3>
@ -437,44 +392,48 @@
<H3><A name="Convert_To_Char"></A>Char / Char Sequence</H3> <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 <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 sequence of ASCII characters, whichever is more appropriate. Invalid and non-printable ASCII
ASCII characters will be rendered in hex (e.g., \x20).<BR> characters will be rendered in hex (e.g., \x20).</P>
</P>
<H3><A name="Convert_To_Unsigned_Binary"></A>Unsigned Binary</H3> <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>The existing scalar value will be displayed as an unsigned binary number.</P>
</P>
<H3><A name="Convert_To_Float"></A>Float</H3> <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 <P>The existing scalar value will be displayed as a IEEE 754 single precision floating point
and will match the size of the Float data type. This action is only supported on instruction number. The floating point size is processor specific and will match the size of the Float
operands.<BR> data type. This action is only supported on instruction operands.</P>
</P>
<H3><A name="Convert_To_Double"></A>Double</H3> <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 <P>The existing scalar value will be displayed as a IEEE 754 double precision floating point
and will match the size of the Double data type. This action is only supported on instruction number. The floating point size is processor specific and will match the size of the Double
operands.<BR> data type. This action is only supported on instruction operands.</P>
</P>
<P><IMG src="help/shared/tip.png" alt="" border="0"> The convert actions also work on an <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. 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> 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 <P><IMG src="help/shared/tip.png" alt="" border="0"> Based upon how an instruction is
is implemented by its' associated language module, a hexadecimal operand which appears implemented by its' associated language module, a hexadecimal operand which appears to be
to be negative may in fact be a positive scalar with negative sign '-' character prepended. negative may in fact be a positive scalar with negative sign '-' character prepended. In such
In such cases, the convert action may not produce the expected result.</P> 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 <P><IMG src="help/shared/tip.png" alt="" border="0"> The presence of a primary reference on
on an operand may prevent rendering of the converted scalar value since reference an operand may prevent rendering of the converted scalar value since reference markup takes
markup takes precedence over equates and data formatting.</P> precedence over equates and data formatting.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<P class="providedbyplugin">Provided By: <I>EquatePlugin</I> and <I>EquateTablePlugin</I></P> <P class="providedbyplugin">Provided By: <I>EquatePlugin</I> and <I>EquateTablePlugin</I></P>
<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> <BR>
</BODY> </BODY>
</HTML> </HTML>

View file

@ -32,7 +32,6 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
private EquateTablePlugin plugin; private EquateTablePlugin plugin;
private List<EquateReference> referenceList = new ArrayList<>(); private List<EquateReference> referenceList = new ArrayList<>();
private Equate currentEquate = null;
EquateReferenceTableModel(EquateTablePlugin plugin) { EquateReferenceTableModel(EquateTablePlugin plugin) {
super(plugin.getTool()); super(plugin.getTool());
@ -70,18 +69,11 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
return null; return null;
} }
Equate getEquate() {
return currentEquate;
}
void setEquate(Equate equate) { void setEquate(Equate equate) {
this.currentEquate = equate; populateReferences(equate);
populateReferences();
} }
private void populateReferences(Equate equate) {
private void populateReferences() {
referenceList.clear(); referenceList.clear();
Program program = getProgram(); Program program = getProgram();
@ -90,14 +82,11 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
} }
EquateTable equateTable = program.getEquateTable(); EquateTable equateTable = program.getEquateTable();
if (equateTable == null || currentEquate == null) { if (equateTable == null || equate == null) {
return; return;
} }
// @formatter:off referenceList.addAll(Arrays.asList(equate.getReferences()));
Arrays.asList(currentEquate.getReferences())
.forEach(r -> referenceList.add(r));
// @formatter:on
fireTableDataChanged(); fireTableDataChanged();
} }
@ -131,7 +120,7 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
@Override @Override
public Address getValue(EquateReference rowObject, Settings settings, Object data, public Address getValue(EquateReference rowObject, Settings settings, Object data,
ServiceProvider serviceProvider) throws IllegalArgumentException { ServiceProvider sp) throws IllegalArgumentException {
return rowObject.getAddress(); return rowObject.getAddress();
} }
@ -147,7 +136,7 @@ class EquateReferenceTableModel extends GDynamicColumnTableModel<EquateReference
@Override @Override
public Short getValue(EquateReference rowObject, Settings settings, Object data, public Short getValue(EquateReference rowObject, Settings settings, Object data,
ServiceProvider serviceProvider) throws IllegalArgumentException { ServiceProvider sp) throws IllegalArgumentException {
return rowObject.getOpIndex(); return rowObject.getOpIndex();
} }

View file

@ -200,8 +200,8 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
} }
@Override @Override
public String getValue(Equate rowObject, Settings settings, Object data, public String getValue(Equate rowObject, Settings settings, Object data, ServiceProvider sp)
ServiceProvider sp) throws IllegalArgumentException { throws IllegalArgumentException {
return rowObject.getDisplayName(); return rowObject.getDisplayName();
} }
@ -251,8 +251,8 @@ class EquateTableModel extends GDynamicColumnTableModel<Equate, Object> {
} }
@Override @Override
public Long getValue(Equate rowObject, Settings settings, Object data, public Long getValue(Equate rowObject, Settings settings, Object data, ServiceProvider sp)
ServiceProvider sp) throws IllegalArgumentException { throws IllegalArgumentException {
FormatSettingsDefinition formatDef = FormatSettingsDefinition.DEF; FormatSettingsDefinition formatDef = FormatSettingsDefinition.DEF;

View file

@ -26,7 +26,7 @@ import javax.swing.table.TableCellEditor;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.*;
import docking.widgets.OptionDialog; import docking.action.builder.ActionBuilder;
import docking.widgets.label.GLabel; import docking.widgets.label.GLabel;
import ghidra.app.context.ProgramActionContext; import ghidra.app.context.ProgramActionContext;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
@ -61,7 +61,7 @@ public class EquateTableProvider extends ComponentProviderAdapter {
this.plugin = plugin; this.plugin = plugin;
mainPanel = createWorkPanel(); mainPanel = createWorkPanel();
addToTool(); addToTool();
createAction(); createActions();
} }
@Override @Override
@ -107,18 +107,12 @@ public class EquateTableProvider extends ComponentProviderAdapter {
void updateEquates() { void updateEquates() {
// restore selection after update // restore selection after update
int row = equatesTable.getSelectedRow(); List<Equate> selectedItems = equatesFilterPanel.getSelectedItems();
equatesModel.update(); equatesModel.update();
int rows = equatesTable.getRowCount(); equatesFilterPanel.setSelectedItems(selectedItems);
if (row < 0 || row >= rows) {
row = 0;
}
if (rows > 0) {
equatesTable.setRowSelectionInterval(row, row);
}
handleEquateTableSelection(); 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 -> { equatesTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting()) { if (e.getValueIsAdjusting()) {
return; return;
@ -212,7 +169,7 @@ public class EquateTableProvider extends ComponentProviderAdapter {
equatesTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); equatesTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
equatesTable.setPreferredScrollableViewportSize(new Dimension(350, 150)); equatesTable.setPreferredScrollableViewportSize(new Dimension(350, 150));
equatesTable.setRowSelectionAllowed(true); equatesTable.setRowSelectionAllowed(true);
equatesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); equatesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
equatesFilterPanel = new GhidraTableFilterPanel<>(equatesTable, equatesModel); equatesFilterPanel = new GhidraTableFilterPanel<>(equatesTable, equatesModel);
@ -223,8 +180,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
equatesPanel.add(equatesTablePane, BorderLayout.CENTER); equatesPanel.add(equatesTablePane, BorderLayout.CENTER);
equatesPanel.add(equatesFilterPanel, BorderLayout.SOUTH); equatesPanel.add(equatesFilterPanel, BorderLayout.SOUTH);
//////////////////////////////////////////////////////////////
referencesModel = new EquateReferenceTableModel(plugin); referencesModel = new EquateReferenceTableModel(plugin);
referencesTable = new GhidraTable(referencesModel); referencesTable = new GhidraTable(referencesModel);
@ -248,8 +203,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
referencesPanel.add(new GLabel("References", SwingConstants.CENTER), "North"); referencesPanel.add(new GLabel("References", SwingConstants.CENTER), "North");
referencesPanel.add(referencesTablePane, "Center"); referencesPanel.add(referencesTablePane, "Center");
//////////////////////////////////////////////////////////////
JPanel workPanel = new JPanel(new BorderLayout()); JPanel workPanel = new JPanel(new BorderLayout());
JSplitPane splitPane = JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, equatesPanel, referencesPanel); new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, equatesPanel, referencesPanel);
@ -260,12 +213,47 @@ public class EquateTableProvider extends ComponentProviderAdapter {
} }
private void handleEquateTableSelection() { private void handleEquateTableSelection() {
int[] rows = equatesTable.getSelectedRows();
if (rows.length > 1) {
referencesTable.clearSelection();
referencesModel.setEquate(null);
return;
}
Equate equate = equatesFilterPanel.getSelectedItem(); Equate equate = equatesFilterPanel.getSelectedItem();
referencesTable.clearSelection(); referencesTable.clearSelection();
referencesModel.setEquate(equate); 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; Icon deleteImage = Icons.DELETE_ICON;
deleteAction = new DockingAction("Delete Equate", plugin.getName()) { deleteAction = new DockingAction("Delete Equate", plugin.getName()) {
@ -290,22 +278,56 @@ public class EquateTableProvider extends ComponentProviderAdapter {
SelectionNavigationAction selectionNavigationAction = SelectionNavigationAction selectionNavigationAction =
new SelectionNavigationAction(plugin, referencesTable); new SelectionNavigationAction(plugin, referencesTable);
selectionNavigationAction.setHelpLocation( selectionNavigationAction
new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation")); .setHelpLocation(new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation"));
tool.addLocalAction(this, deleteAction); tool.addLocalAction(this, deleteAction);
tool.addLocalAction(this, selectionNavigationAction); 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(); TableCellEditor cellEditor = equatesTable.getCellEditor();
if (cellEditor != null) { if (cellEditor != null) {
cellEditor.stopCellEditing(); cellEditor.stopCellEditing();
} }
List<Equate> equates = equatesFilterPanel.getSelectedItems();
plugin.deleteEquates(equates); 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() { EquateTableModel getEquatesModel() {
return equatesModel; return equatesModel;
} }

View file

@ -17,9 +17,6 @@ package ghidra.app.plugin.core.equate;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.awt.Rectangle;
import java.util.*;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
@ -40,7 +37,6 @@ import ghidra.program.util.OperandFieldLocation;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.test.*; import ghidra.test.*;
import ghidra.util.table.GhidraTable; import ghidra.util.table.GhidraTable;
import util.CollectionUtils;
/** /**
* Tests for the equate table plugin. * Tests for the equate table plugin.
@ -114,16 +110,6 @@ public class EquateTablePluginTest extends AbstractGhidraHeadedIntegrationTest {
env.dispose(); 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 @Test
public void testShowReferences() { public void testShowReferences() {
setRowSelection(equatesTable, 1, 1);// this triggers the refs table to update setRowSelection(equatesTable, 1, 1);// this triggers the refs table to update
@ -370,37 +356,6 @@ public class EquateTablePluginTest extends AbstractGhidraHeadedIntegrationTest {
waitForProgram(program); 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) { private String getRenderedValue(TableCellRenderer renderer, int row, int column) {
return runSwing(() -> { return runSwing(() -> {

View file

@ -26,6 +26,7 @@ import javax.swing.event.*;
import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import org.apache.commons.collections4.CollectionUtils;
import org.jdom.Element; import org.jdom.Element;
import docking.DockingWindowManager; import docking.DockingWindowManager;
@ -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 * 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 * @param t the row object to select
*/ */
public void setSelectedItem(ROW_OBJECT t) { public void setSelectedItem(ROW_OBJECT t) {
if (t == null) {
table.clearSelection();
return;
}
int viewRow = textFilterModel.getViewIndex(t); int viewRow = textFilterModel.getViewIndex(t);
if (viewRow >= 0) { if (viewRow >= 0) {
table.setRowSelectionInterval(viewRow, viewRow); 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. * Scrolls the view to the currently selected item.
*/ */

View file

@ -15,22 +15,49 @@
*/ */
/* /*
WARNING! 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 Java Help Note: JavaHelp does not accept sizes (like in 'margin-top') in anything but
px (pixel) or with no type marking. 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 */ 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; } 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; } 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; } 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; } 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 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 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; } p { margin-left: 40px; font-family:times new roman; font-size:14pt; }
blockquote p { margin-left: 10px; } 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.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.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 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; } 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; } 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, 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: methods, etc. To apply this to a file path, use this syntax: