GP-4261 - Version Tracking - Fixed 'Unregistered Option' tooltip

This commit is contained in:
dragonmacher
2024-08-05 19:00:10 -04:00
parent 4737bbfc5d
commit ed8f22d47c
2 changed files with 26 additions and 6 deletions

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.
@@ -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;
}
}

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.
@@ -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) {