Merge remote-tracking branch 'origin/GP-2780-dragonmacher-fixed-options-name-with-dot' into patch

This commit is contained in:
Ryan Kurtz
2022-11-03 10:50:47 -04:00
3 changed files with 14 additions and 6 deletions
@@ -65,7 +65,8 @@ import resources.ResourceManager;
import resources.icons.RotateIcon; import resources.icons.RotateIcon;
public interface DebuggerResources { public interface DebuggerResources {
String OPTIONS_CATEGORY_WORKFLOW = "Debugger.Workflow"; String OPTIONS_CATEGORY_DEBUGGER = "Debugger";
String OPTIONS_CATEGORY_WORKFLOW = "Workflow";
ImageIcon ICON_DEBUGGER = ResourceManager.loadImage("images/debugger.png"); ImageIcon ICON_DEBUGGER = ResourceManager.loadImage("images/debugger.png");
@@ -128,7 +128,7 @@ public class DebuggerWorkflowServicePlugin extends Plugin
/* testing */ final List<DebuggerBot> allBots = new ArrayList<>(); /* testing */ final List<DebuggerBot> allBots = new ArrayList<>();
// Cannot auto-wire, since they're dynamically populated // Cannot auto-wire, since they're dynamically populated
private final ToolOptions options; private final Options options;
@SuppressWarnings("hiding") // I'm FrontEndOnly @SuppressWarnings("hiding") // I'm FrontEndOnly
protected final FrontEndTool tool; protected final FrontEndTool tool;
@@ -140,8 +140,9 @@ public class DebuggerWorkflowServicePlugin extends Plugin
this.tool = (FrontEndTool) tool; // I'm FrontEndOnly this.tool = (FrontEndTool) tool; // I'm FrontEndOnly
this.autoServiceWiring = AutoService.wireServicesProvidedAndConsumed(this); this.autoServiceWiring = AutoService.wireServicesProvidedAndConsumed(this);
this.options = tool.getOptions(DebuggerResources.OPTIONS_CATEGORY_WORKFLOW); ToolOptions rootOptions = tool.getOptions(DebuggerResources.OPTIONS_CATEGORY_DEBUGGER);
this.options.addOptionsChangeListener(this); rootOptions.addOptionsChangeListener(this);
this.options = rootOptions.getOptions(DebuggerResources.OPTIONS_CATEGORY_WORKFLOW);
} }
@@ -33,6 +33,7 @@ import ghidra.framework.plugintool.dialog.KeyBindingsPanel;
import ghidra.framework.plugintool.util.OptionsService; import ghidra.framework.plugintool.util.OptionsService;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.AssertException;
/** /**
* Created by PluginTool to manage the set of Options for each category. * Created by PluginTool to manage the set of Options for each category.
@@ -61,6 +62,12 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
@Override @Override
public ToolOptions getOptions(String category) { public ToolOptions getOptions(String category) {
if (category.contains(Options.DELIMITER_STRING)) {
throw new AssertException(
"Options category cannot contain the options path delimiter '" + Options.DELIMITER +
"'");
}
ToolOptions opt = optionsMap.get(category); ToolOptions opt = optionsMap.get(category);
if (opt == null) { if (opt == null) {
opt = new ToolOptions(category); opt = new ToolOptions(category);
@@ -245,8 +252,7 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
} }
private void removeUnusedOptions(List<String> deleteList) { private void removeUnusedOptions(List<String> deleteList) {
for (int i = 0; i < deleteList.size(); i++) { for (String name : deleteList) {
String name = deleteList.get(i);
ToolOptions options = optionsMap.remove(name); ToolOptions options = optionsMap.remove(name);
options.removeOptionsChangeListener(this); options.removeOptionsChangeListener(this);
} }