/**
* Completes the steps necessary to properly close the CodeGemPanel autocomplete popup
*/
void closeAutoCompletePopup() {
// when the panel is closed, then we want to complete the proper user actions
IntellicutListEntry selected = autoCompletePopup.getSelected();
JTextComponent calEditor = editor.getEditorComponent();
// Close before doing anything else, so that the ui doesn't try to update the popup appearance for any string insertion.
autoCompletePopup.setVisible(false);
// if the user commited, then 'selected' is not null
if (selected != null) {
String insertion = selected.getSourceText();
int userInputLength = autoCompletePopup.getUserInputQualifiedNameLength();
// removes the user's portion of the to-be completed work to fix case errors
// eg. User types "Hou", then hit Ctrl-Space. Then we replace "Hou" with "hour"
editor.insertAutoCompleteString(userInputLength, insertion);