Ejemplo n.º 1
0
  private void initCommandCompletion() {

    //
    // init: Command Completion
    //
    CompletionInterfaceAbstract _cmdComplete_provider =
        new CompletionInterfaceAbstract(this.rgui) {

          public String getText() {
            return commandInputField.getText();
          }

          public int getCaretPosition() {
            return commandInputField.getCaretPosition();
          }

          public void setText(String text) {
            commandInputField.setText(text);
          }

          public void setCaretPosition(int pos) {
            commandInputField.setCaretPosition(pos);
          }

          public void closePopup() {
            cmdComplete.closePopups();
          }

          public boolean canShow() {
            return (!cmdSearch.isActive());
          }
        };

    // init popup components
    cmdComplete = new CompletionSupport("Completion", commandInputField, _cmdComplete_provider);

    cmdComplete.setAppearanceOption(CompletionSupport.APPEARS_ABOVE);

    // assign control hotkeys
    //

    cmdComplete.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_ENTER, 0), CompletionSupport.SELECT);

    cmdComplete.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_TAB, 0), CompletionSupport.COMPLETE);

    cmdComplete.bindKeyAction(
        KeyUtil.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK), CompletionSupport.COMPLETE);

    cmdComplete.bindKeyAction(
        KeyUtil.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CompletionSupport.CANCEL);

    cmdComplete.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_UP, 0), CompletionSupport.SCROLL_UP);

    cmdComplete.bindKeyAction(
        KeyUtil.getKeyStroke(KeyEvent.VK_DOWN, 0), CompletionSupport.SCROLL_DOWN);
  }
Ejemplo n.º 2
0
 @Override
 public boolean isInputLocked() {
   return (cmdSearch.isActive() || cmdComplete.isActive());
 }
Ejemplo n.º 3
0
  private void initCommandSearch() {
    // init: Command History Search
    //
    CompletionInterface _cmdSearch_provider =
        new CompletionInterface() {
          public CompletionResult provideResult() {
            // provide command history
            Vector<String> history = getCommandHistory();

            int size = history.size();
            CompletionResult result = new CompletionResult();

            for (int i = size - 1; i >= 0; i--) {
              result.add(new CompletionItem(history.get(i), "command"));
            }

            return result;
          }

          public String providePattern() {
            return (commandInputField.getText());
          }

          public void acceptResult(final String string, final int offset) {
            commandInputField.setText(string);

            if (offset != 0) {
              commandInputField.setCaretPosition(commandInputField.getCaretPosition() + offset);
            }
          }

          public void makeAddition(final String string) {
            commandInputField.setText(string);
          }

          public boolean canShow() {
            return (!cmdComplete.isActive());
          }

          public void handlePopupShowed() {}

          public void handlePopupClosed() {}
        };

    cmdSearch = new CompletionSupport("History Search", commandInputField, _cmdSearch_provider);

    cmdSearch.setAppearanceOption(CompletionSupport.APPEARS_ABOVE);

    cmdSearch.setFilter(CompletionSupport.FREETEXT_FILTER);

    cmdSearch.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_ENTER, 0), CompletionSupport.SELECT);

    cmdSearch.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_TAB, 0), CompletionSupport.COMPLETE);

    cmdSearch.bindKeyAction(
        KeyUtil.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK), CompletionSupport.COMPLETE);

    cmdSearch.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CompletionSupport.CANCEL);

    cmdSearch.bindKeyAction(KeyUtil.getKeyStroke(KeyEvent.VK_UP, 0), CompletionSupport.SCROLL_UP);

    cmdSearch.bindKeyAction(
        KeyUtil.getKeyStroke(KeyEvent.VK_DOWN, 0), CompletionSupport.SCROLL_DOWN);
  }
Ejemplo n.º 4
0
 public void handleComponentResized() {
   cmdSearch.handleComponentResized();
   cmdComplete.handleComponentResized();
 }