Java Code Examples for ghidra.app.services.GoToService#getDefaultNavigatable()

The following examples show how to use ghidra.app.services.GoToService#getDefaultNavigatable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationReferencesPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void findAndDisplayAppliedDataTypeAddresses(DataType dataType) {
	ProgramManager programManagerService = tool.getService(ProgramManager.class);
	GoToService goToService = tool.getService(GoToService.class);
	Program program = programManagerService.getCurrentProgram();
	if (program == null) {
		Msg.showInfo(this, null, "Find References To...",
			"You must have a program open in order to use the 'Find References To...' action");
		return; // cannot find references to a data type if there is no open program
	}

	ProgramLocation genericLocation = new GenericDataTypeProgramLocation(program, dataType);
	LocationDescriptor locationDescriptor = getLocationDescriptor(genericLocation);
	Navigatable navigatable = goToService.getDefaultNavigatable();
	LocationReferencesProvider provider = findProvider(locationDescriptor, navigatable);
	showProvider(program, provider, locationDescriptor, navigatable);
}
 
Example 2
Source File: LocationReferencesPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void findAndDisplayAppliedDataTypeAddresses(Composite dataType, String fieldName) {
	ProgramManager programManagerService = tool.getService(ProgramManager.class);
	GoToService goToService = tool.getService(GoToService.class);
	Program program = programManagerService.getCurrentProgram();
	if (program == null) {
		Msg.showInfo(this, null, "Find References To...",
			"You must have a program open in order to use the 'Find References To...' action");
		return; // cannot find references to a data type if there is no open program
	}

	ProgramLocation genericLocation =
		new GenericCompositeDataTypeProgramLocation(program, dataType, fieldName);
	LocationDescriptor locationDescriptor = getLocationDescriptor(genericLocation);
	Navigatable navigatable = goToService.getDefaultNavigatable();
	LocationReferencesProvider provider = findProvider(locationDescriptor, navigatable);
	showProvider(program, provider, locationDescriptor, navigatable);
}
 
Example 3
Source File: TableServicePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public <T> TableComponentProvider<T> showTable(String title, String tableTypeName,
		GhidraProgramTableModel<T> model, String windowSubMenu, Navigatable navigatable) {

	GoToService gotoService = tool.getService(GoToService.class);

	if (gotoService != null && navigatable == null) {
		navigatable = gotoService.getDefaultNavigatable();
	}

	Program program = model.getProgram();

	TableComponentProvider<T> cp = new TableComponentProvider<>(this, title, tableTypeName,
		model, program.getDomainFile().getName(), gotoService, windowSubMenu, navigatable);
	addProvider(program, cp);
	return cp;
}
 
Example 4
Source File: TableServicePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public <T> TableComponentProvider<T> showTableWithMarkers(String title, String tableTypeName,
		GhidraProgramTableModel<T> model, Color markerColor, ImageIcon markerIcon,
		String windowSubMenu, Navigatable navigatable) {

	GoToService gotoService = tool.getService(GoToService.class);

	if (gotoService != null && navigatable == null) {
		navigatable = gotoService.getDefaultNavigatable();
	}

	MarkerService markerService = tool.getService(MarkerService.class);
	Program program = model.getProgram();

	TableComponentProvider<T> cp = new TableComponentProvider<>(this, title, tableTypeName,
		model, program.getDomainFile().getName(), gotoService, markerService, markerColor,
		markerIcon, windowSubMenu, navigatable);
	addProvider(program, cp);
	return cp;
}
 
Example 5
Source File: TableServicePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public TableChooserDialog createTableChooserDialog(TableChooserExecutor executor,
		Program program, String title, Navigatable navigatable, boolean isModal) {

	GoToService gotoService = tool.getService(GoToService.class);

	if (gotoService != null && navigatable == null) {
		navigatable = gotoService.getDefaultNavigatable();
	}

	TableChooserDialog dialog =
		new MyTableChooserDialog(this, executor, program, title, navigatable, isModal);

	List<TableChooserDialog> list = programToDialogMap.get(program);
	if (list == null) {
		list = new ArrayList<>();
		programToDialogMap.put(program, list);
	}
	list.add(dialog);
	return dialog;
}
 
Example 6
Source File: TableChooserDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private JPanel buildMainPanel() {
	JPanel panel = new JPanel(new BorderLayout());
	createTableModel();
	TableChooserDialogPanel tablePanel = new TableChooserDialogPanel(model);

	table = tablePanel.getTable();
	GoToService goToService = tool.getService(GoToService.class);
	if (goToService != null) {
		navigatable = navigatable == null ? goToService.getDefaultNavigatable() : navigatable;
		navigatable.addNavigatableListener(this);
		table.installNavigation(goToService, navigatable);
	}
	table.getSelectionModel().addListSelectionListener(
		e -> setOkEnabled(table.getSelectedRowCount() > 0));

	GhidraTableFilterPanel<AddressableRowObject> filterPanel =
		new GhidraTableFilterPanel<>(table, model);
	panel.add(tablePanel, BorderLayout.CENTER);
	panel.add(filterPanel, BorderLayout.SOUTH);
	return panel;
}
 
Example 7
Source File: NextPrevAddressPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Navigatable getNavigatable(ActionContext context) {
	if (context instanceof NavigatableActionContext) {
		Navigatable navigatable = ((NavigatableActionContext) context).getNavigatable();
		if (!navigatable.isConnected()) {
			return navigatable;
		}
	}
	GoToService service = tool.getService(GoToService.class);
	if (service != null) {
		return service.getDefaultNavigatable();
	}
	return null;
}
 
Example 8
Source File: SetHighlightPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void setHighlight(Navigatable navigatable, ProgramSelection highlight) {
	if (navigatable == null) {
		GoToService service = tool.getService(GoToService.class);
		if (service == null) {
			return; // can't do anything
		}
		navigatable = service.getDefaultNavigatable();
	}
	navigatable.setHighlight(highlight);
}
 
Example 9
Source File: SetHighlightPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void setSelection(Navigatable navigatable, ProgramSelection selection) {
	if (navigatable == null) {
		GoToService service = tool.getService(GoToService.class);
		if (service == null) {
			return; // can't do anything
		}
		navigatable = service.getDefaultNavigatable();
	}
	navigatable.setSelection(selection);
}
 
Example 10
Source File: GhidraToolState.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Navigatable getNavigatable() {
    activeProvider = tool.getActiveComponentProvider();
    if (activeProvider instanceof Navigatable) {
        Navigatable nav = (Navigatable) activeProvider;
        if (!nav.isConnected()) {
            return nav;
        }
    }
    GoToService service = tool.getService(GoToService.class);
    if (service != null) {
        return service.getDefaultNavigatable();
    }
    return null;
}