Executes the input of the GUIInput bar.
()
| 311 | * Executes the input of the {@link GUIInput} bar. |
| 312 | */ |
| 313 | void execute() { |
| 314 | final String in = input.getText().trim(); |
| 315 | final boolean cmd = mode.getSelectedIndex() == 2; |
| 316 | // run as command: command mode or exclamation mark as first character |
| 317 | final boolean exc = Strings.startsWith(in, '!'); |
| 318 | if(cmd || exc) { |
| 319 | try { |
| 320 | // parse and execute all commands |
| 321 | final CommandParser cp = CommandParser.get(in.substring(exc ? 1 : 0), context); |
| 322 | if(pwReader == null) pwReader = () -> { |
| 323 | final DialogPass dp = new DialogPass(this); |
| 324 | return dp.ok() ? dp.password() : ""; |
| 325 | }; |
| 326 | cp.pwReader(pwReader); |
| 327 | execute(cp.parse()); |
| 328 | } catch(final QueryException ex) { |
| 329 | if(!info.visible()) GUIMenuCmd.C_SHOW_INFO.execute(this); |
| 330 | info.setInfo(Util.message(ex), null, false, true); |
| 331 | } |
| 332 | } else if(gopts.get(GUIOptions.SEARCHMODE) == 1 || Strings.startsWith(in, '/')) { |
| 333 | simpleQuery(in); |
| 334 | } else { |
| 335 | execute(new Find(in)); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * Launches a simple single-line query. Adds the default namespace if available. |