Refine search
@Override public void defaultAction(JTextComponent component) { if (component != null) { Completion.get().hideDocumentation(); Completion.get().hideCompletion(); int caretOffset = component.getSelectionEnd(); substituteText(component, substitutionOffset, caretOffset - substitutionOffset); } }
@Override public void run() { Completion.get().showCompletion(); } }, 50, TimeUnit.MILLISECONDS);
@Override public void defaultAction(JTextComponent component) { Completion completion = Completion.get(); completion.hideCompletion(); completion.hideDocumentation(); defaultAction(component, ""); }
@Override protected boolean canFilter(JTextComponent component) { int caretOffset = component.getCaretPosition(); filterPrefix = null; if (queryAnchorOffset > -1 && caretOffset >= queryAnchorOffset) { Document doc = component.getDocument(); try { filterPrefix = doc.getText(queryAnchorOffset, caretOffset - queryAnchorOffset); } catch (BadLocationException ex) { Completion.get().hideCompletion(); } } else { Completion.get().hideCompletion(); } return filterPrefix != null; }
if (b != null) { int s, e; final BaseDocument doc = (BaseDocument)txt.getDocument(); if (txt.getSelectionStart() == txt.getSelectionEnd()) { Completion.get().showCompletion();
public void defaultAction (JTextComponent component) { NbEditorDocument doc = (NbEditorDocument) component.getDocument (); int offset = component.getCaret ().getDot (); boolean isMethod = type == CompletionItem.Type.METHOD || type == CompletionItem.Type.CONSTRUCTOR; try { component.setCaretPosition(component.getCaret ().getDot () - 1); Completion.get ().hideAll ();
public int getAutoQueryTypes(JTextComponent component, String typedText) { if (!autoPopup) { return 0; } if (typedText.length() > 0) { CodeCompletionHandler provider = getCompletable(component.getDocument(), component.getCaretPosition()); if (provider != null) { QueryType autoQuery = provider.getAutoQuery(component, typedText); switch (autoQuery) { case NONE: return 0; case STOP: { Completion.get().hideAll(); return 0; } case COMPLETION: return COMPLETION_QUERY_TYPE; case DOCUMENTATION: return DOCUMENTATION_QUERY_TYPE; case TOOLTIP: return TOOLTIP_QUERY_TYPE; case ALL_COMPLETION: return COMPLETION_ALL_QUERY_TYPE; } } } return 0; }
@Override protected void preQueryUpdate(JTextComponent component) { int newCaretOffset = component.getSelectionStart(); if (newCaretOffset >= caretOffset) { try { Document doc = component.getDocument(); Language language = getCompletableLanguage(doc, caretOffset); if (isJavaIdentifierPart(language, doc.getText(caretOffset, newCaretOffset - caretOffset))) { return; } } catch (BadLocationException e) { } } Completion.get().hideCompletion(); }
@Override public void defaultAction(JTextComponent jtc) { try { StyledDocument doc = (StyledDocument) jtc.getDocument(); //Here we remove the characters starting at the start offset //and ending at the point where the caret is currently found: doc.remove(dotOffset, caretOffset - dotOffset); doc.insertString(dotOffset, getText(), null); //This statement will close the code completion box: Completion.get().hideAll(); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } }
public void actionPerformed(@SuppressWarnings("unused") final ActionEvent evt, final JTextComponent txt) { final ProjectConfigurationProvider prov = J2MEProjectUtils.getConfigProviderForDoc(txt.getDocument()); if (prov == null) return; NbDocument.runAtomic((StyledDocument)txt.getDocument(), new Runnable() { public void run() { try { final BaseDocument doc = (BaseDocument)txt.getDocument(); final int s = Utilities.getRowStartFromLineOffset(doc, getSelectionStartLine(txt) - 1); final int e = Utilities.getRowEnd(txt, Utilities.getRowStartFromLineOffset(doc, getSelectionEndLine(txt) - 1)); final String text = doc.getText(s, e-s); doc.insertString(e, "\n//#else\n" + text + "\n//#endif", null); //NOI18N doc.insertString(s, "//#if \n", null); //NOI18N txt.setSelectionStart(s + 6); txt.setSelectionEnd(s + 6); } catch (BadLocationException ble) { ErrorManager.getDefault().notify(ble); } RecommentAction.actionPerformed(txt); } }); Completion.get().showCompletion(); } }
private void defaultSubstituteText(final JTextComponent c, final int offset, final int len, String toAdd) { final String template = item.getCustomInsertTemplate(); if (template != null) { final BaseDocument doc = (BaseDocument)c.getDocument(); final CodeTemplateManager ctm = CodeTemplateManager.get(doc); if (ctm != null) { Completion.get().showToolTip();
public void defaultAction(JTextComponent component) { if (component != null) { // Items with no insert prefix and no custom code template // are "read-only" (such as the method call items) if (getInsertPrefix().length() == 0) { return; } Completion.get().hideAll(); int caretOffset = component.getSelectionEnd(); substituteText(component, substitutionOffset, caretOffset - substitutionOffset, null); } }
public void processKeyEvent(final KeyEvent event) { if (event.getKeyChar()==' ' && !event.isControlDown()) { Completion.get().hideCompletion(); } }
@Override public String getInsertPrefix() { Completion.get().showToolTip(); return getName(); }
@Override protected boolean canFilter(JTextComponent component) { int caretOffset = component.getCaretPosition(); filterPrefix = null; if (queryAnchorOffset > -1 && caretOffset >= queryAnchorOffset) { Document doc = component.getDocument(); try { filterPrefix = doc.getText(queryAnchorOffset, caretOffset - queryAnchorOffset); } catch (BadLocationException ex) { Completion.get().hideCompletion(); } } else { Completion.get().hideCompletion(); } return filterPrefix != null; }
@Override public void defaultAction(JTextComponent jtc) { try { StyledDocument doc = (StyledDocument) jtc.getDocument(); Completion.get().hideAll(); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex);
@Override public void defaultAction(JTextComponent component) { Completion completion = Completion.get(); completion.hideCompletion(); completion.hideDocumentation(); defaultAction(component, ""); }
protected void query(final CompletionResultSet resultSet, @SuppressWarnings("unused") final Document doc, final int caretOffset) { try { final int ancor = Utilities.getPreviousWord(this.component, caretOffset); final PPToken tok = new PreprocessorScanner(new StringReader(org.netbeans.modules.mobility.editor.Utilities.getLine(this.component))).nextToken(); if (canFilter(this.component)) { this.ancor = ancor; resultSet.setTitle(NbBundle.getMessage(PPCompletionProvider.class, "DESC_TITLE_VAR_CC")); resultSet.setAnchorOffset(ancor); //see what the previous directive word is and offer completion items accordingly if (tok.getType() == LineParserTokens.COMMAND_DEBUG || tok.getType() == LineParserTokens.COMMAND_MDEBUG) resultSet.addAllItems(getFilteredData(this.debugItems, filterPrefix)); else resultSet.addAllItems(getFilteredData(this.variableItems, filterPrefix)); } else Completion.get().hideCompletion(); } catch (BadLocationException ble) { } catch (IOException ioe) { } resultSet.finish(); }