GP-0 correct AnalysisOptionsTest failures

This commit is contained in:
ghidra1 2021-04-27 09:21:33 -04:00
parent 43476f2e20
commit 4e16b3aa3a
2 changed files with 16 additions and 2 deletions

View File

@ -29,7 +29,7 @@ import org.junit.*;
import docking.action.DockingActionIf;
import docking.widgets.OptionDialog;
import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.dialogs.InputDialog;
import docking.widgets.dialogs.InputWithChoicesDialog;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.services.ProgramManager;
import ghidra.framework.Application;
@ -276,7 +276,7 @@ public class AnalysisOptionsTest extends AbstractGhidraHeadedIntegrationTest {
}
private void saveConfig(String name) {
InputDialog dialog = waitForDialogComponent(InputDialog.class);
InputWithChoicesDialog dialog = waitForDialogComponent(InputWithChoicesDialog.class);
runSwing(() -> dialog.setValue(name));
pressButtonByText(dialog, "OK");
waitForSwing();

View File

@ -17,6 +17,7 @@ package docking.widgets.dialogs;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.NoSuchElementException;
import javax.swing.*;
@ -182,4 +183,17 @@ public class InputWithChoicesDialog extends DialogComponentProvider {
Object selectedItem = combo.getSelectedItem();
return selectedItem == null ? null : selectedItem.toString();
}
/**
* Set the current choice to value.
* @param value updated choice
* @throws NoSuchElementException if choice does not permit edits and value is
* not a valid choice.
*/
public void setValue(String value) {
combo.setSelectedItem(value);
if (!combo.isEditable() && !combo.getSelectedItem().equals(value)) {
throw new NoSuchElementException();
}
}
}