Merge remote-tracking branch 'origin/GP-4947-dragomacher-function-graph-toggle-action'

This commit is contained in:
Ryan Kurtz 2024-10-11 12:50:57 -04:00
commit 86088f058b
3 changed files with 40 additions and 2 deletions

View File

@ -33,6 +33,15 @@
"#Function_Graph_Actions">actions</A> that apply to the entire graph.</P>
</BLOCKQUOTE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<A NAME="Toggle_Listing_and_Function_Graph"></A>
<P><IMG src="help/shared/tip.png" alt="" border="0"><B><I>Ctrl-Space</I></B> will toggle
between the full Listing view and the Function Graph view. The <CODE>Toggle Listing and
Function Graph</CODE> action's key binding can be changed in the tool options.</P>
</BLOCKQUOTE>
</BLOCKQUOTE>
<H2><A name="Primary_View"></A>Primary View</H2>

View File

@ -21,6 +21,9 @@ import javax.swing.Icon;
import org.jdom.Element;
import docking.ComponentProvider;
import docking.DockingWindowManager;
import docking.action.builder.ActionBuilder;
import docking.options.OptionsService;
import docking.tool.ToolConstants;
import generic.theme.GIcon;
@ -36,6 +39,7 @@ import ghidra.app.plugin.core.functiongraph.mvc.FunctionGraphOptions;
import ghidra.app.plugin.core.marker.MarginProviderSupplier;
import ghidra.app.services.*;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
import ghidra.framework.model.DomainFile;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginInfo;
@ -86,6 +90,29 @@ public class FunctionGraphPlugin extends ProgramPlugin
super(tool);
colorProvider = new IndependentColorProvider(tool);
new ActionBuilder("Toggle Listing and Function Graph", getName())
.keyBinding("control space")
.onAction(c -> toggleView())
.buildAndInstall(tool);
}
private void toggleView() {
CodeViewerService cvService = tool.getService(CodeViewerService.class);
ListingPanel lp = cvService.getListingPanel();
DockingWindowManager dwm = DockingWindowManager.getInstance(lp);
ComponentProvider cvProvider = dwm.getComponentProvider(lp);
if (cvProvider.isFocusedProvider()) {
connectedProvider.setVisible(true);
}
else {
// Either the Function Graph is focused or some other provider has focus. Just jump to
// the code viewer in this case. The user can perform the action again to get to the
// graph.
cvProvider.setVisible(true);
}
}
@Override

View File

@ -248,6 +248,8 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
return;
}
// this call is needed to bring tabbed providers to the front
toFront();
if (defaultFocusComponent != null) {
DockingWindowManager.requestFocus(defaultFocusComponent);
return;