KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > NNCompletionProvider


1 ///*
2
// * The contents of this file are subject to the terms of the Common Development
3
// * and Distribution License (the License). You may not use this file except in
4
// * compliance with the License.
5
// *
6
// * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
// * or http://www.netbeans.org/cddl.txt.
8
// *
9
// * When distributing Covered Code, include this CDDL Header Notice in each file
10
// * and include the License file at http://www.netbeans.org/cddl.txt.
11
// * If applicable, add the following below the CDDL Header, with the fields
12
// * enclosed by brackets [] replaced by your own identifying information:
13
// * "Portions Copyrighted [year] [name of copyright owner]"
14
// *
15
// * The Original Software is NetBeans. The Initial Developer of the Original
16
// * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
// * Microsystems, Inc. All Rights Reserved.
18
// */
19
//
20
//package org.netbeans.modules.j2ee.persistence.editor.completion;
21
//
22
//import javax.swing.text.Document;
23
//import javax.swing.text.JTextComponent;
24
//import org.netbeans.editor.Utilities;
25
//import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
26
//import org.netbeans.spi.editor.completion.CompletionProvider;
27
//import org.netbeans.spi.editor.completion.CompletionResultSet;
28
//import org.netbeans.spi.editor.completion.CompletionTask;
29
//import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery;
30
//import org.netbeans.spi.editor.completion.support.AsyncCompletionTask;
31
//import org.openide.util.NbBundle;
32
//
33
///**
34
// *
35
// * @author abadea
36
// */
37
// TODO: RETOUCHE
38
//public class NNCompletionProvider implements CompletionProvider {
39
//
40
// public int getAutoQueryTypes(JTextComponent component, String typedText) {
41
// return 0;
42
// }
43
//
44
// public CompletionTask createTask(int queryType, JTextComponent component) {
45
// if (queryType == CompletionProvider.COMPLETION_QUERY_TYPE) {
46
// return new AsyncCompletionTask(new Query(component.getCaret().getDot()), component);
47
// }
48
// return null;
49
// }
50
//
51
// static final class Query extends AsyncCompletionQuery {
52
//
53
// private JTextComponent component;
54
//
55
// private int creationCaretOffset;
56
// private int queryCaretOffset;
57
//
58
// private int queryAnchorOffset;
59
//
60
// private String filterPrefix;
61
//
62
// Query(int caretOffset) {
63
// this.creationCaretOffset = caretOffset;
64
// }
65
//
66
// protected void preQueryUpdate(JTextComponent component) {
67
//// int caretOffset = component.getCaretPosition();
68
//// Document doc = component.getDocument();
69
//// if (caretOffset >= creationCaretOffset) {
70
//// try {
71
//// if (isJavaIdentifierPart(doc.getText(creationCaretOffset, caretOffset - creationCaretOffset)))
72
//// return;
73
//// } catch (BadLocationException e) {
74
//// }
75
//// }
76
//// Completion.get().hideCompletion();
77
// }
78
//
79
// protected void query(CompletionResultSet resultSet, Document doc, int caretOffset) {
80
// if (JavaMetamodel.getManager().isScanInProgress()) {
81
// resultSet.setWaitText(NbBundle.getMessage(NNCompletionProvider.class, "scanning-in-progress")); //NOI18N
82
// }
83
// NNCompletionQuery query = new NNCompletionQuery(true);
84
// NNCompletionQuery.DefaultResult res = (NNCompletionQuery.DefaultResult)query.query(component, caretOffset, Utilities.getSyntaxSupport(component));
85
// if (res != null) {
86
// queryCaretOffset = caretOffset;
87
// //queryAnchorOffset = res.getSubstituteOffset();
88
// resultSet.setTitle(res.getTitle());
89
// // resultSet.setAnchorOffset(queryAnchorOffset);
90
// resultSet.addAllItems(res.getData());
91
// // queryResult = res;
92
// }
93
// resultSet.finish();
94
// }
95
//
96
// protected void prepareQuery(JTextComponent component) {
97
// this.component = component;
98
// }
99
//
100
//// private boolean isJavaIdentifierPart(String text) {
101
//// for (int i = 0; i < text.length(); i++) {
102
//// if (!(Character.isJavaIdentifierPart(text.charAt(i))) ) {
103
//// return false;
104
//// }
105
//// }
106
//// return true;
107
//// }
108
//
109
// // TODO: filtering
110
// }
111
//}
112
Popular Tags