GP-4947 - Function Graph - Added an action to toggle between the Listing

and Function Graph views (ctrl-space)
This commit is contained in:
dragonmacher 2024-10-10 20:28:01 -04:00
parent 065a845d4a
commit f133c6c971
3 changed files with 40 additions and 2 deletions

View File

@ -32,6 +32,15 @@
"#Satellite_View">Satellite View</A>. There is also a group of <A href=
"#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

@ -4,9 +4,9 @@
* 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.
@ -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;