mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-308 preserved graph satellite state between graph instantiations.
(also changed the timing for when preferences are loaded into the tool so that they happen before plugins get initialized)
This commit is contained in:
parent
8dffa0384e
commit
490bc9ffa9
7 changed files with 46 additions and 21 deletions
|
@ -202,6 +202,9 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
|||
componentProvider = new DefaultGraphDisplayComponentProvider(this, pluginTool);
|
||||
componentProvider.addToTool();
|
||||
satelliteViewer = createSatelliteViewer(viewer);
|
||||
if (graphDisplayProvider.getDefaultSatelliteState()) {
|
||||
viewer.getComponent().add(satelliteViewer.getComponent());
|
||||
}
|
||||
layoutTransitionManager =
|
||||
new LayoutTransitionManager(viewer, this::isRoot);
|
||||
|
||||
|
@ -321,6 +324,7 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
|||
new ToggleActionBuilder("SatelliteView", actionOwnerName).description("Show Satellite View")
|
||||
.toolBarIcon(DefaultDisplayGraphIcons.SATELLITE_VIEW_ICON)
|
||||
.onAction(this::toggleSatellite)
|
||||
.selected(graphDisplayProvider.getDefaultSatelliteState())
|
||||
.buildAndInstallLocal(componentProvider);
|
||||
|
||||
// create an icon button to reset the view transformations to identity (scaled to layout)
|
||||
|
@ -576,7 +580,9 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
|||
* @param context information about the event
|
||||
*/
|
||||
private void toggleSatellite(ActionContext context) {
|
||||
if (((AbstractButton) context.getSourceObject()).isSelected()) {
|
||||
boolean selected = ((AbstractButton) context.getSourceObject()).isSelected();
|
||||
graphDisplayProvider.setDefaultSatelliteState(selected);
|
||||
if (selected) {
|
||||
viewer.getComponent().add(satelliteViewer.getComponent());
|
||||
}
|
||||
else {
|
||||
|
@ -770,7 +776,6 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the {@link AttributedGraph} for visualization
|
||||
* @param attributedGraph the {@link AttributedGraph} to visualize
|
||||
|
@ -1208,7 +1213,6 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use the hide selected action states to determine what vertices are shown:
|
||||
* <ul>
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.options.PreferenceState;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.service.graph.GraphDisplay;
|
||||
import ghidra.service.graph.GraphDisplayProvider;
|
||||
|
@ -28,10 +29,14 @@ import ghidra.util.task.TaskMonitor;
|
|||
|
||||
public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
||||
|
||||
private static final String PREFERENCES_KEY = "GRAPH_DISPLAY_SERVICE";
|
||||
private static final String DEFAULT_SATELLITE_STATE = "DEFAULT_SATELLITE_STATE";
|
||||
private final Set<DefaultGraphDisplay> displays = new HashSet<>();
|
||||
private PluginTool pluginTool;
|
||||
private Options options;
|
||||
private int displayCounter = 1;
|
||||
private boolean defaultSatelliteState;
|
||||
private PreferenceState preferences;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -66,6 +71,12 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
|||
public void initialize(PluginTool tool, Options graphOptions) {
|
||||
this.pluginTool = tool;
|
||||
this.options = graphOptions;
|
||||
preferences = pluginTool.getWindowManager().getPreferenceState(PREFERENCES_KEY);
|
||||
if (preferences == null) {
|
||||
preferences = new PreferenceState();
|
||||
pluginTool.getWindowManager().putPreferenceState(PREFERENCES_KEY, preferences);
|
||||
}
|
||||
defaultSatelliteState = preferences.getBoolean(DEFAULT_SATELLITE_STATE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,4 +116,14 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
|||
displays.remove(defaultGraphDisplay);
|
||||
}
|
||||
|
||||
boolean getDefaultSatelliteState() {
|
||||
return defaultSatelliteState;
|
||||
}
|
||||
|
||||
void setDefaultSatelliteState(boolean b) {
|
||||
defaultSatelliteState = b;
|
||||
preferences.putBoolean(DEFAULT_SATELLITE_STATE, b);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue