GP-3709 - Updated GhidraTable to simplify navigation installation

This commit is contained in:
dragonmacher 2023-08-07 18:55:47 -04:00
parent d8f61fc7b2
commit 999fe21b33
30 changed files with 128 additions and 149 deletions

View File

@ -19,7 +19,6 @@ import java.awt.*;
import javax.swing.*;
import ghidra.app.services.GoToService;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.AddressSet;
@ -138,10 +137,7 @@ public class FunctionStartTableProvider extends ProgramAssociatedComponentProvid
startTable = tablePanel.getTable();
startTable.setName("Potential Functions in " + model.getProgram().getName());
GoToService goToService = tool.getService(GoToService.class);
if (goToService != null) {
startTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
startTable.installNavigation(tool);
startTable.setNavigateOnSelectionEnabled(true);
startTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
startTable.setPreferredScrollableViewportSize(new Dimension(900, 300));

View File

@ -21,7 +21,6 @@ import java.util.List;
import javax.swing.*;
import ghidra.app.services.GoToService;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
@ -88,10 +87,8 @@ public class SimilarStartsTableProvider extends ProgramAssociatedComponentProvid
GhidraTable similarStartsTable = similarStartsPanel.getTable();
similarStartsPanel.setName(
targetProgram.getName() + ": Known Starts Similar to " + potentialStart.toString());
GoToService goToService = tool.getService(GoToService.class);
if (goToService != null) {
similarStartsTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
similarStartsTable.installNavigation(tool);
similarStartsTable.setNavigateOnSelectionEnabled(true);
similarStartsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
similarStartsTable.setPreferredScrollableViewportSize(new Dimension(700, 200));
@ -107,9 +104,7 @@ public class SimilarStartsTableProvider extends ProgramAssociatedComponentProvid
GhidraTable potentialStartTable = potentialStartPanel.getTable();
potentialStartTable
.setToolTipText("Potential Function Start in " + targetProgram.getName());
if (goToService != null) {
potentialStartTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
potentialStartTable.installNavigation(tool);
potentialStartTable.setNavigateOnSelectionEnabled(true);
potentialStartTable.setPreferredScrollableViewportSize(new Dimension(700, 30));
potentialStartTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

View File

@ -109,7 +109,7 @@ public class BookmarkProvider extends ComponentProviderAdapter {
}
void setGoToService(GoToService goToService) {
bookmarkTable.installNavigation(goToService, goToService.getDefaultNavigatable());
bookmarkTable.installNavigation(tool);
}
private JPanel createFilterFieldPanel() {

View File

@ -23,7 +23,6 @@ import javax.swing.*;
import javax.swing.table.JTableHeader;
import docking.ActionContext;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
@ -126,8 +125,7 @@ class CommentWindowProvider extends ComponentProviderAdapter {
setSubTitle(buffy.toString());
});
GoToService goToService = tool.getService(GoToService.class);
commentTable.installNavigation(goToService, goToService.getDefaultNavigatable());
commentTable.installNavigation(tool);
JTableHeader commentHeader = commentTable.getTableHeader();
commentHeader.setUpdateTableInRealTime(true);

View File

@ -24,7 +24,6 @@ import javax.swing.table.JTableHeader;
import docking.ActionContext;
import generic.theme.GIcon;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
@ -132,8 +131,7 @@ class DataWindowProvider extends ComponentProviderAdapter {
setSubTitle(buffy.toString());
});
GoToService goToService = tool.getService(GoToService.class);
dataTable.installNavigation(goToService, goToService.getDefaultNavigatable());
dataTable.installNavigation(tool);
JTableHeader dataHeader = dataTable.getTableHeader();
dataHeader.setUpdateTableInRealTime(true);

View File

@ -29,7 +29,6 @@ import docking.widgets.checkbox.GCheckBox;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel;
import docking.widgets.textfield.HintTextField;
import ghidra.app.services.GoToService;
import ghidra.app.util.HelpTopics;
import ghidra.app.util.PseudoDisassembler;
import ghidra.program.model.listing.Program;
@ -93,8 +92,7 @@ public class AddressTableDialog extends ReusableDialogComponentProvider {
// create right side query results table with three columns
resultsTablePanel = new GhidraThreadedTablePanel<>(plugin.getModel());
resultsTable = resultsTablePanel.getTable();
GoToService goToService = plugin.getTool().getService(GoToService.class);
resultsTable.installNavigation(goToService, goToService.getDefaultNavigatable());
resultsTable.installNavigation(plugin.getTool());
ListSelectionModel selModel = resultsTable.getSelectionModel();
selModel.addListSelectionListener(e -> {

View File

@ -66,20 +66,6 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
goToService = tool.getService(GoToService.class);
}
@Override
public void serviceAdded(Class<?> interfaceClass, Object service) {
if (interfaceClass == GoToService.class) {
provider.setGoToService((GoToService) service);
}
}
@Override
public void serviceRemoved(Class<?> interfaceClass, Object service) {
if (interfaceClass == GoToService.class) {
provider.setGoToService(null);
}
}
@Override
public void dispose() {
updateMgr.dispose();

View File

@ -30,7 +30,6 @@ import docking.action.builder.ActionBuilder;
import docking.widgets.label.GLabel;
import ghidra.app.context.ProgramActionContext;
import ghidra.app.services.DataTypeManagerService;
import ghidra.app.services.GoToService;
import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.data.DataTypeManager;
@ -183,17 +182,12 @@ public class EquateTableProvider extends ComponentProviderAdapter {
referencesModel = new EquateReferenceTableModel(plugin);
referencesTable = new GhidraTable(referencesModel);
referencesTable.installNavigation(tool);
referencesTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
referencesTable.setPreferredScrollableViewportSize(new Dimension(250, 150));
referencesTable.setRowSelectionAllowed(true);
referencesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
GoToService goToService = tool.getService(GoToService.class);
if (goToService != null) {
referencesTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
JScrollPane referencesTablePane = new JScrollPane(referencesTable);
JTableHeader referencesHeader = referencesTable.getTableHeader();
@ -331,15 +325,6 @@ public class EquateTableProvider extends ComponentProviderAdapter {
plugin.deleteEquates(equates);
}
void setGoToService(GoToService service) {
if (service != null) {
referencesTable.installNavigation(service, service.getDefaultNavigatable());
}
else {
referencesTable.removeNavigation();
}
}
EquateTableModel getEquatesModel() {
return equatesModel;
}

View File

@ -21,7 +21,6 @@ import java.util.stream.Collectors;
import javax.swing.*;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.listing.*;
import ghidra.util.table.*;
@ -61,10 +60,7 @@ public class AllFunctionsPanel extends JPanel {
add(tablePanel, BorderLayout.CENTER);
add(filterPanel, BorderLayout.SOUTH);
GoToService goToService = provider.getTool().getService(GoToService.class);
if (goToService != null) {
table.installNavigation(goToService, goToService.getDefaultNavigatable());
}
table.installNavigation(provider.getTool());
}
/**

View File

@ -36,7 +36,7 @@ public class EditFunctionTagsAction extends ListingContextAction {
private FunctionTagPlugin plugin;
// Menu option that will show up when right-clicking on a function in the listing
private final String MENU_LABEL = "Edit Tags...";
private final String MENU_LABEL = "Edit Tags";
/**
* Constructor.

View File

@ -27,7 +27,6 @@ import javax.swing.table.*;
import docking.ActionContext;
import docking.DefaultActionContext;
import generic.theme.GIcon;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.*;
@ -121,11 +120,7 @@ public class FunctionWindowProvider extends ComponentProviderAdapter {
functionTable = threadedTablePanel.getTable();
functionTable.setName("FunctionTable");
GoToService goToService = tool.getService(GoToService.class);
if (goToService != null) {
functionTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
functionTable.installNavigation(tool);
functionTable.setAutoLookupColumn(FunctionTableModel.NAME_COL);
functionTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
functionTable.setPreferredScrollableViewportSize(new Dimension(350, 150));

View File

@ -24,7 +24,6 @@ import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.event.TableModelListener;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.util.ProgramSelection;
@ -58,8 +57,7 @@ public class LocationReferencesPanel extends JPanel {
setLayout(new BorderLayout(10, 10));
PluginTool tool = locationReferencesProvider.getTool();
GoToService goToService = tool.getService(GoToService.class);
table.installNavigation(goToService, goToService.getDefaultNavigatable());
table.installNavigation(tool);
GhidraTableFilterPanel<LocationReference> tableFilterPanel =
new GhidraTableFilterPanel<>(table, tableModel);

View File

@ -483,7 +483,7 @@ class ShowInfoAction extends ListingContextAction {
this.plugin = plugin;
setPopupMenuData(new MenuData(new String[] { "Instruction Info..." }, null, "Disassembly"));
setPopupMenuData(new MenuData(new String[] { "Instruction Info" }, null, "Disassembly"));
}
@ -505,8 +505,8 @@ class ShowProcessorManualAction extends ProgramContextAction {
this.plugin = plugin;
setMenuBarData(
new MenuData(new String[] { "Tools", "Processor Manual..." }, null, "Disassembly"));
setPopupMenuData(new MenuData(new String[] { "Processor Manual..." }, null, "Disassembly"));
new MenuData(new String[] { "Tools", "Processor Manual" }, null, "Disassembly"));
setPopupMenuData(new MenuData(new String[] { "Processor Manual" }, null, "Disassembly"));
this.setEnabled(true);
}

View File

@ -24,7 +24,6 @@ import javax.swing.*;
import docking.ComponentProvider;
import docking.WindowPosition;
import docking.widgets.label.GDLabel;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressFactory;
@ -167,10 +166,7 @@ public class FunctionReachabilityProvider extends ComponentProvider {
resultsTable = tablePanel.getTable();
GoToService goToService = plugin.getTool().getService(GoToService.class);
if (goToService != null) {
resultsTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
resultsTable.installNavigation(plugin.getTool());
resultsTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting()) {
@ -193,9 +189,7 @@ public class FunctionReachabilityProvider extends ComponentProvider {
pathsModel = new FRPathsModel(plugin.getTool(), program);
pathsTable = new GhidraTable(pathsModel);
if (goToService != null) {
pathsTable.installNavigation(goToService, goToService.getDefaultNavigatable());
}
pathsTable.installNavigation(plugin.getTool());
outputPanel.add(new JScrollPane(pathsTable));

View File

@ -31,7 +31,8 @@ import generic.theme.GThemeDefaults.Colors.Palette;
import generic.theme.Gui;
import ghidra.app.cmd.register.SetRegisterCmd;
import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.services.*;
import ghidra.app.services.MarkerService;
import ghidra.app.services.MarkerSet;
import ghidra.framework.cmd.Command;
import ghidra.framework.cmd.CompoundCmd;
import ghidra.framework.plugintool.PluginTool;
@ -119,8 +120,7 @@ class RegisterValuesPanel extends JPanel {
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setRowSelectionAllowed(true);
table.setColumnSelectionAllowed(false);
GoToService goToService = tool.getService(GoToService.class);
table.installNavigation(goToService, goToService.getDefaultNavigatable());
table.installNavigation(tool);
table.setNavigateOnSelectionEnabled(true);
return table;
}

View File

@ -21,7 +21,6 @@ import java.awt.Dimension;
import javax.swing.*;
import ghidra.app.plugin.core.reloc.RelocationTableModel.RelocationRowObject;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.listing.Program;
@ -76,9 +75,7 @@ class RelocationProvider extends ComponentProviderAdapter {
threadedPanel = new GhidraThreadedTablePanel<>(tableModel);
table = threadedPanel.getTable();
GoToService goToService = serviceProvider.getService(GoToService.class);
table.installNavigation(goToService, goToService.getDefaultNavigatable());
table.installNavigation(serviceProvider);
table.setPreferredScrollableViewportSize(new Dimension(300, 200));
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);

View File

@ -28,7 +28,6 @@ import docking.widgets.table.GTableFilterPanel;
import docking.widgets.table.TableFilter;
import generic.theme.GIcon;
import ghidra.app.plugin.core.scalartable.RangeFilterTextField.FilterType;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
@ -218,8 +217,7 @@ public class ScalarSearchProvider extends ComponentProviderAdapter {
scalarModel.addTableModelListener(
e -> setSubTitle(primarySubTitle + ' ' + scalarModel.getRowCount() + " items"));
GoToService goToService = tool.getService(GoToService.class);
scalarTable.installNavigation(goToService, goToService.getDefaultNavigatable());
scalarTable.installNavigation(tool);
mainPanel = new JPanel(new BorderLayout());
mainPanel.add(threadedTablePanel, BorderLayout.CENTER);

View File

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,7 @@
*/
package ghidra.app.plugin.core.stackeditor;
import docking.action.MenuData;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
import ghidra.app.services.DataTypeManagerService;
@ -24,7 +24,6 @@ import ghidra.program.model.listing.Function;
import ghidra.program.util.FunctionLocation;
import ghidra.program.util.ProgramLocation;
import ghidra.util.HelpLocation;
import docking.action.MenuData;
/**
* <CODE>EditStackAction</CODE> allows the user to edit a function's stack frame.
@ -45,16 +44,12 @@ public class EditStackAction extends ListingContextAction {
super("Edit Stack Frame", plugin.getName());
this.plugin = plugin;
this.dtmService = dtmService;
setPopupMenuData(new MenuData(new String[] { "Function", "Edit Stack Frame..." }, null,
setPopupMenuData(new MenuData(new String[] { "Function", "Edit Stack Frame" }, null,
"Stack"));
setHelpLocation(new HelpLocation("StackEditor", "Stack_Editor"));
}
/**
* Method called when the action is invoked.
* @param ActionEvent details regarding the invocation of this action
*/
@Override
public void actionPerformed(ListingActionContext context) {
Function function = getFunction(context);

View File

@ -31,7 +31,6 @@ import docking.widgets.table.*;
import docking.widgets.table.threaded.ThreadedTableModel;
import docking.widgets.textfield.IntegerTextField;
import generic.theme.GIcon;
import ghidra.app.services.GoToService;
import ghidra.app.util.HelpTopics;
import ghidra.docking.settings.SettingsImpl;
import ghidra.framework.model.DomainObjectChangedEvent;
@ -518,8 +517,7 @@ public class StringTableProvider extends ComponentProviderAdapter implements Dom
stringModel.addTableModelListener(e -> updateSubTitle());
GoToService goToService = tool.getService(GoToService.class);
table.installNavigation(goToService, goToService.getDefaultNavigatable());
table.installNavigation(tool);
table.setDefaultRenderer(FoundString.DefinedState.class, new DefinedColumnRenderer());
filterPanel = new GhidraTableFilterPanel<>(table, stringModel);

View File

@ -29,7 +29,6 @@ import docking.ActionContext;
import docking.widgets.table.GTableTextCellEditor;
import docking.widgets.table.threaded.ThreadedTableModelListener;
import generic.theme.GIcon;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.DataUtilities;
@ -161,8 +160,7 @@ public class ViewStringsProvider extends ComponentProviderAdapter {
stringRepCol.setCellEditor(new StringRepCellEditor());
GoToService goToService = tool.getService(GoToService.class);
table.installNavigation(goToService, goToService.getDefaultNavigatable());
table.installNavigation(tool);
filterPanel = new GhidraTableFilterPanel<>(table, stringModel);

View File

@ -24,7 +24,6 @@ import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import ghidra.app.services.GoToService;
import ghidra.program.model.symbol.Reference;
import ghidra.util.table.GhidraTable;
import ghidra.util.table.GhidraThreadedTablePanel;
@ -40,8 +39,8 @@ class ReferencePanel extends JPanel {
private TableModelListener listener;
private GhidraThreadedTablePanel<Reference> threadedTablePanel;
ReferencePanel(ReferenceProvider provider, SymbolReferenceModel model, SymbolRenderer renderer,
GoToService gotoService) {
ReferencePanel(ReferenceProvider provider, SymbolReferenceModel model,
SymbolRenderer renderer) {
super(new BorderLayout());
@ -54,7 +53,7 @@ class ReferencePanel extends JPanel {
refTable.setName("ReferenceTable");//used by JUnit...
refTable.setPreferredScrollableViewportSize(new Dimension(250, 200));
refTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
refTable.installNavigation(gotoService, gotoService.getDefaultNavigatable());
refTable.installNavigation(provider.getTool());
this.listener = e -> referenceProvider.updateTitle();
refTable.getModel().addTableModelListener(listener);

View File

@ -56,7 +56,7 @@ class ReferenceProvider extends ComponentProviderAdapter {
referenceKeyModel =
new SymbolReferenceModel(plugin.getBlockModelService(), plugin.getTool());
referencePanel =
new ReferencePanel(this, referenceKeyModel, renderer, plugin.getGoToService());
new ReferencePanel(this, referenceKeyModel, renderer);
addToTool();
}

View File

@ -28,7 +28,6 @@ import org.jdom.Element;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.table.DefaultRowFilterTransformer;
import docking.widgets.table.RowFilterTransformer;
import ghidra.app.services.GoToService;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.symbol.Symbol;
@ -50,7 +49,7 @@ class SymbolPanel extends JPanel {
private GhidraTableFilterPanel<SymbolRowObject> tableFilterPanel;
SymbolPanel(SymbolProvider provider, SymbolTableModel model, SymbolRenderer renderer,
final PluginTool tool, GoToService gotoService) {
PluginTool tool) {
super(new BorderLayout());
@ -74,8 +73,7 @@ class SymbolPanel extends JPanel {
}
});
GoToService goToService = tool.getService(GoToService.class);
symTable.installNavigation(goToService, goToService.getDefaultNavigatable());
symTable.installNavigation(tool);
for (int i = 0; i < symTable.getColumnCount(); i++) {
TableColumn column = symTable.getColumnModel().getColumn(i);

View File

@ -58,8 +58,7 @@ class SymbolProvider extends ComponentProviderAdapter {
renderer = new SymbolRenderer();
symbolKeyModel = new SymbolTableModel(this, plugin.getTool());
symbolPanel = new SymbolPanel(this, symbolKeyModel, renderer, plugin.getTool(),
plugin.getGoToService());
symbolPanel = new SymbolPanel(this, symbolKeyModel, renderer, plugin.getTool());
addToTool();
}

View File

@ -133,11 +133,12 @@ public class TableComponentProvider<T> extends ComponentProviderAdapter
// only allow global actions through if we are derived from the connect/primary navigatable
table.setActionsEnabled(navigatable.isConnected());
if (gotoService != null) {
if (navigatable != null) {
navigatable.addNavigatableListener(this);
}
table.installNavigation(gotoService, navigatable);
if (navigatable != null) {
navigatable.addNavigatableListener(this);
table.installNavigation(tool, navigatable);
}
else {
table.installNavigation(tool);
}
panel.add(threadedPanel, BorderLayout.CENTER);
@ -155,7 +156,7 @@ public class TableComponentProvider<T> extends ComponentProviderAdapter
selectionNavigationAction = new SelectionNavigationAction(plugin, table);
selectionNavigationAction
.setHelpLocation(new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation"));
.setHelpLocation(new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation"));
DockingAction externalGotoAction = new DockingAction("Go to External Location", getName()) {
@Override

View File

@ -110,7 +110,7 @@ public class TableChooserDialog extends DialogComponentProvider
if (goToService != null) {
navigatable = navigatable == null ? goToService.getDefaultNavigatable() : navigatable;
navigatable.addNavigatableListener(this);
table.installNavigation(goToService, navigatable);
table.installNavigation(tool, navigatable);
}
table.getSelectionModel()
.addListSelectionListener(e -> setOkEnabled(table.getSelectedRowCount() > 0));

View File

@ -26,9 +26,12 @@ import javax.swing.table.TableModel;
import docking.widgets.table.GTable;
import ghidra.app.nav.Navigatable;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.framework.plugintool.ServiceProviderStub;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
import ghidra.util.Msg;
/**
* Navigation is only supported if the underlying table model
@ -43,7 +46,7 @@ import ghidra.program.util.ProgramSelection;
public class GhidraTable extends GTable {
private Navigatable navigatable;
private GoToService gotoService;
private ServiceProvider serviceProvider;
private boolean navigateOnSelection;
private KeyListener navigationKeyListener;
private MouseListener navigationMouseListener;
@ -77,11 +80,50 @@ public class GhidraTable extends GTable {
/**
* 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
* @deprecated use {@link #installNavigation(ServiceProvider)} or
* {@link #installNavigation(ServiceProvider,Navigatable)}
*/
@Deprecated
public void installNavigation(GoToService goToService, Navigatable nav) {
installNavigation(new GoToServiceProvider(goToService), nav);
}
/**
* Sets the service provider to use when navigation is enabled on this table. 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.
*
* @param sp the service provider
* @param nav the navigable
*/
public void installNavigation(GoToService goToService, Navigatable nav) {
public void installNavigation(ServiceProvider sp, Navigatable nav) {
if (nav == null) {
// When null, the default navigatable will be used. But, clients calling this method
// with a null navigatable have likely made a mistake. Clients that do not have a valid
// navigatable should call installNavigation(serviceProvider) instead.
Msg.debug(this, "Attempted to install navigation on a table using a null Navigatable");
}
this.navigatable = nav;
installNavigation(sp);
}
/**
* Sets the service provider to use when navigation is enabled on this table. The service
* provider will be used to retrieve the {@link GoToService}, as needed after the system has
* been initialized.
*
* @param sp the service provider
*/
public void installNavigation(ServiceProvider sp) {
if (sp == null) {
Msg.error(this,
"Attempt to install navigation on this table failed; service provider is null");
return;
}
@ -119,16 +161,19 @@ public class GhidraTable extends GTable {
selectionModel.addListSelectionListener(navigationSelectionListener);
}
this.gotoService = goToService;
this.navigatable = nav;
this.serviceProvider = sp;
}
/**
* Removes any installed navigation components, such as listeners, a navigatable and the
* service provider.
*/
public void removeNavigation() {
removeKeyListener(navigationKeyListener);
removeMouseListener(navigationMouseListener);
selectionModel.removeListSelectionListener(navigationSelectionListener);
this.gotoService = null;
this.serviceProvider = null;
this.navigatable = null;
}
@ -181,11 +226,11 @@ public class GhidraTable extends GTable {
* @param column the column
*/
public void navigate(int row, int column) {
if (navigatable == null) {
if (serviceProvider == null) {
return;
}
column = convertColumnIndexToModel(column);
column = convertColumnIndexToModel(column);
if (row < 0 || column < 0) {
return;
}
@ -194,14 +239,19 @@ public class GhidraTable extends GTable {
return;
}
GoToService goToService = serviceProvider.getService(GoToService.class);
if (goToService == null) {
return;
}
ProgramTableModel ptm = (ProgramTableModel) dataModel;
ProgramLocation loc = ptm.getProgramLocation(row, column);
if (loc != null && loc.getAddress().isExternalAddress()) {
gotoService.goTo(loc.getAddress(), ptm.getProgram());
goToService.goTo(loc.getAddress(), ptm.getProgram());
return;
}
Program program = ptm.getProgram();
gotoService.goTo(navigatable, loc, program);
goToService.goTo(navigatable, loc, program);
}
/**
@ -297,4 +347,26 @@ public class GhidraTable extends GTable {
}
}
private class GoToServiceProvider extends ServiceProviderStub {
private GoToService goToService;
GoToServiceProvider(GoToService goToService) {
this.goToService = goToService;
if (goToService == null) {
Msg.error(this,
"Attempt to install the GoToService on this table failed; service is null");
}
}
@SuppressWarnings("unchecked") // cast is safe; we checked the class
@Override
public <T> T getService(Class<T> serviceClass) {
if (serviceClass == GoToService.class) {
return (T) goToService;
}
return null;
}
}
}

View File

@ -21,7 +21,6 @@ import javax.swing.*;
import docking.WindowPosition;
import docking.widgets.label.GLabel;
import ghidra.app.services.GoToService;
import ghidra.bitpatterns.info.*;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.AddressSet;
@ -67,10 +66,7 @@ public class PatternEvalTableProvider extends ComponentProviderAdapter {
new GhidraThreadedTablePanel<>(patternEvalModel, 1000);
GhidraTable table = threadedPanel.getTable();
GoToService goToService = tool.getService(GoToService.class);
if (goToService != null) {
table.installNavigation(goToService, goToService.getDefaultNavigatable());
}
table.installNavigation(tool);
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

View File

@ -40,7 +40,6 @@ import docking.widgets.table.threaded.ThreadedTableModel;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.functioncompare.FunctionComparisonPanel;
import ghidra.app.services.GoToService;
import ghidra.app.util.viewer.listingpanel.ListingCodeComparisonPanel;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
import ghidra.feature.vt.api.db.DeletedMatch;
@ -443,8 +442,6 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
private JComponent createSourceFunctionPanel() {
GoToService goToService = tool.getService(GoToService.class);
Program sourceProgram = controller.getSourceProgram();
sourceFunctionsModel =
new VTFunctionAssociationTableModel(tool, controller, sourceProgram, true);
@ -453,10 +450,7 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
sourceFunctionsTable.setName("SourceFunctionTable");
sourceFunctionsTable.setPreferenceKey(
"VTFunctionAssociationTableModel - Source Function Table");
if (goToService != null) {
sourceFunctionsTable.installNavigation(goToService,
goToService.getDefaultNavigatable());
}
sourceFunctionsTable.installNavigation(tool);
sourceFunctionsTable.setAutoLookupColumn(VTFunctionAssociationTableModel.NAME_COL);
sourceFunctionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
sourceFunctionsTable.setPreferredScrollableViewportSize(new Dimension(350, 150));
@ -498,8 +492,6 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
private JComponent createDestinationFunctionPanel() {
GoToService goToService = tool.getService(GoToService.class);
Program destinationProgram = controller.getDestinationProgram();
destinationFunctionsModel =
new VTFunctionAssociationTableModel(tool, controller, destinationProgram, false);
@ -509,10 +501,7 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
destinationFunctionsTable.setName("DestinationFunctionTable");
destinationFunctionsTable.setPreferenceKey(
"VTFunctionAssociationTableModel - " + "Destination Function Table");
if (goToService != null) {
destinationFunctionsTable.installNavigation(goToService,
goToService.getDefaultNavigatable());
}
destinationFunctionsTable.installNavigation(tool);
destinationFunctionsTable.setAutoLookupColumn(VTFunctionAssociationTableModel.NAME_COL);
destinationFunctionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
destinationFunctionsTable.setPreferredScrollableViewportSize(new Dimension(350, 150));

View File

@ -1017,7 +1017,7 @@ Before you can do anything else, you must first create a project. Projects are u
<p>
<b><u>Notes:</u></b>
<ul>
<li><b>Instruction Manual</b> Right-click on any instruction and choose <b>Processor Manual...</b> from the menu. If the manual is in your installation, your default web browser will open the manual to the first page containing that instruction if it allows page numbers. If not, the first page of the manual will open. If the manual is not in your installation, a window will open with a link to the manual and tell you where to put the manual in the installation.</li>
<li><b>Instruction Manual</b> Right-click on any instruction and choose <b>Processor Manual</b> from the menu. If the manual is in your installation, your default web browser will open the manual to the first page containing that instruction if it allows page numbers. If not, the first page of the manual will open. If the manual is not in your installation, a window will open with a link to the manual and tell you where to put the manual in the installation.</li>
<li><b>Info Fields at bottom of Browser</b>: The Little window with basic assembly shows what the original assembly looked like before Ghidra marked it up. The current address window shows the address of the cursor and the function name.</li>
<li><b>Hover</b>: Use hover by placing the mouse over all items with references and all data types to bring up a temporary window with a referenced item or data definition. The hover window stays visible as long as the cursor is in the window.</li>
<li><b>Cursor text highlight</b>: Click on any text in a Listing field with the middle mouse button. All matching text in the listing will be highlighted in yellow. By default, there is different behavior when middle-mousing on a register. Every matching register or sub-register in the current scope of the register will be highlighted in green. The register's initialization within the current scope will be highlighted mustard yellow. Every matching register or subregister outside the current scope of the register will be highlighted in yellow. You can change the colors or the default behavior of this feature by going to the <b>Edit->Tool Options...</b></li>