used component listener so that only one event fired per open

This commit is contained in:
Greg DiCristofaro 2020-07-16 08:31:17 -04:00
parent d57e0df831
commit 1e749e5e53

View File

@ -20,6 +20,8 @@ package org.sleuthkit.autopsy.centralrepository.persona;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -60,28 +62,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
* update gui when it is displayed.
*/
private final AncestorListener onAddListener = new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
resetSearchControls();
setKeywordSearchEnabled(false, true);
}
@Override
public void ancestorRemoved(AncestorEvent event) {
//Empty
}
@Override
public void ancestorMoved(AncestorEvent event) {
//Empty
}
};
@Messages({ @Messages({
"PersonasTopComponent_Name=Personas", "PersonasTopComponent_Name=Personas",
"PersonasTopComponent_delete_exception_Title=Delete failure", "PersonasTopComponent_delete_exception_Title=Delete failure",
@ -165,7 +145,17 @@ public final class PersonasTopComponent extends TopComponent {
} }
}); });
addAncestorListener(onAddListener); /**
* Listens for when this component will be rendered and executes a
* search to update gui when it is displayed.
*/
addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
resetSearchControls();
setKeywordSearchEnabled(false, true);
}
});
} }
/** /**