Shows or hides a popup menu with input completions.
()
| 149 | * Shows or hides a popup menu with input completions. |
| 150 | */ |
| 151 | private void popupMenu() { |
| 152 | final String query = getText(); |
| 153 | |
| 154 | StringList list = null; |
| 155 | if(textField().getCaretPosition() == query.length()) { |
| 156 | final Data data = gui.context.data(); |
| 157 | if(queryMode() && data != null) { |
| 158 | try(QueryContext qc = new QueryContext(gui.context)) { |
| 159 | list = qc.suggest(query, data); |
| 160 | } |
| 161 | } else if(cmdMode()) { |
| 162 | list = CommandParser.get(query, gui.context).suggest(); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if(list != null) { |
| 167 | prefix = list.pop(); |
| 168 | createCombo(list); |
| 169 | } else { |
| 170 | popup.setVisible(false); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Creates and shows the combo box. |