reset controls on reopen

This commit is contained in:
Greg DiCristofaro 2020-07-10 13:38:01 -04:00
parent e082c4f376
commit 84179456c0

View File

@ -60,7 +60,6 @@ public final class PersonasTopComponent extends TopComponent {
private List<Persona> currentResults = null; private List<Persona> currentResults = null;
private Persona selectedPersona = null; private Persona selectedPersona = null;
/** /**
* Listens for when this component will be rendered and executes a search to * Listens for when this component will be rendered and executes a search to
* update gui when it is displayed. * update gui when it is displayed.
@ -68,7 +67,8 @@ public final class PersonasTopComponent extends TopComponent {
private final AncestorListener onAddListener = new AncestorListener() { private final AncestorListener onAddListener = new AncestorListener() {
@Override @Override
public void ancestorAdded(AncestorEvent event) { public void ancestorAdded(AncestorEvent event) {
setKeywordSearchEnabled(false); resetSearchControls();
setKeywordSearchEnabled(false, true);
} }
@Override @Override
@ -82,14 +82,12 @@ public final class PersonasTopComponent extends TopComponent {
} }
}; };
@Messages({ @Messages({
"PersonasTopComponent_Name=Personas", "PersonasTopComponent_Name=Personas",
"PersonasTopComponent_delete_exception_Title=Delete failure", "PersonasTopComponent_delete_exception_Title=Delete failure",
"PersonasTopComponent_delete_exception_msg=Failed to delete persona.", "PersonasTopComponent_delete_exception_msg=Failed to delete persona.",
"PersonasTopComponent_delete_confirmation_Title=Are you sure?", "PersonasTopComponent_delete_confirmation_Title=Are you sure?",
"PersonasTopComponent_delete_confirmation_msg=Are you sure you want to delete this persona?", "PersonasTopComponent_delete_confirmation_msg=Are you sure you want to delete this persona?",})
})
public PersonasTopComponent() { public PersonasTopComponent() {
initComponents(); initComponents();
setName(Bundle.PersonasTopComponent_Name()); setName(Bundle.PersonasTopComponent_Name());
@ -188,8 +186,24 @@ public final class PersonasTopComponent extends TopComponent {
} }
} }
private void setKeywordSearchEnabled(boolean selected) { /**
if (cbFilterByKeyword.isSelected() != selected) { * Resets search controls to default state.
*/
private void resetSearchControls() {
searchField.setText("");
searchNameRadio.setSelected(true);
searchAccountRadio.setSelected(false);
}
/**
* Sets up the GUI for appropriate state for keyword search enabled state.
*
* @param selected Whether or not keyword search is enabled.
* @param setFilterCb Whether or not the filter checkbox should be
* manipulated as a part of this change.
*/
private void setKeywordSearchEnabled(boolean selected, boolean setFilterCb) {
if (setFilterCb && cbFilterByKeyword.isSelected() != selected) {
cbFilterByKeyword.setSelected(selected); cbFilterByKeyword.setSelected(selected);
} }
@ -284,8 +298,7 @@ public final class PersonasTopComponent extends TopComponent {
} else { } else {
results = Persona.getPersonaByAccountIdentifierLike(searchField.getText()); results = Persona.getPersonaByAccountIdentifierLike(searchField.getText());
} }
} } else {
else {
results = Persona.getPersonaByName(""); results = Persona.getPersonaByName("");
} }
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
@ -466,7 +479,7 @@ public final class PersonasTopComponent extends TopComponent {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void cbFilterByKeywordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbFilterByKeywordActionPerformed private void cbFilterByKeywordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbFilterByKeywordActionPerformed
setKeywordSearchEnabled(cbFilterByKeyword.isSelected()); setKeywordSearchEnabled(cbFilterByKeyword.isSelected(), false);
}//GEN-LAST:event_cbFilterByKeywordActionPerformed }//GEN-LAST:event_cbFilterByKeywordActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables