@Override public List<Completion> getCompletions(JTextComponent comp) { List<Completion> completions = getCompletionsImpl(comp); if (parent!=null) { List<Completion> parentCompletions = parent.getCompletions(comp); if (parentCompletions!=null) { completions.addAll(parentCompletions); Collections.sort(completions); } } // NOTE: We can't sort by relevance prior to this; we need to have // things alphabetical so we can easily narrow down completions to // those starting with what was already typed. if (/*sortByRelevance*/true) { Collections.sort(completions, SORT_BY_RELEVANCE_COMPARATOR); } return completions; }
/** * {@inheritDoc} */ @Override public boolean isAutoActivateOkay(JTextComponent tc) { boolean ok = super.isAutoActivateOkay(tc); // In our constructor, we set up auto-activation of the completion // popup to occur on space chars. This extra check makes it a little // more sane, by only letting space auto-activate completion choices // for property values. if (ok) { RSyntaxDocument doc = (RSyntaxDocument)tc.getDocument(); int dot = tc.getCaretPosition(); try { if (dot>1 && doc.charAt(dot)==' ') { // Caret hasn't advanced (?) ok = doc.charAt(dot-1)==':'; } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } return ok; }