GP-5438: Fix 'Select All' and others in Dynamic Listing. (syncing needs follow-up work.)

This commit is contained in:
Dan 2025-04-01 12:48:30 +00:00
parent b319b3df7f
commit d7f63a9075
42 changed files with 432 additions and 358 deletions

View file

@ -31,7 +31,8 @@ import docking.action.ToggleDockingAction;
import generic.theme.GColor; import generic.theme.GColor;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.codebrowser.MarkerServiceBackgroundColorModel; import ghidra.app.plugin.core.codebrowser.MarkerServiceBackgroundColorModel;
import ghidra.app.plugin.core.debug.*; import ghidra.app.plugin.core.debug.AbstractDebuggerPlugin;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent; import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.*; import ghidra.app.plugin.core.debug.gui.DebuggerResources.*;
import ghidra.app.plugin.core.debug.gui.action.DebuggerTrackLocationTrait; import ghidra.app.plugin.core.debug.gui.action.DebuggerTrackLocationTrait;
@ -58,12 +59,21 @@ import ghidra.trace.model.program.TraceProgramView;
import ghidra.trace.model.time.schedule.TraceSchedule; import ghidra.trace.model.time.schedule.TraceSchedule;
import ghidra.util.Msg; import ghidra.util.Msg;
@PluginInfo(shortDescription = "Compare memory state between times in a trace", description = "Provides a side-by-side diff view between snapshots (points in time) in a " + @PluginInfo(
"trace. The comparison is limited to raw bytes.", category = PluginCategoryNames.DEBUGGER, packageName = DebuggerPluginPackage.NAME, status = PluginStatus.RELEASED, eventsConsumed = { shortDescription = "Compare memory state between times in a trace",
description = "Provides a side-by-side diff view between snapshots (points in time) in a " +
"trace. The comparison is limited to raw bytes.",
category = PluginCategoryNames.DEBUGGER,
packageName = DebuggerPluginPackage.NAME,
status = PluginStatus.RELEASED,
eventsConsumed = {
TraceClosedPluginEvent.class, TraceClosedPluginEvent.class,
}, eventsProduced = {}, servicesRequired = { },
eventsProduced = {},
servicesRequired = {
DebuggerListingService.class, DebuggerListingService.class,
}, servicesProvided = {}) },
servicesProvided = {})
public class DebuggerTraceViewDiffPlugin extends AbstractDebuggerPlugin { public class DebuggerTraceViewDiffPlugin extends AbstractDebuggerPlugin {
static final Color COLOR_DIFF = new GColor("color.bg.highlight.listing.diff"); static final Color COLOR_DIFF = new GColor("color.bg.highlight.listing.diff");

View file

@ -41,9 +41,4 @@ public class DebuggerListingActionContext extends ListingActionContext
public TraceProgramView getProgram() { public TraceProgramView getProgram() {
return (TraceProgramView) super.getProgram(); return (TraceProgramView) super.getProgram();
} }
@Override
public DebuggerListingProvider getComponentProvider() {
return (DebuggerListingProvider) super.getComponentProvider();
}
} }

View file

@ -408,7 +408,7 @@ public class DebuggerListingProvider extends CodeViewerProvider {
protected MarkerMarginProvider markerMarginProvider; protected MarkerMarginProvider markerMarginProvider;
protected MarkerOverviewProvider markerOverviewProvider; protected MarkerOverviewProvider markerOverviewProvider;
private SuppressableCallback<ProgramLocation> cbGoTo = new SuppressableCallback<>(); private final SuppressableCallback<ProgramLocation> cbGoTo = new SuppressableCallback<>();
protected final ForStaticSyncMappingChangeListener mappingChangeListener = protected final ForStaticSyncMappingChangeListener mappingChangeListener =
new ForStaticSyncMappingChangeListener(); new ForStaticSyncMappingChangeListener();

View file

@ -1,25 +0,0 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.app.context;
/**
* Marker interface to signal a context specifically for actions that work on a range of
* program locations.
*/
public interface NavigatableRangeActionContext {
}

View file

@ -15,12 +15,14 @@
*/ */
package ghidra.app.context; package ghidra.app.context;
import docking.ActionContext;
/** /**
* An interface that signals the client supports navigation. * An interface that signals the client supports navigation.
* *
* <P>Note: the {@link NavigatableActionContext} is tied to {@link ProgramLocationActionContext} * <P>Note: the {@link NavigatableActionContext} is tied to {@link ProgramLocationActionContext}
* which has more baggage than just 'navigation'. * which has more baggage than just 'navigation'.
*/ */
public interface NavigationActionContext { public interface NavigationActionContext extends ActionContext {
// marker interface // marker interface
} }

View file

@ -33,7 +33,6 @@ import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.util.FieldNavigator; import ghidra.app.util.viewer.util.FieldNavigator;
import ghidra.framework.model.DomainObject; import ghidra.framework.model.DomainObject;
import ghidra.framework.plugintool.ModalPluginTool; import ghidra.framework.plugintool.ModalPluginTool;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.util.PluginException; import ghidra.framework.plugintool.util.PluginException;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
@ -46,8 +45,7 @@ import help.Help;
import help.HelpService; import help.HelpService;
/** /**
* Top level object that manages each step of the merge/resolve conflicts * Top level object that manages each step of the merge/resolve conflicts process.
* process.
*/ */
public class ProgramMultiUserMergeManager extends MergeManager { public class ProgramMultiUserMergeManager extends MergeManager {
@ -113,6 +111,7 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Returns one of the four programs involved in the merge as indicated by the version. * Returns one of the four programs involved in the merge as indicated by the version.
*
* @param version the program version to return. (LATEST, MY, ORIGINAL, or RESULT). * @param version the program version to return. (LATEST, MY, ORIGINAL, or RESULT).
* @return the indicated program version or null if a valid version isn't specified. * @return the indicated program version or null if a valid version isn't specified.
* @see MergeConstants * @see MergeConstants
@ -165,9 +164,12 @@ public class ProgramMultiUserMergeManager extends MergeManager {
} }
/** /**
* Show the default merge panel. The default merge panel now shows the status of each phase * Show the default merge panel.
* of the merge and also the progress in the current phase. * <p>
*@param description description of current merge process near the top of the merge tool. * The default merge panel now shows the status of each phase of the merge and also the progress
* in the current phase.
*
* @param description description of current merge process near the top of the merge tool.
*/ */
@Override @Override
public void showDefaultMergePanel(final String description) { public void showDefaultMergePanel(final String description) {
@ -179,14 +181,15 @@ public class ProgramMultiUserMergeManager extends MergeManager {
} }
/** /**
* Show the component that is used to resolve conflicts. This method * Show the component that is used to resolve conflicts.
* is called by the MergeResolvers when user input is required. If the * <p>
* component is not null, this method blocks until the user either * This method is called by the MergeResolvers when user input is required. If the component is
* cancels the merge process or resolves a conflict. If comp is null, * not null, this method blocks until the user either cancels the merge process or resolves a
* then the default component is displayed, and the method does not * conflict. If comp is null, then the default component is displayed, and the method does not
* wait for user input. * wait for user input.
* @param comp component to show; if component is null, show the *
* default component and do not block * @param comp component to show; if component is null, show the default component and do not
* block
* @param componentID id or name for the component * @param componentID id or name for the component
*/ */
@Override @Override
@ -202,7 +205,7 @@ public class ProgramMultiUserMergeManager extends MergeManager {
showMergeTool(); showMergeTool();
Dimension oldSize = mergeTool.getSize(); Dimension oldSize = mergeTool.getSize();
if (listingPlugin != null) { if (listingPlugin != null) {
mergeTool.removePlugins(new Plugin[] { listingPlugin, goToPlugin }); mergeTool.removePlugins(java.util.List.of(listingPlugin, goToPlugin));
listingPlugin = null; listingPlugin = null;
goToPlugin = null; goToPlugin = null;
} }
@ -227,6 +230,7 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Show the listing merge panel. * Show the listing merge panel.
*
* @param goToAddress the address to goto. * @param goToAddress the address to goto.
*/ */
public void showListingMergePanel(final Address goToAddress) { public void showListingMergePanel(final Address goToAddress) {
@ -265,7 +269,9 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Show the listing merge panel with each listing positioned to the indicated address. * Show the listing merge panel with each listing positioned to the indicated address.
* <p>
* A null can be passed for any address to indicate that listing should be empty. * A null can be passed for any address to indicate that listing should be empty.
*
* @param resultAddress the address for positioning the Result program's listing. * @param resultAddress the address for positioning the Result program's listing.
* @param latestAddress the address for positioning the Latest program's listing. * @param latestAddress the address for positioning the Latest program's listing.
* @param myAddress the address for positioning the My program's listing. * @param myAddress the address for positioning the My program's listing.
@ -291,7 +297,9 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Show the listing merge panel with each listing positioned to the indicated address. * Show the listing merge panel with each listing positioned to the indicated address.
* <p>
* A null can be passed for any address to indicate that listing should be empty. * A null can be passed for any address to indicate that listing should be empty.
*
* @param resultAddress the address for positioning the Result program's listing. * @param resultAddress the address for positioning the Result program's listing.
* @param latestAddress the address for positioning the Latest program's listing. * @param latestAddress the address for positioning the Latest program's listing.
* @param myAddress the address for positioning the My program's listing. * @param myAddress the address for positioning the My program's listing.
@ -368,16 +376,19 @@ public class ProgramMultiUserMergeManager extends MergeManager {
return; return;
} }
mergePanel.removeDomainObjectListener(); mergePanel.removeDomainObjectListener();
mergeTool.removePlugins(new Plugin[] { listingPlugin, goToPlugin }); mergeTool.removePlugins(java.util.List.of(listingPlugin, goToPlugin));
isShowingListingMergePanel = false; isShowingListingMergePanel = false;
mergePlugin.showDefaultComponent(); mergePlugin.showDefaultComponent();
}); });
} }
/** /**
* Returns the listing merge panel. This is the panel containing the four * Returns the listing merge panel.
* listing windows: result, latest, my, and original. The four listings are * <p>
* the center component of JPanel with a BorderLayout. * This is the panel containing the four listing windows: result, latest, my, and original. The
* four listings are the center component of {@link JPanel} with a {@link BorderLayout}.
*
* @return the merge panel
*/ */
public ListingMergePanel getListingMergePanel() { public ListingMergePanel getListingMergePanel() {
return mergePanel; return mergePanel;
@ -385,6 +396,7 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Determines if the modal merge tool is currently displayed on the screen. * Determines if the modal merge tool is currently displayed on the screen.
*
* @return true if the merge tool is displayed. * @return true if the merge tool is displayed.
*/ */
@Override @Override
@ -394,6 +406,7 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Determines if the four program Listing merge panel is currently displayed in the merge tool. * Determines if the four program Listing merge panel is currently displayed in the merge tool.
*
* @return true if the Listing merge panel is displayed. * @return true if the Listing merge panel is displayed.
*/ */
public boolean isShowingListingMergePanel() { public boolean isShowingListingMergePanel() {
@ -402,7 +415,9 @@ public class ProgramMultiUserMergeManager extends MergeManager {
/** /**
* Determine if the listing panels should be rendered. * Determine if the listing panels should be rendered.
* <p>
* NOTE: This is provided for testing performance reasons only. * NOTE: This is provided for testing performance reasons only.
*
* @return true if listing panels should be rendered * @return true if listing panels should be rendered
*/ */
public boolean isShowListingPanel() { public boolean isShowListingPanel() {

View file

@ -299,6 +299,7 @@ public class ListingMergePanel extends JPanel
/** /**
* Color the background of all 4 listings to the indicated color for the indicated addresses. * Color the background of all 4 listings to the indicated color for the indicated addresses.
*
* @param addrSet the addresses * @param addrSet the addresses
*/ */
public void paintAllBackgrounds(AddressSetView addrSet) { public void paintAllBackgrounds(AddressSetView addrSet) {
@ -365,6 +366,7 @@ public class ListingMergePanel extends JPanel
/** /**
* Adds a button press listener. * Adds a button press listener.
*
* @param listener the listener to add. * @param listener the listener to add.
*/ */
public void addButtonPressedListener(ButtonPressedListener listener) { public void addButtonPressedListener(ButtonPressedListener listener) {
@ -375,6 +377,7 @@ public class ListingMergePanel extends JPanel
/** /**
* Get the indicated program version. * Get the indicated program version.
*
* @param version LATEST, CHECKED_OUT, ORIGINAL, RESULT from MergeConstants * @param version LATEST, CHECKED_OUT, ORIGINAL, RESULT from MergeConstants
* @return the program * @return the program
*/ */
@ -383,8 +386,8 @@ public class ListingMergePanel extends JPanel
} }
/** /**
* Add the result program's listing model as a listener to the result program * Add the result program's listing model as a listener to the result program for domain object
* for domain object events. * events.
*/ */
public void addDomainObjectListener() { public void addDomainObjectListener() {
DomainObjectListener listingModel = (DomainObjectListener) multiModel.getModel(RESULT); DomainObjectListener listingModel = (DomainObjectListener) multiModel.getModel(RESULT);
@ -392,8 +395,8 @@ public class ListingMergePanel extends JPanel
} }
/** /**
* Remove the result program's listing model as a listener to the result program * Remove the result program's listing model as a listener to the result program for domain
* for domain object events. * object events.
*/ */
public void removeDomainObjectListener() { public void removeDomainObjectListener() {
DomainObjectListener listingModel = (DomainObjectListener) multiModel.getModel(RESULT); DomainObjectListener listingModel = (DomainObjectListener) multiModel.getModel(RESULT);

View file

@ -41,6 +41,7 @@ public class ListingMergePanelPlugin extends Plugin implements ProgramaticUseOnl
/** /**
* Constructor * Constructor
*
* @param tool merge tool * @param tool merge tool
* @param mergePanel merge panel * @param mergePanel merge panel
*/ */
@ -91,9 +92,7 @@ public class ListingMergePanelPlugin extends Plugin implements ProgramaticUseOnl
@Override @Override
public void processEvent(PluginEvent event) { public void processEvent(PluginEvent event) {
if (event instanceof ProgramLocationPluginEvent evt) {
if (event instanceof ProgramLocationPluginEvent) {
ProgramLocationPluginEvent evt = (ProgramLocationPluginEvent) event;
ProgramLocation location = evt.getLocation(); ProgramLocation location = evt.getLocation();
ListingMergePanel mergePanel = (ListingMergePanel) provider.getComponent(); ListingMergePanel mergePanel = (ListingMergePanel) provider.getComponent();
mergePanel.goTo(location, true); mergePanel.goTo(location, true);

View file

@ -39,7 +39,6 @@ public interface Navigatable {
* Commands this navigatable to goto (display) the given program and location * Commands this navigatable to goto (display) the given program and location
* *
* @param program the program * @param program the program
*
* @param location the location in that program to display * @param location the location in that program to display
* @return true if the goto was successful * @return true if the goto was successful
*/ */
@ -81,8 +80,9 @@ public interface Navigatable {
public Icon getNavigatableIcon(); public Icon getNavigatableIcon();
/** /**
* Returns true if this Navigatable is "connected". Navigatables are connected if they produce * Returns true if this Navigatable is "connected".
* and consume location and selection events. * <p>
* Navigatables are connected if they produce and consume location and selection events.
* *
* @return true if this Navigatable is "connected" * @return true if this Navigatable is "connected"
*/ */
@ -199,9 +199,11 @@ public interface Navigatable {
Program program); Program program);
/** /**
* Returns a source for providing byte values of the program associated with this * Returns a source for providing byte values of the program associated with this navigatable.
* navigatable. For a static program, this is just a wrapper for a program's memory. But * <p>
* dynamic programs require special handling for reading bytes. * For a static program, this is just a wrapper for a program's memory. But dynamic programs
* require special handling for reading bytes.
*
* @return a source of bytes for the navigatable's program * @return a source of bytes for the navigatable's program
*/ */
public default AddressableByteSource getByteSource() { public default AddressableByteSource getByteSource() {

View file

@ -296,11 +296,10 @@ public abstract class AbstractPatchAction extends DockingAction {
ListingActionContext lac = (ListingActionContext) context; ListingActionContext lac = (ListingActionContext) context;
ComponentProvider provider = lac.getComponentProvider(); ComponentProvider provider = lac.getComponentProvider();
if (!(provider instanceof CodeViewerProvider)) { if (!(provider instanceof CodeViewerProvider codeViewer)) {
return false; return false;
} }
CodeViewerProvider codeViewer = (CodeViewerProvider) provider;
if (codeViewer.isReadOnly()) { if (codeViewer.isReadOnly()) {
return false; return false;
} }

View file

@ -767,7 +767,6 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
@Override @Override
public boolean goTo(ProgramLocation location, boolean centerOnScreen) { public boolean goTo(ProgramLocation location, boolean centerOnScreen) {
return Swing return Swing
.runNow(() -> connectedProvider.getListingPanel().goTo(location, centerOnScreen)); .runNow(() -> connectedProvider.getListingPanel().goTo(location, centerOnScreen));
} }

View file

@ -33,7 +33,8 @@ import ghidra.framework.model.DomainFile;
import ghidra.framework.options.SaveState; import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.*; import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus; import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.address.*; import ghidra.program.model.address.AddressSet;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection; import ghidra.program.util.ProgramSelection;
@ -142,9 +143,7 @@ public class CodeBrowserPlugin extends AbstractCodeBrowserPlugin<CodeViewerProvi
updateHighlightProvider(); updateHighlightProvider();
updateBackgroundColorModel(); updateBackgroundColorModel();
setHighlight(new FieldSelection()); setHighlight(new FieldSelection());
AddressFactory currentAddressFactory = setSelection(new ProgramSelection());
(currentProgram != null) ? currentProgram.getAddressFactory() : null;
setSelection(new ProgramSelection(currentAddressFactory));
} }
else if (event instanceof ProgramLocationPluginEvent) { else if (event instanceof ProgramLocationPluginEvent) {
ProgramLocationPluginEvent evt = (ProgramLocationPluginEvent) event; ProgramLocationPluginEvent evt = (ProgramLocationPluginEvent) event;

View file

@ -21,6 +21,7 @@ import docking.action.builder.ActionBuilder;
import docking.tool.ToolConstants; import docking.tool.ToolConstants;
import generic.theme.GIcon; import generic.theme.GIcon;
import ghidra.app.CorePluginPackage; import ghidra.app.CorePluginPackage;
import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.codebrowser.SelectEndpointsAction.RangeEndpoint; import ghidra.app.plugin.core.codebrowser.SelectEndpointsAction.RangeEndpoint;
import ghidra.app.plugin.core.table.TableComponentProvider; import ghidra.app.plugin.core.table.TableComponentProvider;
@ -81,7 +82,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
.menuGroup(SELECT_GROUP, "a") .menuGroup(SELECT_GROUP, "a")
.keyBinding("ctrl A") .keyBinding("ctrl A")
.helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select All")) .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select All"))
.withContext(CodeViewerActionContext.class, true) .withContext(ListingActionContext.class, true)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES) .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
.onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectAll()) .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectAll())
.buildAndInstall(tool); .buildAndInstall(tool);
@ -90,7 +91,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
.menuPath(ToolConstants.MENU_SELECTION, "&Clear Selection") .menuPath(ToolConstants.MENU_SELECTION, "&Clear Selection")
.menuGroup(SELECT_GROUP, "b") .menuGroup(SELECT_GROUP, "b")
.helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection")) .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection"))
.withContext(CodeViewerActionContext.class, true) .withContext(ListingActionContext.class, true)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES) .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
.enabledWhen(c -> c.hasSelection()) .enabledWhen(c -> c.hasSelection())
.onAction(c -> ((CodeViewerProvider) c.getComponentProvider()) .onAction(c -> ((CodeViewerProvider) c.getComponentProvider())
@ -101,7 +102,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
.menuPath(ToolConstants.MENU_SELECTION, "&Complement") .menuPath(ToolConstants.MENU_SELECTION, "&Complement")
.menuGroup(SELECT_GROUP, "c") .menuGroup(SELECT_GROUP, "c")
.helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select Complement")) .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select Complement"))
.withContext(CodeViewerActionContext.class, true) .withContext(ListingActionContext.class, true)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES) .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
.onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectComplement()) .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectComplement())
.buildAndInstall(tool); .buildAndInstall(tool);
@ -112,7 +113,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
.menuPath(ToolConstants.MENU_SELECTION, "Create Table From Selection") .menuPath(ToolConstants.MENU_SELECTION, "Create Table From Selection")
.menuGroup("SelectUtils") .menuGroup("SelectUtils")
.helpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "Selection_Tables")) .helpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "Selection_Tables"))
.withContext(CodeViewerActionContext.class, true) .withContext(ListingActionContext.class, true)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES) .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
.onAction(c -> createTable((CodeViewerProvider) c.getComponentProvider())) .onAction(c -> createTable((CodeViewerProvider) c.getComponentProvider()))
.buildAndInstall(tool); .buildAndInstall(tool);
@ -121,7 +122,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
.menuPath(ToolConstants.MENU_SELECTION, CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME) .menuPath(ToolConstants.MENU_SELECTION, CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME)
.menuGroup("SelectUtils") .menuGroup("SelectUtils")
.helpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "Selection_Tables")) .helpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "Selection_Tables"))
.withContext(CodeViewerActionContext.class, true) .withContext(ListingActionContext.class, true)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES) .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
.onAction( .onAction(
c -> createAddressRangeTable((CodeViewerProvider) c.getComponentProvider())) c -> createAddressRangeTable((CodeViewerProvider) c.getComponentProvider()))
@ -150,7 +151,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
String title = "Selected Ranges in " + program.getName(); String title = "Selected Ranges in " + program.getName();
TableComponentProvider<AddressRangeInfo> tableProvider = TableComponentProvider<AddressRangeInfo> tableProvider =
tableService.showTableWithMarkers(title, "Address Ranges", model, tableService.showTableWithMarkers(title, "Address Ranges", model,
SearchConstants.SEARCH_HIGHLIGHT_COLOR, markerIcon, title, null); SearchConstants.SEARCH_HIGHLIGHT_COLOR, markerIcon, title, componentProvider);
tableProvider.installRemoveItemsAction(); tableProvider.installRemoveItemsAction();
SelectEndpointsAction selectMin = SelectEndpointsAction selectMin =
@ -186,7 +187,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
Icon markerIcon = new GIcon("icon.plugin.codebrowser.cursor.marker"); Icon markerIcon = new GIcon("icon.plugin.codebrowser.cursor.marker");
TableComponentProvider<Address> tableProvider = TableComponentProvider<Address> tableProvider =
tableService.showTableWithMarkers(title + " " + model.getName(), "Selections", model, tableService.showTableWithMarkers(title + " " + model.getName(), "Selections", model,
SearchConstants.SEARCH_HIGHLIGHT_COLOR, markerIcon, title, null); SearchConstants.SEARCH_HIGHLIGHT_COLOR, markerIcon, title, componentProvider);
tableProvider.installRemoveItemsAction(); tableProvider.installRemoveItemsAction();
} }

View file

@ -16,11 +16,9 @@
package ghidra.app.plugin.core.codebrowser; package ghidra.app.plugin.core.codebrowser;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.NavigatableRangeActionContext;
import ghidra.program.util.ProgramLocation; import ghidra.program.util.ProgramLocation;
public class CodeViewerActionContext extends ListingActionContext implements public class CodeViewerActionContext extends ListingActionContext {
NavigatableRangeActionContext {
public CodeViewerActionContext(CodeViewerProvider provider) { public CodeViewerActionContext(CodeViewerProvider provider) {
super(provider, provider); super(provider, provider);
@ -29,5 +27,4 @@ public class CodeViewerActionContext extends ListingActionContext implements
public CodeViewerActionContext(CodeViewerProvider provider, ProgramLocation location) { public CodeViewerActionContext(CodeViewerProvider provider, ProgramLocation location) {
super(provider, provider, location); super(provider, provider, location);
} }
} }

View file

@ -943,14 +943,14 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
public void selectAll() { public void selectAll() {
listingPanel.getFieldPanel().requestFocus(); listingPanel.getFieldPanel().requestFocus();
ProgramSelection sel = new ProgramSelection(program.getAddressFactory(), ProgramSelection sel = new ProgramSelection(
listingPanel.getAddressIndexMap().getOriginalAddressSet()); listingPanel.getAddressIndexMap().getOriginalAddressSet());
doSetSelection(sel); doSetSelection(sel);
} }
public void selectComplement() { public void selectComplement() {
AddressSet complement = listingPanel.selectComplement(); AddressSet complement = listingPanel.selectComplement();
ProgramSelection sel = new ProgramSelection(program.getAddressFactory(), complement); ProgramSelection sel = new ProgramSelection(complement);
doSetSelection(sel); doSetSelection(sel);
} }

View file

@ -30,9 +30,9 @@ import ghidra.program.util.ProgramSelection;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
/** /**
* Actions for creating a selection using two distinct steps. The first time the action * Actions for creating a selection using two distinct steps. The first time the action is invoked,
* is invoked, it records the current location as the start of a selection. The second time the * it records the current location as the start of a selection. The second time the action is
* action is invoked it creates a selection from the recorded location to the current location. * invoked it creates a selection from the recorded location to the current location.
*/ */
public class MarkAndSelectionAction extends ToggleDockingAction { public class MarkAndSelectionAction extends ToggleDockingAction {
private Navigatable markedNavigatable; private Navigatable markedNavigatable;

View file

@ -15,7 +15,7 @@
*/ */
package ghidra.app.plugin.core.gotoquery; package ghidra.app.plugin.core.gotoquery;
import static ghidra.framework.main.DataTreeDialogType.*; import static ghidra.framework.main.DataTreeDialogType.OPEN;
import java.util.Stack; import java.util.Stack;
@ -170,27 +170,27 @@ public class GoToHelper {
} }
/** /**
* GoTo external address linkage location (pointer or thunk) within the current program * GoTo external address linkage location (pointer or thunk) within the current program which is
* which is associated with the specified external location. * associated with the specified external location.
* <p> * <p>
* For those use cases which should not popup a window the popupAllowed * For those use cases which should not popup a window the popupAllowed option should be
* option should be <b>false</b>. * <b>false</b>.
* <p> * <p>
* This method will generally cause navigation to a linkage location associated with * This method will generally cause navigation to a linkage location associated with the
* the specified external location. A linkage location is either a pointer to the * specified external location. A linkage location is either a pointer to the external location
* external location (identified by reference) or a thunk to the external * (identified by reference) or a thunk to the external location, provided the thunk does not
* location, provided the thunk does not reference a linkage pointer. If more than one * reference a linkage pointer. If more than one linkage location exists and popupAllowed is
* linkage location exists and popupAllowed is <b>true</b>, a table will be displayed allowing * <b>true</b>, a table will be displayed allowing the user to navigate to any of the linkage
* the user to navigate to any of the linkage locations. If navigation is initiated from the * locations. If navigation is initiated from the only known linkage location, and popupAllowed
* only known linkage location, and popupAllowed is <b>true</b>, navigation to the external * is <b>true</b>, navigation to the external program will be attempted regardless of the
* program will be attempted regardless of the current * current {@link NavigationOptions#isGotoExternalProgramEnabled} setting.
* {@link NavigationOptions#isGotoExternalProgramEnabled} setting. *
* @param nav Navigatable * @param nav Navigatable
* @param externalLoc external location * @param externalLoc external location
* @param popupAllowed if true a table may be displayed when multiple linkage locations * @param popupAllowed if true a table may be displayed when multiple linkage locations exist,
* exist, otherwise navigation to the first linkage location will be performed * otherwise navigation to the first linkage location will be performed
* @return true if navigation was successful or a list of possible linkage locations * @return true if navigation was successful or a list of possible linkage locations was
* was displayed. * displayed.
*/ */
protected boolean goToExternalLinkage(Navigatable nav, ExternalLocation externalLoc, protected boolean goToExternalLinkage(Navigatable nav, ExternalLocation externalLoc,
boolean popupAllowed) { boolean popupAllowed) {
@ -237,27 +237,28 @@ public class GoToHelper {
/** /**
* Navigate to either the external program location or address linkage location. * Navigate to either the external program location or address linkage location.
* This method will only navigate to the
* external program associated with the specified location if either checkNavigationOption
* is false, or the navigation option is set to Show External Program, or
* the current location is the same as the single linkage location. See
* {@link #goToExternalLinkage(Navigatable, ExternalLocation, boolean)} method for
* external linkage navigation behavior.
* <p> * <p>
* If navigation to an external program will be performed, the associated program will * This method will only navigate to the external program associated with the specified location
* be identified and the location within that program found. Once this occurs, the * if either checkNavigationOption is false, or the navigation option is set to Show External
* external program will be opened within the current tool and navigation completed. If an * Program, or the current location is the same as the single linkage location. See
* external program association has not yet been established, the user will be prompted to make * {@link #goToExternalLinkage(Navigatable, ExternalLocation, boolean)} method for external
* an association if they choose before completing the navigation. * linkage navigation behavior.
* <p>
* If navigation to an external program will be performed, the associated program will be
* identified and the location within that program found. Once this occurs, the external program
* will be opened within the current tool and navigation completed. If an external program
* association has not yet been established, the user will be prompted to make an association if
* they choose before completing the navigation.
*
* @param nav Navigatable * @param nav Navigatable
* @param externalLocation external location * @param externalLocation external location
* @param checkNavigationOption if true the {@link NavigationOptions#isGotoExternalProgramEnabled} * @param checkNavigationOption if true the
* option will be used to determine if navigation to the external program will be * {@link NavigationOptions#isGotoExternalProgramEnabled} option will be used to
* attempted, or if navigation to the external linkage location within the current * determine if navigation to the external program will be attempted, or if
* program will be attempted. If false, only navigation to the external linkage will be * navigation to the external linkage location within the current program will be
* attempted. * attempted. If false, only navigation to the external linkage will be attempted.
* @return true if navigation to the external program was successful or navigation to a * @return true if navigation to the external program was successful or navigation to a linkage
* linkage location was performed. * location was performed.
*/ */
public boolean goToExternalLocation(Navigatable nav, ExternalLocation externalLocation, public boolean goToExternalLocation(Navigatable nav, ExternalLocation externalLocation,
boolean checkNavigationOption) { boolean checkNavigationOption) {

View file

@ -58,6 +58,7 @@ public final class GoToServicePlugin extends ProgramPlugin {
/** /**
* Creates a new instance of the <CODE>GoToServicePlugin</CODE> * Creates a new instance of the <CODE>GoToServicePlugin</CODE>
*
* @param tool the tool * @param tool the tool
*/ */
public GoToServicePlugin(PluginTool tool) { public GoToServicePlugin(PluginTool tool) {

View file

@ -66,6 +66,7 @@ public class SetHighlightPlugin extends Plugin {
/** /**
* Constructor * Constructor
*
* @param tool * @param tool
*/ */
public SetHighlightPlugin(PluginTool tool) { public SetHighlightPlugin(PluginTool tool) {

View file

@ -54,9 +54,9 @@ public abstract class AbstractTranslateAction extends DockingAction {
setPopupMenuData(dataListMenuData); setPopupMenuData(dataListMenuData);
return isEnabledForContext((DataLocationListContext) context); return isEnabledForContext((DataLocationListContext) context);
} }
else if (context instanceof CodeViewerActionContext) { else if (context instanceof CodeViewerActionContext cvac) {
setPopupMenuData(codeViewerMenuData); setPopupMenuData(codeViewerMenuData);
return isEnabledForContext((CodeViewerActionContext) context); return isEnabledForContext(cvac);
} }
return false; return false;
} }

View file

@ -26,29 +26,31 @@ import ghidra.util.Swing;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
/** /**
* The GoToService provides a general service for plugins to generate GoTo * The GoToService provides a general service for plugins to generate GoTo events. The provider of
* events. The provider of this service will take care of interfacing with * this service will take care of interfacing with any history service that may be available.
* any history service that may be available.
* <p> * <p>
* This class will execute all {@code goTo} calls on the Java Swing thread. This will happen in * This class will execute all {@code goTo} calls on the Java Swing thread. This will happen in a
* a blocking manner if the client calls from any other thread. This has the potential to lead * blocking manner if the client calls from any other thread. This has the potential to lead to
* to deadlocks if the client is using custom synchronization. Care must be taken to not be * deadlocks if the client is using custom synchronization. Care must be taken to not be holding any
* holding any lock that will cause the Swing thread to block when using this class from any other * lock that will cause the Swing thread to block when using this class from any other thread. To
* thread. To work around this issue, clients can always call this service from within a * work around this issue, clients can always call this service from within a
* {@link Swing#runLater(Runnable)} call, which will prevent any deadlock issues. * {@link Swing#runLater(Runnable)} call, which will prevent any deadlock issues.
*/ */
@ServiceInfo(defaultProvider = GoToServicePlugin.class, description = "Navigate to a program location") @ServiceInfo(
defaultProvider = GoToServicePlugin.class,
description = "Navigate to a program location")
public interface GoToService { public interface GoToService {
/** /**
* Characters that are allowed in words that the GoToService can use. These * Characters that are allowed in words that the GoToService can use. These typically represent
* typically represent library name delimiters. * library name delimiters.
*/ */
public static final char[] VALID_GOTO_CHARS = new char[] { '.', ':', '*' }; public static final char[] VALID_GOTO_CHARS = new char[] { '.', ':', '*' };
/** /**
* Generates a GoTo event and handles any history state that needs to be saved. This method * Generates a GoTo event and handles any history state that needs to be saved.
* will attempt to find the program that contains the given ProgramLocation. * <p>
* This method will attempt to find the program that contains the given ProgramLocation.
* *
* @param loc location to go to * @param loc location to go to
* @return true if the go to was successful * @return true if the go to was successful
@ -57,11 +59,12 @@ public interface GoToService {
public boolean goTo(ProgramLocation loc); public boolean goTo(ProgramLocation loc);
/** /**
* Generates a GoTo event and handles any history state that needs to be saved. This * Generates a GoTo event and handles any history state that needs to be saved.
* overloaded version of {@link #goTo(Address)} uses the given program as the program within * <p>
* which to perform the GoTo. If the given program does not contain the given address, then * This overloaded version of {@link #goTo(Address)} uses the given program as the program
* the GoTo will not be performed and false will be returned. Passing <code>null</code> as the * within which to perform the GoTo. If the given program does not contain the given address,
* <code>program</code> parameter will cause this method to attempt to find a program that * then the GoTo will not be performed and false will be returned. Passing <code>null</code> as
* the <code>program</code> parameter will cause this method to attempt to find a program that
* contains the given ProgramLocation. * contains the given ProgramLocation.
* *
* @param loc location to go to * @param loc location to go to
@ -82,8 +85,10 @@ public interface GoToService {
public boolean goTo(Navigatable navigatable, ProgramLocation loc, Program program); public boolean goTo(Navigatable navigatable, ProgramLocation loc, Program program);
/** /**
* Generates a GoTo event to the given address. The refAddress is used to determine if * Generates a GoTo event to the given address.
* there is a specific symbol reference from that reference. * <p>
* The refAddress is used to determine if there is a specific symbol reference from that
* reference.
* *
* @param navigatable the destination navigatable * @param navigatable the destination navigatable
* @param program program * @param program program
@ -95,8 +100,10 @@ public interface GoToService {
Address refAddress); Address refAddress);
/** /**
* Generates a GoTo event to the given address. The fromAddress is used to determine if * Generates a GoTo event to the given address.
* there is a specific symbol reference from the current address. * <p>
* The fromAddress is used to determine if there is a specific symbol reference from the current
* address.
* *
* @param fromAddress the current address * @param fromAddress the current address
* @param address the address to goto * @param address the address to goto
@ -115,6 +122,7 @@ public interface GoToService {
/** /**
* Generates a GoTo event to the gotoAddress. * Generates a GoTo event to the gotoAddress.
*
* @param goToAddress the address to goto * @param goToAddress the address to goto
* @return true if the go to was successful * @return true if the go to was successful
* @see #goTo(Address, Program) * @see #goTo(Address, Program)
@ -122,12 +130,13 @@ public interface GoToService {
public boolean goTo(Address goToAddress); public boolean goTo(Address goToAddress);
/** /**
* Generates a GoTo event to the gotoAddress. This overloaded version of * Generates a GoTo event to the gotoAddress.
* {@link #goTo(Address)} uses the given program as the program within which to perform the * <p>
* GoTo. If the given program does not contain the given address, then the GoTo will not be * This overloaded version of {@link #goTo(Address)} uses the given program as the program
* performed and false will be returned. Passing <code>null</code> as the <code>program</code> * within which to perform the GoTo. If the given program does not contain the given address,
* parameter will cause this method to attempt to find a program that contains the given * then the GoTo will not be performed and false will be returned. Passing <code>null</code> as
* ProgramLocation. * the <code>program</code> parameter will cause this method to attempt to find a program that
* contains the given ProgramLocation.
* *
* @param goToAddress the address to goto * @param goToAddress the address to goto
* @param program the program within which to perform the GoTo * @param program the program within which to perform the GoTo
@ -137,14 +146,15 @@ public interface GoToService {
public boolean goTo(Address goToAddress, Program program); public boolean goTo(Address goToAddress, Program program);
/** /**
* Navigate to either the external program location or address linkage location. Specific * Navigate to either the external program location or address linkage location.
* behavior may vary based upon implementation. * <p>
* Specific behavior may vary based upon implementation.
* *
* @param externalLoc external location * @param externalLoc external location
* @param checkNavigationOption if true the service navigation option will be used to determine * @param checkNavigationOption if true the service navigation option will be used to determine
* if navigation to the external program will be attempted, or if navigation to the * if navigation to the external program will be attempted, or if navigation to the
* external linkage location within the current program will be attempted. If false, the * external linkage location within the current program will be attempted. If false,
* implementations default behavior will be performed. * the implementations default behavior will be performed.
* @return true if either navigation to the external program or to a linkage location was * @return true if either navigation to the external program or to a linkage location was
* completed successfully. * completed successfully.
*/ */
@ -152,15 +162,16 @@ public interface GoToService {
boolean checkNavigationOption); boolean checkNavigationOption);
/** /**
* Navigate to either the external program location or address linkage location. Specific * Navigate to either the external program location or address linkage location.
* behavior may vary based upon implementation. * <p>
* Specific behavior may vary based upon implementation.
* *
* @param navigatable Navigatable * @param navigatable Navigatable
* @param externalLoc external location * @param externalLoc external location
* @param checkNavigationOption if true the service navigation option will be used to determine * @param checkNavigationOption if true the service navigation option will be used to determine
* if navigation to the external program will be attempted, or if navigation to the * if navigation to the external program will be attempted, or if navigation to the
* external linkage location within the current program will be attempted. If false, the * external linkage location within the current program will be attempted. If false,
* implementations default behavior will be performed. * the implementations default behavior will be performed.
* @return true if either navigation to the external program or to a linkage location was * @return true if either navigation to the external program or to a linkage location was
* completed successfully. * completed successfully.
*/ */
@ -170,9 +181,9 @@ public interface GoToService {
/** /**
* Generates a GoTo event for the given query. * Generates a GoTo event for the given query.
* <p> * <p>
* If the query results in more than one location, a list of locations will be displayed. * If the query results in more than one location, a list of locations will be displayed. If the
* If the query results in only one location, then a goto event will be fired(except for a * query results in only one location, then a goto event will be fired(except for a wildcard
* wildcard query in which case a list will still be displayed. * query in which case a list will still be displayed.
* <p> * <p>
* The listener will be notified after query and will indicate the query status. * The listener will be notified after query and will indicate the query status.
* *
@ -188,9 +199,9 @@ public interface GoToService {
/** /**
* Generates a GoTo event for the given query. * Generates a GoTo event for the given query.
* <p> * <p>
* If the query results in more than one location, a list of locations will be displayed. * If the query results in more than one location, a list of locations will be displayed. If the
* If the query results in only one location, then a goto event will be fired(except for a * query results in only one location, then a goto event will be fired(except for a wildcard
* wildcard query in which case a list will still be displayed. * query in which case a list will still be displayed.
* <p> * <p>
* The listener will be notified after query and will indicate the query status. * The listener will be notified after query and will indicate the query status.
* *
@ -205,8 +216,10 @@ public interface GoToService {
GoToServiceListener listener, TaskMonitor monitor); GoToServiceListener listener, TaskMonitor monitor);
/** /**
* Returns the default navigatable that is the destination for GoTo events. This navigatable * Returns the default navigatable that is the destination for GoTo events.
* will not be null. * <p>
* This navigatable will not be null.
*
* @return the navigatable * @return the navigatable
*/ */
public Navigatable getDefaultNavigatable(); public Navigatable getDefaultNavigatable();

View file

@ -106,7 +106,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
private String currentTextSelection; private String currentTextSelection;
/** /**
* Constructs a new ListingPanel using the given FormatManager and ServiceProvider. * Constructs a new ListingPanel using the given FormatManager
* *
* @param manager the FormatManager to use. * @param manager the FormatManager to use.
*/ */
@ -152,10 +152,10 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Constructs a new ListingPanel with the given FormatManager and ListingLayoutModel * Constructs a new ListingPanel with the given FormatManager and ListingModel
* *
* @param mgr the FormatManager to use * @param mgr the FormatManager to use
* @param model the ListingLayoutModel to use. * @param model the ListingModel to use.
*/ */
public ListingPanel(FormatManager mgr, ListingModel model) { public ListingPanel(FormatManager mgr, ListingModel model) {
this(mgr); this(mgr);
@ -173,6 +173,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* A width for new windows that shows a reasonable amount of the Listing * A width for new windows that shows a reasonable amount of the Listing
*
* @return the width * @return the width
*/ */
protected int getNewWindowDefaultWidth() { protected int getNewWindowDefaultWidth() {
@ -203,7 +204,9 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Sets the ProgramLocationListener. Only one listener is supported * Sets the ProgramLocationListener.
* <p>
* Only one listener is supported
* *
* @param listener the ProgramLocationListener to use. * @param listener the ProgramLocationListener to use.
*/ */
@ -212,7 +215,9 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Sets the ProgramSelectionListener. Only one listener is supported * Sets the ProgramSelectionListener.
* <p>
* Only one listener is supported
* *
* @param listener the ProgramSelectionListener to use. * @param listener the ProgramSelectionListener to use.
*/ */
@ -221,8 +226,9 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Sets the ProgramSelectionListener for selection changes while dragging. Only one listener is * Sets the ProgramSelectionListener for selection changes while dragging.
* supported * <p>
* Only one listener is supported
* *
* @param listener the ProgramSelectionListener to use. * @param listener the ProgramSelectionListener to use.
*/ */
@ -235,7 +241,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Sets the ListingLayoutModel to use. * Sets the ListingModel to use.
* *
* @param newModel the model to use. * @param newModel the model to use.
*/ */
@ -249,6 +255,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the current ListingModel used by this panel. * Returns the current ListingModel used by this panel.
*
* @return the model * @return the model
*/ */
public ListingModel getListingModel() { public ListingModel getListingModel() {
@ -285,6 +292,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns true if the field header component is showing. * Returns true if the field header component is showing.
*
* @return true if showing * @return true if showing
*/ */
public boolean isHeaderShowing() { public boolean isHeaderShowing() {
@ -493,8 +501,10 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Adds a {@link ListingHighlightProvider} to this listing. This highlight provider will be used with * Adds a {@link ListingHighlightProvider} to this listing.
* any other registered providers to paint all the highlights for this listing. * <p>
* This highlight provider will be used with any other registered providers to paint all the
* highlights for this listing.
* *
* @param highlightProvider The provider to add * @param highlightProvider The provider to add
*/ */
@ -504,6 +514,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the FieldPanel used by this ListingPanel. * Returns the FieldPanel used by this ListingPanel.
*
* @return the field panel * @return the field panel
*/ */
public FieldPanel getFieldPanel() { public FieldPanel getFieldPanel() {
@ -536,6 +547,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the divider location between the left margin areas and the main display. * Returns the divider location between the left margin areas and the main display.
*
* @return the location * @return the location
*/ */
public int getDividerLocation() { public int getDividerLocation() {
@ -604,8 +616,9 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Moves the cursor to the given program location. Also, repositions the scrollbar to show that * Moves the cursor to the given program location.
* location, if the location is not on the screen. * <p>
* Also, repositions the scrollbar to show that location, if the location is not on the screen.
* *
* @param loc the location to move to. * @param loc the location to move to.
* @param centerWhenNotVisible this variable only has an effect if the given location is not on * @param centerWhenNotVisible this variable only has an effect if the given location is not on
@ -615,7 +628,6 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
* @return true if successful * @return true if successful
*/ */
public boolean goTo(ProgramLocation loc, boolean centerWhenNotVisible) { public boolean goTo(ProgramLocation loc, boolean centerWhenNotVisible) {
Swing.assertSwingThread("goTo() must be called on the Swing thread"); Swing.assertSwingThread("goTo() must be called on the Swing thread");
final FieldLocation floc = getFieldLocation(loc); final FieldLocation floc = getFieldLocation(loc);
@ -640,6 +652,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
* *
* <p> * <p>
* If the given location is not displayed, this has no effect. * If the given location is not displayed, this has no effect.
*
* @param location the location * @param location the location
*/ */
public void scrollTo(ProgramLocation location) { public void scrollTo(ProgramLocation location) {
@ -652,6 +665,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Center the view of the listing around the given location. * Center the view of the listing around the given location.
*
* @param location the location * @param location the location
*/ */
public void center(ProgramLocation location) { public void center(ProgramLocation location) {
@ -866,6 +880,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Gets the view of this listing panel (meant to be used in conjunction with * Gets the view of this listing panel (meant to be used in conjunction with
* {@link #setView(AddressSetView)}. * {@link #setView(AddressSetView)}.
*
* @return the addresses * @return the addresses
*/ */
public AddressSetView getView() { public AddressSetView getView() {
@ -893,8 +908,10 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Sets the background color for the listing panel. This will set the background for the main * Sets the background color for the listing panel.
* listing display. * <p>
* This will set the background for the main listing display.
*
* @param c the color * @param c the color
*/ */
public void setTextBackgroundColor(Color c) { public void setTextBackgroundColor(Color c) {
@ -912,6 +929,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns true if this component has focus. * Returns true if this component has focus.
*
* @return true if this component has focus. * @return true if this component has focus.
*/ */
public boolean isActive() { public boolean isActive() {
@ -920,6 +938,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the current program location of the cursor. * Returns the current program location of the cursor.
*
* @return the location * @return the location
*/ */
public ProgramLocation getProgramLocation() { public ProgramLocation getProgramLocation() {
@ -933,6 +952,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Get a program location for the given point. * Get a program location for the given point.
*
* @param point the point * @param point the point
* @return program location, or null if point does not correspond to a program location * @return program location, or null if point does not correspond to a program location
*/ */
@ -947,6 +967,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Get the margin providers in this ListingPanel. * Get the margin providers in this ListingPanel.
*
* @return the providers * @return the providers
*/ */
public List<MarginProvider> getMarginProviders() { public List<MarginProvider> getMarginProviders() {
@ -955,6 +976,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Get the overview providers in this ListingPanel. * Get the overview providers in this ListingPanel.
*
* @return the providers * @return the providers
*/ */
public List<OverviewProvider> getOverviewProviders() { public List<OverviewProvider> getOverviewProviders() {
@ -963,6 +985,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns true if the mouse is at a location that can be dragged. * Returns true if the mouse is at a location that can be dragged.
*
* @return true if the mouse is at a location that can be dragged. * @return true if the mouse is at a location that can be dragged.
*/ */
public boolean isStartDragOk() { public boolean isStartDragOk() {
@ -980,7 +1003,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Sets the cursor to the given program location with a given trigger * Sets the cursor to the given program location with a given trigger
* * <p>
* This method should only be used in automated testing to programmatically simulate a user * This method should only be used in automated testing to programmatically simulate a user
* navigating within the listing panel. * navigating within the listing panel.
* *
@ -1013,6 +1036,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the AddressIndexMap currently used by this listing panel. * Returns the AddressIndexMap currently used by this listing panel.
*
* @return the map * @return the map
*/ */
public AddressIndexMap getAddressIndexMap() { public AddressIndexMap getAddressIndexMap() {
@ -1021,6 +1045,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the vertical scrollbar used by this panel. * Returns the vertical scrollbar used by this panel.
*
* @return the scroll bar * @return the scroll bar
*/ */
public JScrollBar getVerticalScrollBar() { public JScrollBar getVerticalScrollBar() {
@ -1029,6 +1054,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the FormatManager used by this listing panel. * Returns the FormatManager used by this listing panel.
*
* @return the format manager * @return the format manager
*/ */
public FormatManager getFormatManager() { public FormatManager getFormatManager() {
@ -1070,6 +1096,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Returns the current program selection. * Returns the current program selection.
*
* @return the selection * @return the selection
*/ */
public ProgramSelection getProgramSelection() { public ProgramSelection getProgramSelection() {
@ -1091,6 +1118,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
/** /**
* Sets the selection to the complement of the current selection in the listing view. * Sets the selection to the complement of the current selection in the listing view.
*
* @return the addresses * @return the addresses
*/ */
public AddressSet selectComplement() { public AddressSet selectComplement() {
@ -1196,8 +1224,9 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Returns the currently selected text. The value will only be non-null for selections within a * Returns the currently selected text.
* single field. * <p>
* The value will only be non-null for selections within a single field.
* *
* @return the selected text or null * @return the selected text or null
*/ */
@ -1210,8 +1239,9 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
} }
/** /**
* Sets listing panel to never show scroll bars. This is useful when you want this listing's * Sets listing panel to never show scroll bars.
* parent to always be as big as this listing. * <p>
* This is useful when you want this listing's parent to always be as big as this listing.
*/ */
public void setNeverSroll() { public void setNeverSroll() {
scroller.setNeverScroll(true); scroller.setNeverScroll(true);

View file

@ -39,6 +39,7 @@ class ListingDisplayGoToService implements GoToService {
/** /**
* Constructs a goTo service for a dual listing panel. * Constructs a goTo service for a dual listing panel.
*
* @param listingPanel the listing panel to be navigated to * @param listingPanel the listing panel to be navigated to
*/ */
ListingDisplayGoToService(ListingPanel listingPanel) { ListingDisplayGoToService(ListingPanel listingPanel) {
@ -154,9 +155,9 @@ class ListingDisplayGoToService implements GoToService {
} }
/** /**
* Checks the address to make sure the listing won't navigate outside the addresses * Checks the address to make sure the listing won't navigate outside the addresses it currently
* it currently has loaded. If it is not a valid address it will set a status message * has loaded. If it is not a valid address it will set a status message on the dual listing.
* on the dual listing. *
* @param addr the address to check * @param addr the address to check
* @return true if the address is valid for navigation. * @return true if the address is valid for navigation.
*/ */
@ -167,8 +168,8 @@ class ListingDisplayGoToService implements GoToService {
AddressIndexMap map = listingPanel.getAddressIndexMap(); AddressIndexMap map = listingPanel.getAddressIndexMap();
AddressSetView addresses = map.getOriginalAddressSet(); AddressSetView addresses = map.getOriginalAddressSet();
if (!addresses.contains(addr)) { if (!addresses.contains(addr)) {
DockingWindowManager.getActiveInstance().setStatusText( DockingWindowManager.getActiveInstance().setStatusText("""
"\"" + addr.toString() + "\" is outside the current listing's view."); "%s" is outside the current listing's view""".formatted(addr));
return false; return false;
} }
return true; return true;

View file

@ -37,9 +37,9 @@ class ListingDisplayNavigator implements Navigatable {
/** /**
* Constructor for a dual listing navigator. * Constructor for a dual listing navigator.
*
* @param listingPanel the dual listing whose left or right listing panel is to be controlled. * @param listingPanel the dual listing whose left or right listing panel is to be controlled.
* @param goToService which side LEFT or RIGHT * @param goToService which side LEFT or RIGHT. false means it's for the right side listing.
* false means it's for the right side listing.
*/ */
ListingDisplayNavigator(ListingPanel listingPanel, GoToService goToService) { ListingDisplayNavigator(ListingPanel listingPanel, GoToService goToService) {

View file

@ -35,12 +35,11 @@ import ghidra.program.util.ProgramSelection;
import ghidra.util.Msg; import ghidra.util.Msg;
/** /**
* Navigation is only supported if the underlying table model * Navigation is only supported if the underlying table model implements {@link ProgramTableModel}
* implements <code>ProgramTableModel</code> and the <code>setGoToService()</code> method * and the <code>setGoToService()</code> method has been called with a valid reference. When both of
* has been called with a valid reference. When both of these conditions are met, then the * these conditions are met, then the table will navigate on a user's double-click or on an
* table will navigate on a user's double-click or on an <code>Enter</code> key press. Also, if * <code>Enter</code> key press. Also, if selection navigation is enabled, then this table will
* selection navigation is enabled, then this table will navigate <b>any time the selection of * navigate <b>any time the selection of the table changes</b>. To prevent this feature call
* the table changes</b>. To prevent this feature call
* {@link #setNavigateOnSelectionEnabled(boolean)} with a value of false. * {@link #setNavigateOnSelectionEnabled(boolean)} with a value of false.
*/ */
public class GhidraTable extends GTable { public class GhidraTable extends GTable {
@ -61,6 +60,7 @@ public class GhidraTable extends GTable {
/** /**
* Installs the default {@link TableCellRenderer}s for known Ghidra table cell data classes. * Installs the default {@link TableCellRenderer}s for known Ghidra table cell data classes.
* <p>
* Subclasses can override this method to add additional types or to change the default * Subclasses can override this method to add additional types or to change the default
* associations. * associations.
*/ */
@ -79,6 +79,7 @@ public class GhidraTable extends GTable {
/** /**
* Sets the GoTo service to use when navigation is enabled on this table. * Sets the GoTo service to use when navigation is enabled on this table.
*
* @param goToService the GoTo service * @param goToService the GoTo service
* @param nav the navigable * @param nav the navigable
* @deprecated use {@link #installNavigation(ServiceProvider)} or * @deprecated use {@link #installNavigation(ServiceProvider)} or
@ -90,9 +91,10 @@ public class GhidraTable extends GTable {
} }
/** /**
* Sets the service provider to use when navigation is enabled on this table. The service * Sets the service provider to use when navigation is enabled on this table.
* provider will be used to retrieve the {@link GoToService}, as needed after the system has * <p>
* been initialized. If you do not have a {@link Navigatable} preferences, then call * The service provider will be used to retrieve the {@link GoToService}, as needed after the
* system has been initialized. If you do not have a {@link Navigatable} preferences, then call
* {@link #installNavigation(ServiceProvider)} instead. * {@link #installNavigation(ServiceProvider)} instead.
* *
* @param sp the service provider * @param sp the service provider
@ -112,9 +114,10 @@ public class GhidraTable extends GTable {
} }
/** /**
* Sets the service provider to use when navigation is enabled on this table. The service * Sets the service provider to use when navigation is enabled on this table.
* provider will be used to retrieve the {@link GoToService}, as needed after the system has * <p>
* been initialized. * The service provider will be used to retrieve the {@link GoToService}, as needed after the
* system has been initialized.
* *
* @param sp the service provider * @param sp the service provider
*/ */
@ -164,8 +167,8 @@ public class GhidraTable extends GTable {
} }
/** /**
* Removes any installed navigation components, such as listeners, a navigatable and the * Removes any installed navigation components, such as listeners, a navigatable and the service
* service provider. * provider.
*/ */
public void removeNavigation() { public void removeNavigation() {
removeKeyListener(navigationKeyListener); removeKeyListener(navigationKeyListener);
@ -178,11 +181,13 @@ public class GhidraTable extends GTable {
/** /**
* Returns the program selection equivalent to the rows currently selected in the table. * Returns the program selection equivalent to the rows currently selected in the table.
* <p>
* This method is only valid when the underlying table model implements * This method is only valid when the underlying table model implements
* {@link ProgramTableModel}. * {@link ProgramTableModel}.
* <P> * <P>
* Returns null if no rows are selected or * Returns null if no rows are selected or the underlying model does not implement
* the underlying model does not implement <code>ProgramTableModel</code>. * <code>ProgramTableModel</code>.
*
* @return the program selection or null. * @return the program selection or null.
*/ */
public ProgramSelection getProgramSelection() { public ProgramSelection getProgramSelection() {
@ -200,8 +205,8 @@ public class GhidraTable extends GTable {
} }
/** /**
* Returns the program being used by this table; null if the underlying model does not * Returns the program being used by this table; null if the underlying model does not implement
* implement {@link ProgramTableModel} * {@link ProgramTableModel}
* *
* @return the table's program * @return the table's program
*/ */
@ -222,11 +227,11 @@ public class GhidraTable extends GTable {
} }
/** /**
* Navigate to the program location denoted by the given row and column
* <p>
* Does nothing if no {@link GoToService} has been installed from * Does nothing if no {@link GoToService} has been installed from
* {@link #installNavigation(GoToService, Navigatable)}. Also, this method will do * {@link #installNavigation(GoToService, Navigatable)}. Also, this method will do nothing if
* nothing if this table's <code>TableModel</code> is not an instance of {@link ProgramTableModel}. * this table's <code>TableModel</code> is not an instance of {@link ProgramTableModel}.
* Otherwise, this method will attempt to go to the program location denoted by the
* given row and column.
* *
* @param row the row * @param row the row
* @param column the column * @param column the column
@ -269,12 +274,13 @@ public class GhidraTable extends GTable {
} }
/** /**
* Does nothing if no {@link GoToService} has been installed from * Navigate to the program location denoted by the given row and column
* {@link #installNavigation(GoToService, Navigatable)}. Otherwise, this method will attempt
* to go to the program location denoted by the given row and column.
* <p> * <p>
* This method differs from {@link #navigate(int, int)} in that this method will not * Does nothing if no {@link GoToService} has been installed from
* navigate if {@link #navigateOnSelection} is <code>false</code>. * {@link #installNavigation(GoToService, Navigatable)}.
* <p>
* This method differs from {@link #navigate(int, int)} in that this method will not navigate if
* {@link #navigateOnSelection} is <code>false</code>.
*/ */
protected void navigateOnCurrentSelection(int row, int column) { protected void navigateOnCurrentSelection(int row, int column) {
if (!navigateOnSelection) { if (!navigateOnSelection) {
@ -289,8 +295,9 @@ public class GhidraTable extends GTable {
} }
/** /**
* Allows the user to enable and disable the table's feature that triggers navigation on * Allows the user to enable and disable the table's feature that triggers navigation on certain
* certain selection events, like mouse clicking and pressing the 'Enter' key. * selection events, like mouse clicking and pressing the 'Enter' key.
*
* @param enabled true enables the navigation on selection feature. * @param enabled true enables the navigation on selection feature.
*/ */
public void setNavigateOnSelectionEnabled(boolean enabled) { public void setNavigateOnSelectionEnabled(boolean enabled) {
@ -328,6 +335,7 @@ public class GhidraTable extends GTable {
/** /**
* Selects the given row and performs a goto, if applicable. * Selects the given row and performs a goto, if applicable.
*
* @param row The row to select * @param row The row to select
*/ */
@Override @Override

View file

@ -35,9 +35,9 @@ import resources.Icons;
/** /**
* An action to make a program selection based on the given table's selection. For the context to * An action to make a program selection based on the given table's selection. For the context to
* work, the provider using this action must create an {@link ActionContext} that returns a * work, the provider using this action must create an {@link ActionContext} that returns a context
* context object that is the table passed to this action's constructor; otherwise, this action * object that is the table passed to this action's constructor; otherwise, this action will not be
* will not be enabled correctly. * enabled correctly.
*/ */
public class MakeProgramSelectionAction extends DockingAction { public class MakeProgramSelectionAction extends DockingAction {
@ -48,10 +48,13 @@ public class MakeProgramSelectionAction extends DockingAction {
private GhidraTable table; private GhidraTable table;
/** /**
* Special constructor for clients that do not have a plugin. Clients using this * Special constructor for clients that do not have a plugin.
* constructor must override {@link #makeProgramSelection(ProgramSelection, ActionContext)}. * <p>
* Clients using this constructor must override
* {@link #makeProgramSelection(ProgramSelection, ActionContext)}.
* *
* <p>Update: the preferred constructor for clients without a plugin is * <p>
* Update: the preferred constructor for clients without a plugin is
* {@link #MakeProgramSelectionAction(Navigatable, String, GhidraTable)}. * {@link #MakeProgramSelectionAction(Navigatable, String, GhidraTable)}.
* *
* @param owner the action's owner * @param owner the action's owner
@ -66,8 +69,10 @@ public class MakeProgramSelectionAction extends DockingAction {
} }
/** /**
* Special constructor for clients that do not have a plugin. Clients using this * Special constructor for clients that do not have a plugin.
* constructor must override {@link #makeProgramSelection(ProgramSelection, ActionContext)}. * <p>
* Clients using this constructor must override
* {@link #makeProgramSelection(ProgramSelection, ActionContext)}.
* *
* @param navigatable the navigatable that will be used to make selections; may not be null * @param navigatable the navigatable that will be used to make selections; may not be null
* @param owner the action's owner * @param owner the action's owner
@ -78,8 +83,10 @@ public class MakeProgramSelectionAction extends DockingAction {
} }
/** /**
* Special constructor for clients that do not have a plugin. Clients using this * Special constructor for clients that do not have a plugin.
* constructor must override {@link #makeProgramSelection(ProgramSelection, ActionContext)}. * <p>
* Clients using this constructor must override
* {@link #makeProgramSelection(ProgramSelection, ActionContext)}.
* *
* @param navigatable the navigatable that will be used to make selections; may not be null * @param navigatable the navigatable that will be used to make selections; may not be null
* @param owner the action's owner * @param owner the action's owner
@ -95,8 +102,10 @@ public class MakeProgramSelectionAction extends DockingAction {
} }
/** /**
* This normal constructor for this action. The given plugin will be used along with the * The normal constructor for this action.
* given table to fire program selection events as the action is executed. * <p>
* The given plugin will be used along with the given table to fire program selection events as
* the action is executed.
* *
* @param plugin the plugin * @param plugin the plugin
* @param table the table * @param table the table

View file

@ -15,7 +15,8 @@
*/ */
package ghidra.app.plugin.core.codebrowser; package ghidra.app.plugin.core.codebrowser;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
@ -57,7 +58,6 @@ public class ExternalCodeBrowserNavigationTest extends AbstractCodeBrowserNaviga
GoToHelper spyGoToHelper = new GoToHelper(tool) { GoToHelper spyGoToHelper = new GoToHelper(tool) {
@Override @Override
public boolean goTo(final Navigatable navigatable, ProgramLocation loc, Program p) { public boolean goTo(final Navigatable navigatable, ProgramLocation loc, Program p) {
Msg.debug(this, "goTo() called with " + loc); Msg.debug(this, "goTo() called with " + loc);
// Track last navigation location // Track last navigation location

View file

@ -23,8 +23,8 @@ import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection; import ghidra.program.util.ProgramSelection;
/** /**
* A stub of the {@link Navigatable} interface. This can be used to supply a test navigatable * A stub of the {@link Navigatable} interface. This can be used to supply a test navigatable or to
* or to spy on system internals by overriding methods as needed. * spy on system internals by overriding methods as needed.
*/ */
public class TestDummyNavigatable implements Navigatable { public class TestDummyNavigatable implements Navigatable {
@ -148,7 +148,8 @@ public class TestDummyNavigatable implements Navigatable {
} }
@Override @Override
public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) { public void removeHighlightProvider(ListingHighlightProvider highlightProvider,
Program program) {
// stub // stub
} }
} }

View file

@ -23,8 +23,8 @@ import ghidra.program.util.ProgramLocation;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
/** /**
* A stub of the {@link GoToService} interface. This can be used to supply a test version * A stub of the {@link GoToService} interface. This can be used to supply a test version of the
* of the service or to spy on system internals by overriding methods as needed. * service or to spy on system internals by overriding methods as needed.
*/ */
public class TestDummyGoToService implements GoToService { public class TestDummyGoToService implements GoToService {

View file

@ -252,7 +252,6 @@ public class DecompilerProvider extends NavigatableComponentProviderAdapter
@Override @Override
public boolean goTo(Program gotoProgram, ProgramLocation location) { public boolean goTo(Program gotoProgram, ProgramLocation location) {
if (!isConnected()) { if (!isConnected()) {
if (program == null) { if (program == null) {
// Special Case: this 'disconnected' provider is waiting to be initialized // Special Case: this 'disconnected' provider is waiting to be initialized

View file

@ -15,7 +15,7 @@
*/ */
package ghidra.app.plugin.core.functiongraph; package ghidra.app.plugin.core.functiongraph;
import static ghidra.framework.model.DomainObjectEvent.*; import static ghidra.framework.model.DomainObjectEvent.RESTORED;
import static ghidra.program.util.ProgramEvent.*; import static ghidra.program.util.ProgramEvent.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -243,8 +243,9 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
} }
/** /**
* Gives to the clipboard of this provider the given string. This will prime the clipboard * Gives to the clipboard of this provider the given string.
* such that a copy action will copy the given string. * <p>
* This will prime the clipboard such that a copy action will copy the given string.
* *
* @param string the string to set * @param string the string to set
*/ */
@ -354,9 +355,11 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
} }
/** /**
* Called to signal to this provider that it should update its state due to a new function * Called to signal to this provider that it should update its state due to a new function being
* being graphed. The UI is updated by the controller without this provider's knowledge. * graphed.
* This call here is to signal that the provider needs to update its metadata. * <p>
* The UI is updated by the controller without this provider's knowledge. This call here is to
* signal that the provider needs to update its metadata.
*/ */
public void functionGraphDataChanged() { public void functionGraphDataChanged() {
updateTitle(); updateTitle();
@ -480,8 +483,8 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
} }
/** /**
* Called when for location changes that are <b>external</b> to the function graph (e.g., * Called when for location changes that are <b>external</b> to the function graph (e.g., when
* when the user clicks in Ghidra's Listing window) * the user clicks in Ghidra's Listing window)
* *
* @param newLocation the new location * @param newLocation the new location
*/ */
@ -533,8 +536,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
} }
/** /**
* Tells this provider to refresh, which means to rebuild the graph and relayout the * Tells this provider to refresh, which means to rebuild the graph and relayout the vertices.
* vertices.
*/ */
private void refresh(boolean keepPerspective) { private void refresh(boolean keepPerspective) {
FGData functionGraphData = controller.getFunctionGraphData(); FGData functionGraphData = controller.getFunctionGraphData();
@ -563,16 +565,16 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
} }
/** /**
* Rebuilds the graph and restores the zoom and location of the graph to the values prior * Rebuilds the graph and restores the zoom and location of the graph to the values prior to
* to rebuilding. * rebuilding.
*/ */
public void refreshAndKeepPerspective() { public void refreshAndKeepPerspective() {
refresh(true); refresh(true);
} }
/** /**
* Rebuilds the graph <b>and</b> will zoom the graph such that it fits on the screen and * Rebuilds the graph <b>and</b> will zoom the graph such that it fits on the screen and is
* is centered. * centered.
*/ */
public void refreshAndResetPerspective() { public void refreshAndResetPerspective() {
refresh(false); refresh(false);
@ -643,8 +645,8 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
} }
/** /**
* Returns true when something destructive has happened to the data upon which the graph * Returns true when something destructive has happened to the data upon which the graph has
* has created, like a memory block move. * created, like a memory block move.
*/ */
private boolean graphDataMissing() { private boolean graphDataMissing() {
FGData data = controller.getFunctionGraphData(); FGData data = controller.getFunctionGraphData();

View file

@ -26,8 +26,8 @@ import ghidra.program.util.ProgramLocation;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
/** /**
* A service that provides the ability to go to a particular address or location in the * A service that provides the ability to go to a particular address or location in the right-hand
* right-hand listing of the Diff. * listing of the Diff.
*/ */
public class DiffGoToService implements GoToService { public class DiffGoToService implements GoToService {
@ -36,10 +36,11 @@ public class DiffGoToService implements GoToService {
private GoToHelper helper; private GoToHelper helper;
/** /**
* Creates a service that provides the ability to go to a particular address or location * Creates a service that provides the ability to go to a particular address or location in the
* in the right-hand listing of the Diff. * right-hand listing of the Diff.
* @param goToService basic GoToService for the left-side listing that this will override *
* so it can go to addresses and locations in the right-side listing. * @param goToService basic GoToService for the left-side listing that this will override so it
* can go to addresses and locations in the right-side listing.
* @param diffPlugin the plugin which provides the Diff capability. * @param diffPlugin the plugin which provides the Diff capability.
*/ */
public DiffGoToService(GoToService goToService, ProgramDiffPlugin diffPlugin) { public DiffGoToService(GoToService goToService, ProgramDiffPlugin diffPlugin) {
@ -171,12 +172,13 @@ public class DiffGoToService implements GoToService {
} }
private void showProgramFailureStatus() { private void showProgramFailureStatus() {
diffPlugin.getTool().setStatusInfo( diffPlugin.getTool()
"Can't navigate from the Diff program to another program."); .setStatusInfo("Can't navigate from the Diff program to another program.");
} }
/** /**
* Go to the specified program location in the right hand Diff listing. * Go to the specified program location in the right hand Diff listing.
*
* @param loc go to this location * @param loc go to this location
* @return true if the listing went to the location. * @return true if the listing went to the location.
*/ */
@ -196,6 +198,7 @@ public class DiffGoToService implements GoToService {
/** /**
* Go to the specified address in the right hand Diff listing. * Go to the specified address in the right hand Diff listing.
*
* @param addr go to this address * @param addr go to this address
* @return true if the listing went to the address. * @return true if the listing went to the address.
*/ */
@ -210,12 +213,11 @@ public class DiffGoToService implements GoToService {
} }
/** /**
* Saving the first program's location (the left listing) in the navigation history. * Saving the first program's location (the left listing) in the navigation history. The second
* The second program's location (the right listing) isn't saved since the navigation is * program's location (the right listing) isn't saved since the navigation is relative to a
* relative to a program in the tool's main listing. Also, if the second program's * program in the tool's main listing. Also, if the second program's locations were saved in the
* locations were saved in the history, their program wouldn't be found and would cause * history, their program wouldn't be found and would cause errors when restarting the
* errors when restarting the application with the tool and primary program displayed, but * application with the tool and primary program displayed, but no Diff program.
* no Diff program.
*/ */
private void saveLocation() { private void saveLocation() {
Program firstProgram = diffPlugin.getFirstProgram(); Program firstProgram = diffPlugin.getFirstProgram();

View file

@ -27,9 +27,8 @@ import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet; import ghidra.util.datastruct.WeakSet;
/** /**
* This is a navigatable for use by the right-hand listing of the Diff. * This is a navigatable for use by the right-hand listing of the Diff. It should navigate within
* It should navigate within the Diff's listing, which would then reposition * the Diff's listing, which would then reposition the CodeViewer's listing.
* the CodeViewer's listing.
*/ */
class DiffNavigatable implements Navigatable { class DiffNavigatable implements Navigatable {
@ -40,8 +39,11 @@ class DiffNavigatable implements Navigatable {
WeakDataStructureFactory.createCopyOnWriteWeakSet(); WeakDataStructureFactory.createCopyOnWriteWeakSet();
/** /**
* The navigatable for the Diff. The CodeViewerService provides Diff with a listing, * The navigatable for the Diff.
* so where appropriate this navigatable will defer to the CodeViewerService navigatable. * <p>
* The CodeViewerService provides Diff with a listing, so where appropriate this navigatable
* will defer to the CodeViewerService navigatable.
*
* @param diffPlugin the plugin for the Diff which can be used to obtain needed info. * @param diffPlugin the plugin for the Diff which can be used to obtain needed info.
* @param navigatable navigatable that the CodeViewerService provides. * @param navigatable navigatable that the CodeViewerService provides.
*/ */
@ -179,7 +181,8 @@ class DiffNavigatable implements Navigatable {
} }
@Override @Override
public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) { public void removeHighlightProvider(ListingHighlightProvider highlightProvider,
Program program) {
// CodeViewerProvider handles the other listing (the Diff listing) highlights. // CodeViewerProvider handles the other listing (the Diff listing) highlights.
navigatable.removeHighlightProvider(highlightProvider, program); navigatable.removeHighlightProvider(highlightProvider, program);
} }

View file

@ -15,7 +15,8 @@
*/ */
package docking.widgets.fieldpanel; package docking.widgets.fieldpanel;
import static docking.widgets.EventTrigger.*; import static docking.widgets.EventTrigger.API_CALL;
import static docking.widgets.EventTrigger.INTERNAL_ONLY;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
@ -347,6 +348,7 @@ public class FieldPanel extends JPanel
/** /**
* Returns true if the given field location is rendered on the screen; false if scrolled * Returns true if the given field location is rendered on the screen; false if scrolled
* offscreen * offscreen
*
* @param location the location * @param location the location
* @return true if the location is on the screen * @return true if the location is on the screen
*/ */
@ -689,8 +691,9 @@ public class FieldPanel extends JPanel
} }
/** /**
* Returns the Field at the given x,y coordinates. Note the x,y must currently be visible on the * Returns the Field at the given x,y coordinates.
* screen or else this method will return null. * <p>
* Note the x,y must currently be visible on the screen or else this method will return null.
* *
* @param x the x mouse coordinate in the component. * @param x the x mouse coordinate in the component.
* @param y the y mouse coordinate in the component. * @param y the y mouse coordinate in the component.
@ -841,8 +844,9 @@ public class FieldPanel extends JPanel
} }
/** /**
* Sets the cursor on or off. When the cursor is turned off, there is no visible cursor * Sets the cursor on or off.
* displayed on the screen. * <p>
* When the cursor is turned off, there is no visible cursor displayed on the screen.
* *
* @param cursorOn true turns the cursor on, false turns it off. * @param cursorOn true turns the cursor on, false turns it off.
*/ */
@ -871,6 +875,7 @@ public class FieldPanel extends JPanel
* @param fieldNum the field on the line to go to. * @param fieldNum the field on the line to go to.
* @param row the row in the field to go to. * @param row the row in the field to go to.
* @param col the column in the field to go to. * @param col the column in the field to go to.
* @param trigger the cause of the go to
* @param alwaysCenterCursor if true, centers cursor on screen. Otherwise, only centers cursor * @param alwaysCenterCursor if true, centers cursor on screen. Otherwise, only centers cursor
* if cursor is offscreen. * if cursor is offscreen.
*/ */
@ -945,8 +950,9 @@ public class FieldPanel extends JPanel
} }
/** /**
* Returns a ViewerPosition object which contains the top of screen information. The * Returns a ViewerPosition object which contains the top of screen information.
* ViewerPosition will have the index of the layout at the top of the screen and the yPos of * <p>
* The ViewerPosition will have the index of the layout at the top of the screen and the yPos of
* that layout. For example, if the layout is completely displayed, yPos will be 0. If part of * that layout. For example, if the layout is completely displayed, yPos will be 0. If part of
* the layout is off the top off the screen, then yPos will have a negative value (indicating * the layout is off the top off the screen, then yPos will have a negative value (indicating
* that it begins above the displayable part of the screen. * that it begins above the displayable part of the screen.
@ -962,8 +968,10 @@ public class FieldPanel extends JPanel
/** /**
* Scrolls the display to show the layout specified by index at the vertical position specified * Scrolls the display to show the layout specified by index at the vertical position specified
* by yPos. Generally, the index will be layout at the top of the screen and the yPos will be * by yPos.
* &lt;= 0, meaning the layout may be partially off the top of the screen. * <p>
* Generally, the index will be layout at the top of the screen and the yPos will be &lt;= 0,
* meaning the layout may be partially off the top of the screen.
* *
* @param index the index of the layout to show at the top of the screen. * @param index the index of the layout to show at the top of the screen.
* @param xPos the x position to set. * @param xPos the x position to set.
@ -1329,6 +1337,7 @@ public class FieldPanel extends JPanel
/** /**
* Finds the layout containing the given y position. * Finds the layout containing the given y position.
*
* @param y the y location * @param y the y location
* @return the layout. * @return the layout.
*/ */

View file

@ -172,11 +172,10 @@ public class VgSatelliteFeaturette<V extends VisualVertex,
return false; return false;
} }
if (!(context instanceof VisualGraphActionContext)) { if (!(context instanceof VisualGraphActionContext vgContext)) {
return false; return false;
} }
VisualGraphActionContext vgContext = (VisualGraphActionContext) context;
return vgContext.shouldShowSatelliteActions(); return vgContext.shouldShowSatelliteActions();
} }
}; };
@ -200,11 +199,10 @@ public class VgSatelliteFeaturette<V extends VisualVertex,
return false; return false;
} }
if (!(context instanceof VisualGraphActionContext)) { if (!(context instanceof VisualGraphActionContext vgContext)) {
return false; return false;
} }
VisualGraphActionContext vgContext = (VisualGraphActionContext) context;
return vgContext.shouldShowSatelliteActions(); return vgContext.shouldShowSatelliteActions();
} }
}; };