From ed8f22d47c60fc42dc0a32ccb9c737772d3cc147 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Mon, 5 Aug 2024 19:00:10 -0400 Subject: [PATCH] GP-4261 - Version Tracking - Fixed 'Unregistered Option' tooltip --- .../ghidra/feature/vt/api/util/VTOptions.java | 20 ++++++++++++++++--- .../java/ghidra/framework/options/Option.java | 12 ++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java index b026f6fc04..f14eb59018 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/util/VTOptions.java @@ -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. @@ -17,7 +17,7 @@ package ghidra.feature.vt.api.util; import org.jdom.Element; -import ghidra.framework.options.ToolOptions; +import ghidra.framework.options.*; public class VTOptions extends ToolOptions { @@ -42,4 +42,18 @@ public class VTOptions extends ToolOptions { public boolean validate() { return true; } + + @Override + public String getDescription(String optionName) { + Option option = getOption(optionName, OptionType.NO_TYPE, null); + String description = option.getDescription(); + + // Correlator factories may create an options object and set values without ever having + // registered the option. Ideally we would update the VTOptions usage to make sure the + // options are all registered. This check here is an easier fix. + if (description.equals(Option.UNREGISTERED_OPTION)) { + return option.getName(); + } + return description; + } } diff --git a/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/Option.java b/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/Option.java index 90c3c293b1..580ee354c2 100644 --- a/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/Option.java +++ b/Ghidra/Framework/Gui/src/main/java/ghidra/framework/options/Option.java @@ -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. @@ -23,6 +23,8 @@ import ghidra.util.SystemUtilities; import utilities.util.reflection.ReflectionUtilities; public abstract class Option { + public static final String UNREGISTERED_OPTION = "Unregistered Option"; + private final String name; private Object defaultValue; private boolean isRegistered; @@ -89,7 +91,11 @@ public abstract class Option { } public String getDescription() { - return description == null ? "Unregistered Option" : description; + // 'Unregistered Option' is returned when an option was never registered. It can also be + // returned when an option value was set, but the option itself was never registered. In + // that case, the isRegistered value is set to true, which means that a client has accessed + // the option. + return description == null ? UNREGISTERED_OPTION : description; } public Object getValue(Object passedInDefaultValue) {