本文整理汇总了Java中org.netbeans.api.editor.completion.Completion类的典型用法代码示例。如果您正苦于以下问题:Java Completion类的具体用法?Java Completion怎么用?Java Completion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Completion类属于org.netbeans.api.editor.completion包,在下文中一共展示了Completion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JPQLEditorCodeCompletionProvider.java
示例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;
// }
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:JPACompletionItem.java
示例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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:CompletionQuery.java
示例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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AddToDictionaryCompletionItem.java
示例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);
}
}
});
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:WordCompletionItem.java
示例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();
}
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SpringXMLConfigCompletionItem.java
示例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
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CompletionSupport.java
示例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);
}
}
});
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SearchCompletionItem.java
示例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;
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:GsfCompletionItem.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:GsfCompletionProvider.java
示例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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:GsfCompletionProvider.java
示例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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GsfCompletionProvider.java
示例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);
}
}
});
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FXMLCompletionItem.java
示例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
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CommandCompletionProvider.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JavadocCompletionQuery.java
示例16: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void defaultAction(JTextComponent component) {
if (component != null) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
StringBuilder sb = new StringBuilder();
sb.append(this.name);
if (this.paramTypes.length == 0) {
sb.append("() "); // NOI18N
} else {
sb.append('(');
for (String pt : paramTypes) {
sb.append(pt).append(", "); // NOI18N
}
sb.setCharAt(sb.length() - 2, ')');
}
complete(component, sb.toString(), substitutionOffset);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavadocCompletionItem.java
示例17: 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);
} else {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
} else if (queryType == TOOLTIP_QUERY_TYPE) {
resultSet.setToolTip(toolTip != null && toolTip.hasData() ? toolTip : null);
}
resultSet.setAnchorOffset(anchorOffset);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
resultSet.finish();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JavaCompletionProvider.java
示例18: beforeInsert
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
@Override
public boolean beforeInsert(Context context) throws BadLocationException {
//"ignore typed text support"
//depending on previous actions we are
//going to ignore some characters typed
if (insertIgnore != null) {
DocumentInsertIgnore local = insertIgnore;
insertIgnore = null;
if (local.getOffset() == context.getOffset() && local.getChar() == context.getText().charAt(0)) {
//move the caret to specified position if needed
if (local.getMoveCaretTo() != -1) {
context.getComponent().setCaretPosition(local.moveCaretTo);
//also close the completion window
Completion.get().hideAll();
}
return true; //stop subsequent processing of the change
}
}
return false;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:HtmlTypedTextInterceptor.java
示例19: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void defaultAction(JTextComponent component) {
Completion.get().hideAll();
// Remove the typed part
Document doc = component.getDocument();
int caretOffset = component.getSelectionStart();
int prefixLength = 0;
try {
String ident = Utilities.getIdentifierBefore((BaseDocument)doc, caretOffset);
if (ident != null) {
prefixLength = ident.length();
}
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
if (prefixLength > 0) {
try {
// Remove the typed prefix
doc.remove(caretOffset - prefixLength, prefixLength);
} catch (BadLocationException ble) {
}
}
codeTemplate.insert(component);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CodeTemplateCompletionItem.java
示例20: defaultAction
import org.netbeans.api.editor.completion.Completion; //导入依赖的package包/类
public void defaultAction(JTextComponent component) {
final BaseDocument doc = (BaseDocument) component.getDocument();
doc.runAtomicAsUser(new Runnable() {
@Override
public void run() {
try {
doc.remove(caret, correction);
doc.insertString(caret, text, null);
} catch (BadLocationException ex) {
// shouldn't happen
}
}
});
//This statement will close the code completion box:
Completion.get().hideAll();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ClassnameCompletionItem.java
注:本文中的org.netbeans.api.editor.completion.Completion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论