本文整理汇总了Java中org.fife.ui.autocomplete.Completion类的典型用法代码示例。如果您正苦于以下问题:Java Completion类的具体用法?Java Completion怎么用?Java Completion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Completion类属于org.fife.ui.autocomplete包,在下文中一共展示了Completion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateCompletionProvider
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* para o editor do jifi usar:
*
* updateCompletionProvider("s3f.jifi.functions.*","tokenInfo");
* updateCompletionProvider("s3f.jifi.functions.*","tokenInfo");
*
*
* @param em
* @param path
* @param property
*/
public final void updateCompletionProvider(EntityManager em, String path, String property) {
AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance();
TokenMaker tokenMaker = atmf.getTokenMaker(textArea.getSyntaxEditingStyle());
TokenMap tokenMap = null;
if (tokenMaker instanceof ExtensibleTokenMaker) {
tokenMap = ((ExtensibleTokenMaker) tokenMaker).getTokenMap();
}
for (Object o : em.getAllProperties(path, property, Object.class)) {
if (o instanceof Completion) {
completionProvider.addCompletion((Completion) o);
if (tokenMap != null) {
//TODO: verificar!
tokenMap.put(((Completion) o).getReplacementText(), Token.FUNCTION);
}
} else {
completionProvider.addCompletion(
new BasicCompletion(completionProvider, o.toString())
);
if (tokenMap != null) {
//TODO: verificar!
tokenMap.put(o.toString(), Token.DATA_TYPE);
}
}
}
}
示例2: getClass
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Returns the class for a completion (class completions return the class
* itself, member completions return the enclosing class).
*/
private String getClass(Completion c, String desc) {
String clazz = null;
if (c instanceof ClassCompletion) {
clazz = ((ClassCompletion)c).getClassName(true);
}
else if (c instanceof MemberCompletion) {
MemberCompletion mc = (MemberCompletion)c;
clazz = mc.getEnclosingClassName(true);
}
else {
System.err.println("Can't determine class from completion type: " +
c.getClass() + " (" + c.toString() + ") - href: " + desc);
}
return clazz;
}
示例3: getPackage
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Returns the package of the specified completion.
*
* @param c The completion.
* @param desc The description text being parsed. Used for errors if we
* cannot determine the package.
* @return The package.
*/
private String getPackage(Completion c, String desc) {
String pkg = null;
if (c instanceof ClassCompletion) {
pkg = ((ClassCompletion)c).getPackageName();
}
else if (c instanceof MemberCompletion) {
String definedIn = ((MemberCompletion)c).getEnclosingClassName(true);
if (definedIn!=null) {
int lastDot = definedIn.lastIndexOf('.');
if (lastDot>-1) {
pkg = definedIn.substring(0, lastDot);
}
}
}
else {
System.err.println("Can't determine package from completion type: " +
c.getClass() + " (" + c.toString() + ") - href: " + desc);
}
return pkg;
}
示例4: compareTo
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Overridden to ensure that two completions don't just have the same
* text value (ignoring case), but that they're of the same "type" of
* <code>Completion</code> as well, so, for example, a completion for the
* "String" class won't clash with a completion for a "string" LocalVar.
*
* @param o Another completion instance.
* @return How this completion compares to the other one.
*/
@Override
public int compareTo(Completion o) {
int rc = -1;
if (o==this) {
rc = 0;
}
else if (o instanceof Completion) {
Completion c2 = (Completion)o;
rc = toString().compareToIgnoreCase(c2.toString());
if (rc==0) { // Same text value
String clazz1 = getClass().getName();
clazz1 = clazz1.substring(clazz1.lastIndexOf('.'));
String clazz2 = c2.getClass().getName();
clazz2 = clazz2.substring(clazz2.lastIndexOf('.'));
rc = clazz1.compareTo(clazz2);
}
}
return rc;
}
示例5: compareTo
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Overridden to ensure that two completions don't just have the same
* text value (ignoring case), but that they're of the same "type" of
* <code>Completion</code> as well, so, for example, a completion for the
* "String" class won't clash with a completion for a "string" LocalVar.
*
* @param c2 Another completion instance.
* @return How this completion compares to the other one.
*/
@Override
public int compareTo(Completion c2) {
int rc = -1;
if (c2==this) {
rc = 0;
}
else if (c2!=null) {
rc = toString().compareToIgnoreCase(c2.toString());
if (rc==0) { // Same text value
String clazz1 = getClass().getName();
clazz1 = clazz1.substring(clazz1.lastIndexOf('.'));
String clazz2 = c2.getClass().getName();
clazz2 = clazz2.substring(clazz2.lastIndexOf('.'));
rc = clazz1.compareTo(clazz2);
}
}
return rc;
}
示例6: generate
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<Completion> generate(CompletionProvider provider, String input){
List<Completion> completions = new ArrayList<Completion>();
completions.add(new FontFamilyCompletion(provider, "Georgia"));
completions.add(new FontFamilyCompletion(provider, "\"Times New Roman\""));
completions.add(new FontFamilyCompletion(provider, "Arial"));
completions.add(new FontFamilyCompletion(provider, "Helvetica"));
completions.add(new FontFamilyCompletion(provider, "Impact"));
completions.add(new FontFamilyCompletion(provider, "\"Lucida Sans Unicode\""));
completions.add(new FontFamilyCompletion(provider, "Tahoma"));
completions.add(new FontFamilyCompletion(provider, "Verdana"));
completions.add(new FontFamilyCompletion(provider, "Geneva"));
completions.add(new FontFamilyCompletion(provider, "\"Courier New\""));
completions.add(new FontFamilyCompletion(provider, "Courier"));
completions.add(new FontFamilyCompletion(provider, "\"Lucida Console\""));
completions.add(new FontFamilyCompletion(provider, "Menlo"));
completions.add(new FontFamilyCompletion(provider, "Monaco"));
completions.add(new FontFamilyCompletion(provider, "Consolas"));
return completions;
}
示例7: generate
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<Completion> generate(CompletionProvider provider, String input){
List<Completion> completions = new ArrayList<Completion>();
completions.add(new BorderStyleCompletion(provider, "none"));
completions.add(new BorderStyleCompletion(provider, "hidden"));
completions.add(new BorderStyleCompletion(provider, "dotted"));
completions.add(new BorderStyleCompletion(provider, "dashed"));
completions.add(new BorderStyleCompletion(provider, "solid"));
completions.add(new BorderStyleCompletion(provider, "double"));
completions.add(new BorderStyleCompletion(provider, "groove"));
completions.add(new BorderStyleCompletion(provider, "ridge"));
completions.add(new BorderStyleCompletion(provider, "inset"));
completions.add(new BorderStyleCompletion(provider, "outset"));
return completions;
}
示例8: PropertyValueCompletionProvider
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
public PropertyValueCompletionProvider(boolean isLess) {
setAutoActivationRules(true, "@: ");
// While we don't have functions per-se in CSS, we do in Less
setParameterizedCompletionParams('(', ", ", ')');
this.isLess = isLess;
try {
this.valueCompletions = new HashMap<String, List<Completion>>();
this.valueCompletionGenerators =
new HashMap<String, List<CompletionGenerator>>();
loadPropertyCompletions();
this.htmlTagCompletions = loadHtmlTagCompletions();
} catch (IOException ioe) { // Never happens
throw new RuntimeException(ioe);
}
comparator = new AbstractCompletionProvider.CaseInsensitiveComparator();
}
示例9: loadFromXML
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Loads completions from an XML file. The XML should validate against
* <code>CompletionXml.dtd</code>.
*
* @param resource A resource the current ClassLoader can get to.
* @throws IOException If an IO error occurs.
*/
protected List<Completion> loadFromXML(String resource) throws IOException {
ClassLoader cl = getClass().getClassLoader();
InputStream in = cl.getResourceAsStream(resource);
if (in==null) {
File file = new File(resource);
if (file.isFile()) {
in = new FileInputStream(file);
}
else {
throw new IOException("No such resource: " + resource);
}
}
BufferedInputStream bin = new BufferedInputStream(in);
try {
return loadFromXML(bin, null);
} finally {
bin.close();
}
}
示例10: getTagCompletions
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Overridden to include JSP-specific tags in addition to the standard
* HTML tags.
*
* @return The list of tags.
*/
@Override
protected List<Completion> getTagCompletions() {
List<Completion> completions = new ArrayList<Completion>(
super.getTagCompletions());
for (Map.Entry<String, TldFile> entry : prefixToTld.entrySet()) {
String prefix = entry.getKey();
TldFile tld = entry.getValue();
for (int j=0; j<tld.getElementCount(); j++) {
TldElement elem = tld.getElement(j);
MarkupTagCompletion mtc = new MarkupTagCompletion(this,
prefix + ":" + elem.getName());
mtc.setDescription(elem.getDescription());
completions.add(mtc);
}
}
Collections.sort(completions);
return completions;
}
示例11: addLessCompletions
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Overridden to handle Less properly.
*/
@Override
protected boolean addLessCompletions(List<Completion> completions,
LexerState state, JTextComponent comp, String alreadyEntered) {
boolean modified = false;
if (alreadyEntered != null && alreadyEntered.length() > 0 &&
alreadyEntered.charAt(0) == '@') {
addLessVariableCompletions(completions, comp, alreadyEntered);
modified = true;
}
if (state == LexerState.VALUE) {
addLessBuiltinFunctionCompletions(completions, alreadyEntered);
modified = true;
}
return modified;
}
示例12: compareTo
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int compareTo(Completion other) {
int rc = -1;
if (other==this) {
rc = 0;
}
else if (other instanceof JSCompletion) {
JSCompletion c2 = (JSCompletion)other;
rc = getLookupName().compareTo(c2.getLookupName());
}
else if (other!=null) {
rc = toString().compareTo(other.toString());
if (rc == 0) { // Same text value
String clazz1 = getClass().getName();
clazz1 = clazz1.substring(clazz1.lastIndexOf('.'));
String clazz2 = other.getClass().getName();
clazz2 = clazz2.substring(clazz2.lastIndexOf('.'));
rc = clazz1.compareTo(clazz2);
}
}
return rc;
}
示例13: addCodeBlock
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* for each child of parent AstNode add a new code block and add completions
* for each block of code
*
* @param parent AstNode to iterate children
* @param set completions set to add to
* @param entered Text entered
* @param codeBlock parent CodeBlock
* @param offset codeblock offset
*/
private void addCodeBlock(Node parent, Set<Completion> set,
String entered, CodeBlock codeBlock, int offset) {
if(parent == null)
return;
Node child = parent.getFirstChild();
while (child != null) {
CodeBlock childBlock = codeBlock;
if (child instanceof AstNode) {
AstNode node = (AstNode) child;
int start = node.getAbsolutePosition();
childBlock = codeBlock.addChildCodeBlock(start);
childBlock.setEndOffset(offset);
}
iterateNode((AstNode) child, set, entered, childBlock, offset);
child = child.getNext();
}
}
示例14: processCaseNode
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
private void processCaseNode(Node child, CodeBlock block,
Set<Completion> set, String entered, int offset) {
SwitchCase switchCase = (SwitchCase) child;
List<AstNode> statements = switchCase.getStatements();
int start = switchCase.getAbsolutePosition();
offset = start + switchCase.getLength();
if (canProcessNode(switchCase)) {
block = block.addChildCodeBlock(start);
block.setEndOffset(offset);
if(statements != null) {
for (AstNode node : statements) {
iterateNode(node, set, entered, block, offset);
}
}
}
}
示例15: iterateNode
import org.fife.ui.autocomplete.Completion; //导入依赖的package包/类
/**
* Overridden iterateNode to intercept Token.EXPR_RESULT and check for importPackage and importClass named nodes
* If found, then process them and extract the imports and add them to RhinoJavaScriptTypesFactory then return
* otherwise call super.iterateNode()
*/
@Override
protected void iterateNode(AstNode child, Set <Completion>set,
String entered, CodeBlock block, int offset) {
//look for importPackage and importClass
switch (child.getType()) {
case Token.EXPR_RESULT:
boolean importFound = processImportNode(child, set, entered, block, offset);
if(importFound)
return; //already processed node
break;
}
super.iterateNode(child, set, entered, block, offset);
}