Merge remote-tracking branch 'origin/GP-3667_ghidragon_cleaning_up_GraphDiaplayOptions_constructor_to_register_tool_options--SQUASHED'

This commit is contained in:
Ryan Kurtz 2023-07-25 13:25:40 -04:00
commit ddba5a57bc
34 changed files with 176 additions and 161 deletions

View File

@ -24,6 +24,7 @@ import javax.swing.*;
import docking.ActionContext;
import docking.action.*;
import docking.options.OptionsService;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.filechooser.GhidraFileChooserPanel;
import docking.widgets.table.GFilterTable;
@ -31,7 +32,6 @@ import generic.theme.GIcon;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.util.*;
import ghidra.util.classfinder.ClassSearcher;
import ghidra.util.layout.MiddleLayout;

View File

@ -20,6 +20,7 @@ import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import docking.options.OptionsService;
import docking.widgets.OptionDialog;
import generic.jar.ResourceFile;
import ghidra.app.CorePluginPackage;
@ -31,7 +32,6 @@ import ghidra.framework.main.AppInfo;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.util.Msg;
import ghidra.util.SystemUtilities;

View File

@ -15,11 +15,11 @@
*/
package ghidra.app.plugin.core.navigation;
import docking.options.OptionsService;
import ghidra.GhidraOptions;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.util.HelpLocation;
public class NavigationOptions implements OptionsChangeListener {

View File

@ -20,6 +20,7 @@ import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import docking.options.OptionsService;
import generic.theme.GThemeDefaults.Colors;
import ghidra.GhidraOptions;
import ghidra.app.util.viewer.options.OptionsGui;
@ -27,7 +28,6 @@ import ghidra.app.util.viewer.options.ScreenElement;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.database.symbol.FunctionSymbol;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.*;

View File

@ -17,10 +17,10 @@ package ghidra.app.util.viewer.field;
import javax.swing.event.ChangeListener;
import docking.options.OptionsService;
import ghidra.GhidraOptions;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.listing.CodeUnitFormat;
/**

View File

@ -19,6 +19,7 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import docking.options.OptionsService;
import ghidra.app.nav.Navigatable;
import ghidra.app.nav.NavigationUtils;
import ghidra.app.plugin.core.navigation.NavigationOptions;
@ -27,7 +28,6 @@ import ghidra.app.services.GoToService;
import ghidra.app.util.PseudoDisassembler;
import ghidra.app.util.query.TableService;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSpace;
import ghidra.program.model.data.Playable;

View File

@ -28,6 +28,7 @@ import docking.*;
import docking.action.*;
import docking.menu.ActionState;
import docking.menu.MultiStateDockingAction;
import docking.options.OptionsService;
import docking.widgets.EventTrigger;
import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.field.Field;
@ -50,7 +51,6 @@ import ghidra.app.util.viewer.util.*;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.ServiceProviderDecorator;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.*;
import ghidra.program.model.correlate.HashedFunctionAddressCorrelation;
import ghidra.program.model.listing.*;

View File

@ -21,6 +21,7 @@ import static ghidra.service.graph.VertexShape.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.service.graph.GraphDisplayOptions;
import ghidra.service.graph.VertexShape;
import ghidra.util.HelpLocation;
/**
* {@link GraphDisplayOptions} for {@link ProgramGraphType}
@ -33,7 +34,8 @@ public class ProgramGraphDisplayOptions extends GraphDisplayOptions {
* @param tool if non-null, will load values from tool options
*/
public ProgramGraphDisplayOptions(ProgramGraphType graphType, PluginTool tool) {
super(graphType, tool);
super(graphType, tool,
new HelpLocation("ProgramGraphPlugin", "Program Graphs Display Options"));
}
@Override

View File

@ -20,10 +20,10 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import docking.options.OptionsService;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.framework.plugintool.util.OptionsService;
/**
* BrowserLoader opens a web browser and displays the given url.

View File

@ -25,10 +25,10 @@
import java.util.Iterator;
import docking.options.OptionsService;
import ghidra.app.decompiler.*;
import ghidra.app.script.GhidraScript;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.HighFunction;

View File

@ -25,13 +25,13 @@
import java.util.*;
import docking.options.OptionsService;
import generic.jar.ResourceFile;
import ghidra.app.decompiler.*;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.script.*;
import ghidra.app.tablechooser.*;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSpace;
import ghidra.program.model.lang.Register;

View File

@ -31,7 +31,6 @@ import ghidra.app.decompiler.*;
import ghidra.app.script.GhidraScript;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.lang.PrototypeModel;
@ -42,6 +41,8 @@ import ghidra.util.exception.*;
import java.util.*;
import docking.options.OptionsService;
public class StringParameterPropagator extends GhidraScript {
// TODO!! Error handling needs a lot of work !!

View File

@ -31,11 +31,11 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import docking.options.OptionsService;
import ghidra.app.decompiler.*;
import ghidra.app.script.GhidraScript;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.*;

View File

@ -15,12 +15,12 @@
*/
//DO NOT RUN. THIS IS NOT A SCRIPT! THIS IS A CLASS THAT IS USED BY SCRIPTS.
package classrecovery;
import docking.options.OptionsService;
import ghidra.app.decompiler.DecompInterface;
import ghidra.app.decompiler.DecompileOptions;
import ghidra.app.decompiler.DecompileResults;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.ParameterDefinition;

View File

@ -18,9 +18,9 @@ package ghidra.app.plugin.core.decompile.actions;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.MenuData;
import docking.options.OptionsService;
import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.util.HelpLocation;
public class EditPropertiesAction extends DockingAction {

View File

@ -18,13 +18,13 @@ package ghidra.app.plugin.core.decompile.actions;
import java.util.*;
import java.util.Map.Entry;
import docking.options.OptionsService;
import ghidra.app.cmd.label.RenameLabelCmd;
import ghidra.app.decompiler.*;
import ghidra.framework.cmd.BackgroundCommand;
import ghidra.framework.model.DomainObject;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.data.*;

View File

@ -18,8 +18,10 @@ package ghidra.app.plugin.core.decompile.actions;
import static ghidra.app.plugin.core.decompile.actions.PCodeDfgGraphType.*;
import static ghidra.service.graph.VertexShape.*;
import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.service.graph.*;
import ghidra.util.HelpLocation;
/**
* {@link GraphDisplayOptions} for {@link PCodeDfgGraphType}
@ -48,7 +50,8 @@ public class PCodeDfgDisplayOptions extends GraphDisplayOptions {
* @param tool if non-null, will load values from tool options
*/
public PCodeDfgDisplayOptions(PluginTool tool) {
super(new PCodeDfgGraphType(), tool);
super(new PCodeDfgGraphType(), tool,
new HelpLocation(HelpTopics.DECOMPILER, "DataFlowGraph"));
}
@Override

View File

@ -20,6 +20,7 @@ import java.util.*;
import org.apache.commons.lang3.StringUtils;
import docking.options.OptionsService;
import generic.cache.CachingPool;
import generic.cache.CountingBasicFactory;
import generic.concurrent.QCallback;
@ -31,7 +32,6 @@ import ghidra.app.decompiler.parallel.ParallelDecompiler;
import ghidra.app.util.*;
import ghidra.framework.model.DomainObject;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.*;

View File

@ -19,11 +19,11 @@ import org.junit.Before;
import org.junit.Test;
import docking.action.DockingActionIf;
import docking.options.OptionsService;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.DecompileOptions.NamespaceStrategy;
import ghidra.app.plugin.core.decompile.AbstractDecompilerTest;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
public class DecompilerClang2Test extends AbstractDecompilerTest {

View File

@ -30,6 +30,7 @@ import org.junit.Before;
import org.junit.Test;
import docking.action.DockingActionIf;
import docking.options.OptionsService;
import docking.options.editor.GhidraColorChooser;
import docking.widgets.dialogs.InputDialog;
import docking.widgets.fieldpanel.FieldPanel;
@ -44,7 +45,6 @@ import ghidra.app.plugin.core.decompile.DecompilerProvider;
import ghidra.app.plugin.core.decompile.actions.*;
import ghidra.app.util.AddEditDialog;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.listing.CodeUnit;
public class DecompilerClangTest extends AbstractDecompilerTest {

View File

@ -18,9 +18,9 @@ package ghidra.app.plugin.core.decompile;
import org.junit.Before;
import org.junit.Test;
import docking.options.OptionsService;
import ghidra.app.decompiler.DecompileOptions.NamespaceStrategy;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
/**
* This test is very similar in concept to {@link DecompilerFindReferencesToActionTest},

View File

@ -27,6 +27,7 @@ import docking.DockingUtils;
import docking.action.*;
import docking.menu.ActionState;
import docking.menu.MultiStateDockingAction;
import docking.options.OptionsService;
import docking.widgets.EventTrigger;
import docking.widgets.OptionDialog;
import edu.uci.ics.jung.graph.Graph;
@ -42,7 +43,6 @@ import ghidra.app.plugin.core.functiongraph.mvc.FGController;
import ghidra.app.plugin.core.functiongraph.mvc.FGData;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.Function;

View File

@ -21,6 +21,7 @@ import javax.swing.Icon;
import org.jdom.Element;
import docking.options.OptionsService;
import docking.tool.ToolConstants;
import generic.theme.GIcon;
import ghidra.GhidraOptions;
@ -38,7 +39,6 @@ import ghidra.framework.model.DomainFile;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.graph.viewer.options.VisualGraphOptions;
import ghidra.program.model.listing.Program;

View File

@ -28,6 +28,7 @@ import javax.swing.SwingUtilities;
import com.google.common.cache.*;
import docking.options.OptionsService;
import docking.widgets.EventTrigger;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.Highlight;
@ -50,7 +51,6 @@ import ghidra.app.util.viewer.listingpanel.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.graph.viewer.*;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;

View File

@ -49,16 +49,12 @@ import docking.action.ToggleDockingAction;
import docking.action.builder.*;
import docking.menu.ActionState;
import docking.menu.MultiStateDockingAction;
import docking.options.editor.OptionsDialog;
import docking.widgets.EventTrigger;
import docking.widgets.OptionDialog;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import generic.util.WindowUtilities;
import ghidra.framework.options.Options;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.graph.AttributeFilters;
import ghidra.graph.job.GraphJobRunner;
import ghidra.graph.viewer.popup.*;
@ -166,7 +162,7 @@ public class DefaultGraphDisplay implements GraphDisplay {
private SelectedEdgePaintable<AttributedVertex, AttributedEdge> selectedEdgePaintable;
private GraphDisplayOptions graphDisplayOptions = GraphDisplayOptions.DEFAULT;
private GraphDisplayOptions graphDisplayOptions = new DefaultGraphDisplayOptions();
private ChangeListener graphDisplayOptionsChangeListener;
@ -524,30 +520,8 @@ public class DefaultGraphDisplay implements GraphDisplay {
}
private void editGraphDisplayOptions() {
String rootOptionsName = graphDisplayOptions.getRootOptionsName();
String relativePath = rootOptionsName + ".Vertex Colors";
// if the options are registered in the tool options, just show them
// otherwise, create a transient options and create an options dialog. This will
// allow the user to edit the options for the current graph instance.
if (graphDisplayOptions.isRegisteredWithTool()) {
OptionsService service = tool.getService(OptionsService.class);
service.showOptionsDialog("Graph." + relativePath, "");
}
else {
ToolOptions transientOptions = new ToolOptions("Graph");
HelpLocation help = new HelpLocation("GraphServices", "Graph Type Display Options");
graphDisplayOptions.registerOptions(transientOptions, help);
transientOptions.addOptionsChangeListener(graphDisplayOptions);
Options[] optionsArray = new Options[] { transientOptions };
String dialogTitle = "Graph Instance Settings (Not Saved in Tool Options)";
OptionsDialog dialog = new OptionsDialog(dialogTitle, "Graph", optionsArray, null);
// we have one less level for these transient tool options, so no need to prepend "graph."
dialog.displayCategory(relativePath, "");
tool.showDialog(dialog, componentProvider);
dialog.dispose();
}
HelpLocation help = new HelpLocation("GraphServices", "Graph Type Display Options");
graphDisplayOptions.displayEditor(tool, help);
}
private void groupSelectedVertices() {

View File

@ -111,12 +111,9 @@ public class ProgramGraphPlugin extends ProgramPlugin
}
private void registerProgramFlowGraphDisplayOptionsWithTool() {
ProgramGraphDisplayOptions displayOptions =
new ProgramGraphDisplayOptions(new BlockFlowGraphType(), null);
// this will register Program Flow Graph Type options with the tool
HelpLocation help = new HelpLocation(getName(), "Program Graphs Display Options");
displayOptions.registerOptions(tool.getOptions("Graph"), help);
// We don't need one of this right now, but creating it will make sure it
// shows up in the tool options
new ProgramGraphDisplayOptions(new BlockFlowGraphType(), tool);
}
private void intializeOptions() {
@ -188,79 +185,75 @@ public class ProgramGraphPlugin extends ProgramPlugin
private void createActions() {
new ActionBuilder("Graph Block Flow", getName())
.menuPath(MENU_GRAPH, "&Block Flow")
.menuGroup(MENU_GRAPH, "A")
.onAction(c -> graphBlockFlow())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ActionBuilder("Graph Block Flow", getName()).menuPath(MENU_GRAPH, "&Block Flow")
.menuGroup(MENU_GRAPH, "A")
.onAction(c -> graphBlockFlow())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ActionBuilder("Graph Code Flow", getName())
.menuPath(MENU_GRAPH, "C&ode Flow")
.menuGroup(MENU_GRAPH, "B")
.onAction(c -> graphCodeFlow())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ActionBuilder("Graph Code Flow", getName()).menuPath(MENU_GRAPH, "C&ode Flow")
.menuGroup(MENU_GRAPH, "B")
.onAction(c -> graphCodeFlow())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ActionBuilder("Graph Calls Using Default Model", getName())
.menuPath(MENU_GRAPH, "&Calls")
.menuGroup(MENU_GRAPH, "C")
.onAction(c -> createDefaultCallGraph())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
.menuPath(MENU_GRAPH, "&Calls")
.menuGroup(MENU_GRAPH, "C")
.onAction(c -> createDefaultCallGraph())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
tool.setMenuGroup(new String[] { MENU_GRAPH, "Data" }, "Graph", "Data");
HelpLocation helpLoc = new HelpLocation(getName(), "Data_Reference_Graph");
new ActionBuilder("Graph To/From Data References", getName())
.menuPath(MENU_GRAPH, "Data", "To/From &References")
.menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc)
.onAction(c -> graphDataReferences())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
.menuPath(MENU_GRAPH, "Data", "To/From &References")
.menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc)
.onAction(c -> graphDataReferences())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ActionBuilder("Graph To Data References", getName())
.menuPath(MENU_GRAPH, "Data", "&To References")
.menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc)
.onAction(c -> graphToDataReferences())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
.menuPath(MENU_GRAPH, "Data", "&To References")
.menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc)
.onAction(c -> graphToDataReferences())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ActionBuilder("Graph From Data References", getName())
.menuPath(MENU_GRAPH, "Data", "&From References")
.menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc)
.onAction(c -> graphFromDataReferences())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
.menuPath(MENU_GRAPH, "Data", "&From References")
.menuGroup(MENU_GRAPH, "Data")
.helpLocation(helpLoc)
.onAction(c -> graphFromDataReferences())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
reuseGraphAction =
new ToggleActionBuilder("Reuse Graph", getName())
.menuPath(MENU_GRAPH, "Reuse Graph")
.menuGroup("Graph Options")
.selected(reuseGraph)
.onAction(c -> reuseGraph = reuseGraphAction.isSelected())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ToggleActionBuilder("Reuse Graph", getName()).menuPath(MENU_GRAPH, "Reuse Graph")
.menuGroup("Graph Options")
.selected(reuseGraph)
.onAction(c -> reuseGraph = reuseGraphAction.isSelected())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
appendGraphAction =
new ToggleActionBuilder("Append Graph", getName())
.menuPath(MENU_GRAPH, "Append Graph")
.menuGroup("Graph Options")
.selected(false)
.onAction(c -> updateAppendAndReuseGraph())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
new ToggleActionBuilder("Append Graph", getName()).menuPath(MENU_GRAPH, "Append Graph")
.menuGroup("Graph Options")
.selected(false)
.onAction(c -> updateAppendAndReuseGraph())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
forceLocationVisibleAction = new ToggleActionBuilder("Show Location in Graph", getName())
.menuPath(MENU_GRAPH, "Show Location")
.description("Tell the graph to pan/scale as need to keep location changes visible")
.menuGroup("Graph Options")
.onAction(c -> toggleForceLocationVisible())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
.menuPath(MENU_GRAPH, "Show Location")
.description("Tell the graph to pan/scale as need to keep location changes visible")
.menuGroup("Graph Options")
.onAction(c -> toggleForceLocationVisible())
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
updateSubroutineActions();
}
@ -309,12 +302,12 @@ public class ProgramGraphPlugin extends ProgramPlugin
private DockingAction buildGraphActionWithModel(String blockModelName, HelpLocation helpLoc) {
return new ActionBuilder("Graph Calls using " + blockModelName, getName())
.menuPath(MENU_GRAPH, "Calls Using Model", blockModelName)
.menuGroup(MENU_GRAPH, "C")
.helpLocation(helpLoc)
.onAction(c -> createCallGraphUsing(blockModelName))
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
.menuPath(MENU_GRAPH, "Calls Using Model", blockModelName)
.menuGroup(MENU_GRAPH, "C")
.helpLocation(helpLoc)
.onAction(c -> createCallGraphUsing(blockModelName))
.enabledWhen(this::canGraph)
.buildAndInstall(tool);
}
private void graphBlockFlow() {
@ -349,10 +342,8 @@ public class ProgramGraphPlugin extends ProgramPlugin
try {
CodeBlockModel model =
blockModelService.getNewModelByName(modelName, currentProgram, true);
BlockGraphTask task =
new BlockGraphTask(graphType, graphEntryPointNexus,
reuseGraph, appendToGraph, tool, currentSelection, currentLocation, model,
defaultGraphService);
BlockGraphTask task = new BlockGraphTask(graphType, graphEntryPointNexus, reuseGraph,
appendToGraph, tool, currentSelection, currentLocation, model, defaultGraphService);
task.setCodeLimitPerBlock(codeLimitPerBlock);
new TaskLauncher(task, tool.getToolFrame());
}

View File

@ -19,11 +19,11 @@ import javax.swing.Icon;
import docking.ActionContext;
import docking.action.*;
import docking.options.OptionsService;
import generic.theme.GIcon;
import ghidra.feature.vt.gui.plugin.VTController;
import ghidra.feature.vt.gui.plugin.VTPlugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.util.HelpLocation;
public class VTMatchApplySettingsAction extends DockingAction {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.framework.plugintool.util;
package docking.options;
import ghidra.framework.options.Options;
import ghidra.framework.options.ToolOptions;

View File

@ -24,6 +24,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import docking.Tool;
import docking.options.OptionsService;
import docking.options.editor.*;
import generic.theme.GColor;
import generic.theme.Gui;
@ -38,8 +39,6 @@ import ghidra.util.bean.opteditor.OptionsVetoException;
*/
public class GraphDisplayOptions implements OptionsChangeListener {
public static final GraphDisplayOptions DEFAULT = new GraphDisplayOptions(new EmptyGraphType());
private static final String FONT = "Font";
private static final String LABEL_POSITION = "Label Position";
private static final String USE_ICONS = "Use Icons";
@ -96,7 +95,14 @@ public class GraphDisplayOptions implements OptionsChangeListener {
* @param graphType The {@link GraphType} for which to define display options
*/
public GraphDisplayOptions(GraphType graphType) {
this(graphType, null);
this.graphType = graphType;
rootOptionsName = graphType.getOptionsName();
List<String> edgeTypes = graphType.getEdgeTypes();
if (!edgeTypes.isEmpty()) {
favoredEdgeType = edgeTypes.iterator().next();
}
initializeEdgePriorities();
initializeDefaults();
}
/**
@ -106,15 +112,9 @@ public class GraphDisplayOptions implements OptionsChangeListener {
* @param graphType The {@link GraphType} for which to define display options
* @param tool the tool from which to initialize from {@link ToolOptions}
*/
public GraphDisplayOptions(GraphType graphType, Tool tool) {
this.graphType = graphType;
rootOptionsName = graphType.getOptionsName();
List<String> edgeTypes = graphType.getEdgeTypes();
if (!edgeTypes.isEmpty()) {
favoredEdgeType = edgeTypes.iterator().next();
}
initializeEdgePriorities();
initializeDefaults();
protected GraphDisplayOptions(GraphType graphType, Tool tool, HelpLocation help) {
this(graphType);
registerOptions(tool, help);
initializeFromOptions(tool);
}
@ -683,11 +683,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
* constructed. Otherwise, if the tool exits and this hasn't been called, any saved option
* values will be lost.
* <P>
* @param toolOptions the {@link ToolOptions} to register these options with
* @param tool The tool to use to register options
* @param help the help location to be used by the {@link OptionsDialog} for display/editing
* these options
*/
public void registerOptions(ToolOptions toolOptions, HelpLocation help) {
protected void registerOptions(Tool tool, HelpLocation help) {
ToolOptions toolOptions = tool.getOptions("Graph");
registerOptions(toolOptions, help);
}
protected void registerOptions(ToolOptions toolOptions, HelpLocation help) {
Options rootOptions = toolOptions.getOptions(graphType.getOptionsName());
registerVertexColorOptions(rootOptions, help);
registerVertexShapeOptions(rootOptions, help);
@ -695,6 +700,45 @@ public class GraphDisplayOptions implements OptionsChangeListener {
registerMiscellaneousOptions(rootOptions, help);
}
/**
* Pop up a dialog for editing these graph display options. If the options
* are registered with tool options, show the tool options with the appropriate
* graph options selected. Otherwise, show an editor for locally editing these
* options.
* @param tool the tool
* @param help the help location to use if the options are edited locally
*/
public void displayEditor(Tool tool, HelpLocation help) {
String startingPath = rootOptionsName + ".Vertex Colors";
// if the options are registered in the tool, just show the
// corresponding tool options
if (isRegisteredWithTool()) {
OptionsService service = tool.getService(OptionsService.class);
if (service != null) {
service.showOptionsDialog("Graph." + startingPath, "");
return;
}
}
// Otherwise, create a new empty options, register the graph options into the
// those options and use our options editor on those options to allow the
// user to change these graph display options.
ToolOptions transientOptions = new ToolOptions("Graph");
registerOptions(transientOptions, help);
transientOptions.addOptionsChangeListener(this);
Options[] optionsArray = new Options[] { transientOptions };
String dialogTitle = "Graph Instance Settings (Not Saved in Tool Options)";
OptionsDialog dialog = new OptionsDialog(dialogTitle, "Graph", optionsArray, null);
// we have one less level for these transient tool options, so no need to prepend "graph."
dialog.displayCategory(startingPath, "");
tool.showDialog(dialog);
dialog.dispose();
}
/**
* Sets default values for vertex types. This method does not allow the vertexType color to
* be eligible to be registered as a tool option.
@ -830,9 +874,8 @@ public class GraphDisplayOptions implements OptionsChangeListener {
for (String vertexType : graphType.getVertexTypes()) {
if (vertexRegistrations.containsKey(vertexType)) {
options.registerThemeColorBinding(vertexType,
vertexRegistrations.get(vertexType), help,
"Choose the color for this vertex type");
options.registerThemeColorBinding(vertexType, vertexRegistrations.get(vertexType),
help, "Choose the color for this vertex type");
}
}
List<String> list = new ArrayList<>(graphType.getVertexTypes());
@ -861,9 +904,8 @@ public class GraphDisplayOptions implements OptionsChangeListener {
for (String edgeType : graphType.getEdgeTypes()) {
if (edgeRegistrations.containsKey(edgeType)) {
options.registerThemeColorBinding(edgeType,
edgeRegistrations.get(edgeType),
help, "Choose the color for this edge type");
options.registerThemeColorBinding(edgeType, edgeRegistrations.get(edgeType), help,
"Choose the color for this edge type");
}
}
List<String> list = new ArrayList<>(graphType.getEdgeTypes());
@ -884,29 +926,29 @@ public class GraphDisplayOptions implements OptionsChangeListener {
if (defaultRegistrations.containsKey(VERTEX_SELECTION_COLOR)) {
optionNamesInDisplayOrder.add(VERTEX_SELECTION_COLOR);
options.registerThemeColorBinding(VERTEX_SELECTION_COLOR,
defaultRegistrations.get(VERTEX_SELECTION_COLOR),
help, "Color for highlighting selected vertices");
defaultRegistrations.get(VERTEX_SELECTION_COLOR), help,
"Color for highlighting selected vertices");
}
if (defaultRegistrations.containsKey(EDGE_SELECTION_COLOR)) {
optionNamesInDisplayOrder.add(EDGE_SELECTION_COLOR);
options.registerThemeColorBinding(EDGE_SELECTION_COLOR,
defaultRegistrations.get(EDGE_SELECTION_COLOR),
help, "Color for highlighting selected edge");
defaultRegistrations.get(EDGE_SELECTION_COLOR), help,
"Color for highlighting selected edge");
}
if (defaultRegistrations.containsKey(DEFAULT_VERTEX_COLOR)) {
optionNamesInDisplayOrder.add(DEFAULT_VERTEX_COLOR);
options.registerThemeColorBinding(DEFAULT_VERTEX_COLOR,
defaultRegistrations.get(DEFAULT_VERTEX_COLOR),
help, "Color for vertices that have no vertex type defined");
defaultRegistrations.get(DEFAULT_VERTEX_COLOR), help,
"Color for vertices that have no vertex type defined");
}
if (defaultRegistrations.containsKey(DEFAULT_EDGE_COLOR)) {
optionNamesInDisplayOrder.add(DEFAULT_EDGE_COLOR);
options.registerThemeColorBinding(DEFAULT_EDGE_COLOR,
defaultRegistrations.get(DEFAULT_EDGE_COLOR),
help, "Color for edge that have no edge type defined");
defaultRegistrations.get(DEFAULT_EDGE_COLOR), help,
"Color for edge that have no edge type defined");
}
optionNamesInDisplayOrder.add(DEFAULT_VERTEX_SHAPE);

View File

@ -271,10 +271,10 @@ public class GraphDisplayOptionsTest {
Options miscellaneousOptions = graphDisplayOptions.getOptions("Miscellaneous");
leafOptionNames = miscellaneousOptions.getLeafOptionNames();
assertEquals(Arrays.asList("Use Icons", "Max Graph Size",
"Selected Vertex Color", "Default Layout Algorithm", "Default Vertex Color",
"Default Vertex Shape", "Selected Edge Color", "Label Position",
"Default Edge Color", "Font", "Favored Edge Type"), leafOptionNames);
assertEquals(Arrays.asList("Use Icons", "Max Graph Size", "Selected Vertex Color",
"Default Layout Algorithm", "Default Vertex Color", "Default Vertex Shape",
"Selected Edge Color", "Label Position", "Default Edge Color", "Font",
"Favored Edge Type"), leafOptionNames);
}
@ -318,4 +318,5 @@ public class GraphDisplayOptionsTest {
}
}
}

View File

@ -37,6 +37,7 @@ import docking.actions.PopupActionProvider;
import docking.actions.ToolActions;
import docking.framework.AboutDialog;
import docking.framework.ApplicationInformationDisplayFactory;
import docking.options.OptionsService;
import docking.tool.ToolConstants;
import docking.tool.util.DockingToolConstants;
import docking.util.image.ToolIconURL;

View File

@ -23,6 +23,7 @@ import javax.swing.tree.TreePath;
import org.jdom.Element;
import docking.options.OptionsService;
import docking.options.editor.OptionsDialog;
import docking.tool.ToolConstants;
import docking.tool.util.DockingToolConstants;
@ -30,7 +31,6 @@ import ghidra.framework.options.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.dialog.KeyBindingsPanel;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.exception.AssertException;

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.junit.Test;
import docking.options.OptionsService;
import ghidra.GhidraOptions;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.colorizer.ColorizingService;
@ -33,7 +34,6 @@ import ghidra.app.util.viewer.listingpanel.ListingPanel;
import ghidra.app.util.viewer.listingpanel.MarginProvider;
import ghidra.framework.options.Options;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.block.*;

View File

@ -32,6 +32,7 @@ import docking.StatusBar;
import docking.action.DockingActionIf;
import docking.actions.KeyEntryDialog;
import docking.actions.ToolActions;
import docking.options.OptionsService;
import docking.tool.ToolConstants;
import docking.widgets.OptionDialog;
import docking.widgets.table.GTable;
@ -44,7 +45,6 @@ import ghidra.framework.cmd.BackgroundCommand;
import ghidra.framework.main.PickToolDialog;
import ghidra.framework.model.DomainObject;
import ghidra.framework.plugintool.dialog.PluginInstallerDialog;
import ghidra.framework.plugintool.util.OptionsService;
import ghidra.test.TestEnv;
import ghidra.util.task.TaskDialog;
import ghidra.util.task.TaskMonitor;