OAuth2ScriptsEditor extends JPanel { void selectField(InputPanel field) { selectedInputField = field; for (InputPanel inputPanel : inputPanels) { if (inputPanel == field) { inputPanel.highlight(); } else { inputPanel.removeHighlight(); } } removeScriptButton.setEnabled(selectedInputField != null); } OAuth2ScriptsEditor(final OAuth2Profile profile); List<String> getJavaScripts();  }
@Test public void disablesRemoveButtonAfterRemoval() throws Exception { editor.selectField(containerWalker.findComponent("Input panel 2", OAuth2ScriptsEditor.InputPanel.class)); stubbedDialogs.mockConfirmWithReturnValue(true); AbstractButton removeButton = containerWalker.findButtonWithName(OAuth2ScriptsEditor.REMOVE_SCRIPT_BUTTON_NAME); removeButton.doClick(); assertThat(removeButton, is(not(enabled()))); }
@Test public void removeButtonEnabledOnlyWhenPanelIsSelected() throws Exception { assertThat(containerWalker.findButtonWithName(OAuth2ScriptsEditor.REMOVE_SCRIPT_BUTTON_NAME), is(not(enabled()))); editor.selectField(containerWalker.findComponent("Input panel 2", OAuth2ScriptsEditor.InputPanel.class)); assertThat(containerWalker.findButtonWithName(OAuth2ScriptsEditor.REMOVE_SCRIPT_BUTTON_NAME), is(enabled())); }