本文整理汇总了Java中org.netbeans.api.editor.completion.Completion类的典型用法代码示例。如果您正苦于以下问题:Java Completion类的具体用法?Java Completion怎么用?Java Completion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Completion类属于org.netbeans.api.editor.completion包,在下文中一共展示了Completion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
protected void filter(CompletionResultSet resultSet) {
try {
if ((queryType & COMPLETION_QUERY_TYPE) != 0) {
if (results != null) {
if (filterPrefix != null) {
resultSet.addAllItems(getFilteredData(results, filterPrefix));
resultSet.setHasAdditionalItems(hasAdditionalItems > 0);
} else {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
}
resultSet.setAnchorOffset(anchorOffset);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
resultSet.finish();
}
示例2: processKeyEvent
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
Completion completion = Completion.get();
switch (evt.getKeyChar()) {
case ' ':
if (evt.getModifiers() == 0) {
completion.hideCompletion();
completion.hideDocumentation();
}
break;
// case ';': //TODO, can special handling be added even if we press these buttons within a literal?
// case ',':
// case '(':
// completion.hideCompletion();
// completion.hideDocumentation();
// case '.':
// if (defaultAction((JTextComponent) evt.getSource(), Character.toString(evt.getKeyChar()))) {
// evt.consume();
// break;
// }
}
}
}
示例3: postPreparedItems
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
/**
* Invokes the CC in the AWT thread and records items which should be displayed.
* The recorded items will be fetched in the completion query and if still valid,
* displayed without any model computation.
*
* @param doc document for the completion
* @param offset offset for which the items were completed
* @param items completion items
*/
private static void postPreparedItems(Document doc, int offset, List<CompletionResultItem> items) {
PreparedResults res = new PreparedResults(offset, items);
synchronized (preparedCompletions) {
PreparedResults r1 = preparedCompletions.get(doc);
LOG.log(Level.FINE, "Prepared results: {0}", r1);
if (r1 != null && r1.accept(offset)) {
LOG.log(Level.FINE, "Will re-invoke completion for {0} items", items.size());
preparedCompletions.put(doc, res);
} else {
LOG.log(Level.FINE, "Task has been obsoleted, ignoring");
return;
}
}
// schedule completion appearance
Completion.get().showCompletion();
}
示例4: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void defaultAction (
final JTextComponent component
) {
Completion.get ().hideCompletion ();
Completion.get ().hideDocumentation ();
Document document = component.getDocument ();
DataObject dataObject = (DataObject) document.getProperty (Document.StreamDescriptionProperty);
FileObject fileObject = dataObject.getPrimaryFile ();
Project project = FileOwnerQuery.getOwner (fileObject);
Locale locale = LocaleQuery.findLocale(fileObject);
DictionaryImpl dictionary = projects && project != null ?
ComponentPeer.getProjectDictionary (project, locale) :
ComponentPeer.getUsersLocalDictionary (locale);
dictionary.addEntry (word);
ComponentPeer componentPeer = (ComponentPeer) component.getClientProperty (ComponentPeer.class);
componentPeer.reschedule();
}
示例5: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void defaultAction(final JTextComponent component) {
Completion.get().hideCompletion();
Completion.get().hideDocumentation();
NbDocument.runAtomic((StyledDocument) component.getDocument(), new Runnable() {
public void run() {
Document doc = component.getDocument();
try {
doc.remove(substituteOffset, component.getCaretPosition() - substituteOffset);
doc.insertString(substituteOffset, getText(), null);
} catch (BadLocationException e) {
ErrorManager.getDefault().notify(e);
}
}
});
}
示例6: processKeyEvent
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
if(evt.getKeyChar() == '.') { // NOI18N
Completion.get().hideDocumentation();
JTextComponent component = (JTextComponent)evt.getSource();
int caretOffset = component.getSelectionEnd();
int len = caretOffset - substitutionOffset;
if (len >= 0) {
substituteText(component, substitutionOffset, len, Character.toString(evt.getKeyChar()));
Completion.get().showCompletion();
evt.consume();
}
}
}
}
示例7: processKeyEvent
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void processKeyEvent (KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
char c = evt.getKeyChar();
JTextComponent component = (JTextComponent)evt.getSource();
if (confirmChars == null) {
confirmChars = getConfirmChars(component);
}
if (confirmChars.indexOf(c) != -1) {
if (c != '.') {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
NbEditorDocument doc = (NbEditorDocument) component.getDocument ();
try {
defaultAction(component);
doc.insertString(processKeyEventOffset, Character.toString(c), null);
} catch (BadLocationException e) {
}
if (c == '.')
Completion.get().showCompletion();
evt.consume();
} // if
} // if
}
示例8: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
public void defaultAction(final JTextComponent component) {
Completion.get().hideCompletion();
Completion.get().hideDocumentation();
NbDocument.runAtomic((StyledDocument) component.getDocument(), new Runnable() {
@Override
public void run() {
Document doc = component.getDocument();
try {
doc.remove(0, doc.getLength());
doc.insertString(0, getText(), null);
} catch (BadLocationException e) {
Logger.getLogger(SearchCompletionItem.class.getName()).log(Level.FINE, null, e);
}
}
});
}
示例9: processKeyEvent
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
switch (evt.getKeyChar()) {
case ';':
case ',':
case '(':
case '.':
case '\n':
Completion.get().hideAll();
// case '.':
// JTextComponent component = (JTextComponent)evt.getSource();
// int caretOffset = component.getSelectionEnd();
// substituteText(component, substitutionOffset, caretOffset - substitutionOffset, Character.toString(evt.getKeyChar()));
// evt.consume();
// break;
}
}
}
示例10: getAutoQueryTypes
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
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;
}
示例11: preQueryUpdate
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@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();
}
示例12: filter
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
protected void filter(CompletionResultSet resultSet) {
try {
if ((queryType & COMPLETION_QUERY_TYPE) != 0) {
if (results != null) {
if (filterPrefix != null) {
resultSet.addAllItems(getFilteredData(results, filterPrefix));
} else {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
} else if (queryType == TOOLTIP_QUERY_TYPE) {
resultSet.setToolTip(toolTip);
}
resultSet.setAnchorOffset(anchorOffset);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
resultSet.finish();
}
示例13: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
public void defaultAction(final JTextComponent component) {
Completion.get().hideCompletion();
Completion.get().hideDocumentation();
NbDocument.runAtomic((StyledDocument) component.getDocument(), new Runnable() {
@Override
public void run() {
Document doc = component.getDocument();
try {
doc.remove(substituteOffset, component.getCaretPosition() - substituteOffset);
doc.insertString(substituteOffset, getText(), null);
} catch (BadLocationException e) {
Logger.getLogger(FXMLCompletionItem.class.getName()).log(Level.FINE, null, e);
}
}
});
}
示例14: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
public void defaultAction(JTextComponent component) {
if (component == null) {
return;
}
Completion.get().hideAll();
Document doc = component.getDocument();
if (doc == null) {
return;
}
int caret = component.getCaretPosition();
int l = caret - fromOffset;
try {
doc.insertString(fromOffset, "/" + command + " ", null); // NOI18N
doc.remove(fromOffset + command.length() + 2, l);
} catch (BadLocationException ex) {
// ignore
}
}
示例15: canFilter
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
protected boolean canFilter(JTextComponent component) {
final int newOffset = component.getSelectionStart();
final Document doc = component.getDocument();
if (newOffset > caretOffset && items != null && !items.isEmpty()) {
try {
String prefix = doc.getText(caretOffset, newOffset - caretOffset);
if (!isJavaIdentifierPart(prefix)) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
} catch (BadLocationException ble) {
}
}
return false;
}