GT-2801: fixed analysis options bug causing apply button to not be

activated
This commit is contained in:
adamopolous 2019-04-17 12:29:47 -04:00
parent 227be22a1f
commit 59fb950c79

View File

@ -33,6 +33,7 @@ import org.apache.commons.collections4.CollectionUtils;
import docking.options.editor.GenericOptionsComponent; import docking.options.editor.GenericOptionsComponent;
import docking.widgets.OptionDialog; import docking.widgets.OptionDialog;
import docking.widgets.table.*; import docking.widgets.table.*;
import ghidra.GhidraOptions;
import ghidra.app.services.Analyzer; import ghidra.app.services.Analyzer;
import ghidra.framework.options.*; import ghidra.framework.options.*;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
@ -465,20 +466,27 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
checkForDifferences(); if (checkForDifferences()) {
propertyChangeListener.propertyChange(
new PropertyChangeEvent(this, GhidraOptions.APPLY_ENABLED, null, Boolean.TRUE));
}
} }
private boolean checkForDifferences() { private boolean checkForDifferences() {
boolean changes = false;
for (int i = 0; i < analyzerNames.size(); ++i) { for (int i = 0; i < analyzerNames.size(); ++i) {
String analyzerName = analyzerNames.get(i); String analyzerName = analyzerNames.get(i);
boolean currEnabled = analyzerEnablement.get(i); boolean currEnabled = analyzerEnablement.get(i);
boolean origEnabled = analysisOptions.getBoolean(analyzerName, false); boolean origEnabled = analysisOptions.getBoolean(analyzerName, false);
if (currEnabled != origEnabled) { if (currEnabled != origEnabled) {
changes = true;
propertyChangeListener.propertyChange( propertyChangeListener.propertyChange(
new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled)); new PropertyChangeEvent(this, analyzerName, origEnabled, currEnabled));
return true;
} }
} }
if (changes) {
return true;
}
for (EditorState info : editorList) { for (EditorState info : editorList) {
if (info.isValueChanged()) { if (info.isValueChanged()) {
return true; return true;
@ -602,21 +610,18 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
*/ */
public void updateOptionForAllPrograms(String analyzerName, boolean enabled) { public void updateOptionForAllPrograms(String analyzerName, boolean enabled) {
for (Program program : programs) { for (Program program : programs) {
// Check to make sure we're only handling events that relate to analyzers. If we
// receive something else (eg: "analyze.apply") ignore it.
Options options = program.getOptions(Program.ANALYSIS_PROPERTIES);
if (!options.getOptionNames().contains(analyzerName)) {
continue;
}
boolean commit = false; boolean commit = false;
int id = program.startTransaction("Setting analysis property"); int id = program.startTransaction("Setting analysis property " + analyzerName);
try { try {
Options options = program.getOptions(Program.ANALYSIS_PROPERTIES);
// Sanity check to make sure that the analyzer is appropriate for
// this program. This should always be the case but it doesn't
// hurt to check.
if (!options.getOptionNames().contains(analyzerName)) {
continue;
}
options.setBoolean(analyzerName, enabled); options.setBoolean(analyzerName, enabled);
commit = true; commit = true;
} }
finally { finally {
@ -624,5 +629,4 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener {
} }
} }
} }
} }