当前位置: 首页>>代码示例>>Java>>正文


Java Document.render方法代码示例

本文整理汇总了Java中javax.swing.text.Document.render方法的典型用法代码示例。如果您正苦于以下问题:Java Document.render方法的具体用法?Java Document.render怎么用?Java Document.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.Document的用法示例。


在下文中一共展示了Document.render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findIdentifierSpan

import javax.swing.text.Document; //导入方法依赖的package包/类
public static int[] findIdentifierSpan( final TreePath decl, final CompilationInfo info, final Document doc) {
    final int[] result = new int[] {-1, -1};
    Runnable r = new Runnable() {
        public void run() {
            Token<JavaTokenId> t = findIdentifierSpan(info, doc, decl);
            if (t != null) {
                result[0] = t.offset(null);
                result[1] = t.offset(null) + t.length();
            }
        }
    };
    if (doc != null) {
        doc.render(r);
    } else {
        r.run();
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Utilities.java

示例2: onlyWhitespacesBetween

import javax.swing.text.Document; //导入方法依赖的package包/类
private boolean onlyWhitespacesBetween(final int endOffset, final int dot) {
    // autoexpand a fold that was JUST CREATED, if there's no non-whitespace (not lexical, but actual) in between the
    // fold end and the caret:
    final String[] cnt = new String[1];
    final Document doc = component.getDocument();
    doc.render(new Runnable() {
        public void run() {
            int dl = doc.getLength();
            int from = Math.min(dl, 
                    Math.min(endOffset, dot)
                    );
            int to = Math.min(dl, 
                    Math.max(endOffset, dot
                    ));
            try {
                cnt[0] = doc.getText(from, to - from);
            } catch (BadLocationException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
    return (cnt[0] == null || cnt[0].trim().isEmpty());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:FoldingEditorSupport.java

示例3: insideToken

import javax.swing.text.Document; //导入方法依赖的package包/类
private boolean insideToken(final JTextComponent jtc, final JavaTokenId first, final JavaTokenId... rest) {
    final Document doc = jtc.getDocument();
    final boolean[] result = new boolean[1];
    
    doc.render(new Runnable() {
        @Override public void run() {
            int offset = jtc.getSelectionStart();
            TokenSequence<JavaTokenId> ts = SourceUtils.getJavaTokenSequence(TokenHierarchy.get(doc), offset);
            if (ts == null || !ts.moveNext() && !ts.movePrevious() || offset == ts.offset()) {
                result[0] = false;
            } else {
                EnumSet tokenIds = EnumSet.of(first, rest);
                result[0] = tokenIds.contains(ts.token().id());
            }
        }
    });
    
    return result[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ClipboardHandler.java

示例4: parse

import javax.swing.text.Document; //导入方法依赖的package包/类
/**
 * Converts to InputSource and pass it.
 */    
protected TreeDocumentRoot parse(final Document doc) throws IOException, TreeException {
    
    InputSource in = new InputSource();
    
    // safely take the text from the document
    //??? what about DocumentReader
    
    final String[] str = new String[1];
    
    Runnable run = new Runnable() {
        public void run () {
            try {
                str[0] = doc.getText(0, doc.getLength());
            } catch (javax.swing.text.BadLocationException e) {
                // impossible
                e.printStackTrace();
            }
        }
    };

    doc.render(run);
    in.setCharacterStream(new StringReader(str[0]));
    return parse(in);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ParsingSupport.java

示例5: TokenList

import javax.swing.text.Document; //导入方法依赖的package包/类
public TokenList(CompilationInfo info, final Document doc, AtomicBoolean cancel) {
    this.info = info;
    this.doc = doc;
    this.cancel = cancel;
    
    this.sourcePositions = info.getTrees().getSourcePositions();
    
    doc.render(new Runnable() {
        @Override
        public void run() {
            if (TokenList.this.cancel.get()) {
                return ;
            }
            
            topLevel = TokenHierarchy.get(doc).tokenSequence();
            
            topLevelIsJava = topLevel.language() == JavaTokenId.language();
            
            if (topLevelIsJava) {
                ts = topLevel;
                ts.moveStart();
                ts.moveNext(); //XXX: what about empty document
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TokenList.java

示例6: documentToString

import javax.swing.text.Document; //导入方法依赖的package包/类
/**
 * @return current state of Document as string
 */
private static String documentToString(final Document doc) {
    
    final String[] str = new String[1];

    // safely take the text from the document
    Runnable run = new Runnable() {
        public void run () {
            try {
                str[0] = doc.getText(0, doc.getLength());
            } catch (javax.swing.text.BadLocationException e) {
                // impossible
                Exceptions.printStackTrace(e);
            }
        }
    };

    doc.render(run);
    return str[0];
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentInputSource.java

示例7: runViewHierarchyTransaction

import javax.swing.text.Document; //导入方法依赖的package包/类
/**
 * Execute the given runnable with view hierarchy being locked.
 * This is necessary when exploring the view hierarchy by views' methods
 * since the views changes may happen due to changes from highlighting layers
 * that cause the views to be rebuilt.
 * @param component non-null text component of which the view hierarchy is being explored.
 * @param readLockDocument if true lock the document before locking the view hierarchy.
 *  This parameter should only be false if it's known that the document was already read/write-locked
 *  prior calling this method.
 * @r non-null runnable to execute.
 */
public static void runViewHierarchyTransaction(final JTextComponent component,
        boolean readLockDocument, final Runnable r)
{
    Runnable wrapRun = new Runnable() {
        @Override
        public void run() {
            View documentView = getDocumentView(component);
            if (documentView != null) {
                ((DocumentView) documentView).runTransaction(r);
            }
        }
    };
    Document doc;
    if (readLockDocument && (doc = component.getDocument()) != null) {
        doc.render(wrapRun);
    } else {
        wrapRun.run();
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:Utilities.java

示例8: previousCamelCasePosition

import javax.swing.text.Document; //导入方法依赖的package包/类
static int previousCamelCasePosition(CamelCaseInterceptor.MutableContext context) throws BadLocationException {
    // get current caret position
    final int offset = context.getOffset();
    final Document doc = context.getDocument();
    final int[] retOffset = new int[1];
    final BadLocationException[] retExc = new BadLocationException[1];
    doc.render(new Runnable() {
        @Override
        public void run() {
            try {
                retOffset[0] = previousCamelCasePositionImpl(doc, offset);
            } catch (BadLocationException ex) {
                retExc[0] = ex;
            }
        }
    });
    if (retExc[0] != null) {
        throw retExc[0];
    }
    return retOffset[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CamelCaseOperations.java

示例9: getMimePath

import javax.swing.text.Document; //导入方法依赖的package包/类
static MimePath getMimePath(final Document doc, final int offset) {
    final MimePath[] mimePathR = new MimePath[1];
    doc.render(new Runnable() {
        @Override
        public void run() {
            List<TokenSequence<?>> seqs = TokenHierarchy.get(doc).embeddedTokenSequences(offset, true);
            TokenSequence<?> seq = seqs.isEmpty() ? null : seqs.get(seqs.size() - 1);
            seq = seq == null ? TokenHierarchy.get(doc).tokenSequence() : seq;
            mimePathR[0] = seq == null ? MimePath.parse(DocumentUtilities.getMimeType(doc)) : MimePath.parse(seq.languagePath().mimePath());
        }
    });
    return mimePathR[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CamelCaseInterceptorsManager.java

示例10: verifyDocument

import javax.swing.text.Document; //导入方法依赖的package包/类
private static boolean verifyDocument(final Document doc) {
    if (doc == null) {
        Logger.getLogger(SemanticHighlighterBase.class.getName()).log(Level.FINE, "SemanticHighlighter: Cannot get document!");
        return false;
    }

    final boolean[] tokenSequenceNull =  new boolean[1];
    doc.render(new Runnable() {
        @Override
        public void run() {
            tokenSequenceNull[0] = (TokenHierarchy.get(doc).tokenSequence() == null);
        }
    });
    return !tokenSequenceNull[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:SemanticHighlighterBase.java

示例11: canFilter

import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
protected boolean canFilter(final JTextComponent component) {
    final Collection<PaletteCompletionItem> currentItems = items;
    if(currentItems == null) {
        return false;
    }
    final Document doc = component.getDocument();
    final AtomicBoolean retval = new AtomicBoolean();
    doc.render(new Runnable() {

        @Override
        public void run() {
            try {
                int offset = component.getCaretPosition();
                if (completionExpressionStartOffset < 0  || offset < completionExpressionStartOffset) {
                    retval.set(false);
                    return;
                }
                String prefix = doc.getText(completionExpressionStartOffset, offset - completionExpressionStartOffset);
                //check the items
                for (PaletteCompletionItem item : currentItems) {
                    if (startsWithIgnoreCase(item.getItemName(), prefix)) {
                        retval.set(true); //at least one item will remain
                        return;
                    }
                }
            } catch (BadLocationException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });


    return retval.get();

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:HtmlPaletteCompletionProvider.java

示例12: checkDependencyList

import javax.swing.text.Document; //导入方法依赖的package包/类
private void checkDependencyList(List<Dependency> deps, final POMModel model, List<ErrorDescription> toRet, Map<String, String> managed) {
    if (deps != null) {
        for (final Dependency dep : deps) {
            String ver = dep.getVersion();
            if (ver != null) {
                String art = dep.getArtifactId();
                String gr = dep.getGroupId();
                String key = gr + ":" + art; //NOI18N
                if (managed.keySet().contains(key)) {
                    final String managedver = managed.get(key);
                    Document doc = model.getBaseDocument();
                    final Line[] line = new Line[1];
                    doc.render(new Runnable() {
                        @Override
                        public void run() {
                            int position = dep.findChildElementPosition(model.getPOMQNames().VERSION.getQName());
                            line[0] = NbEditorUtilities.getLine(model.getBaseDocument(), position, false);
                        }
                    });
                    toRet.add(ErrorDescriptionFactory.createErrorDescription(
                        configuration.getSeverity(configuration.getPreferences()).toEditorSeverity(),
                        NbBundle.getMessage(OverrideDependencyManagementError.class, "TXT_OverrideDependencyManagementError", managedver),
                        Collections.<Fix>singletonList(new OverrideFix(dep)),
                        doc, line[0].getLineNumber() + 1));
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:OverrideDependencyManagementError.java

示例13: findBodyStart

import javax.swing.text.Document; //导入方法依赖的package包/类
public static int findBodyStart(final CompilationInfo info, final Tree cltree, final CompilationUnitTree cu, final SourcePositions positions, final Document doc) {
    Kind kind = cltree.getKind();
    if (!TreeUtilities.CLASS_TREE_KINDS.contains(kind) && kind != Kind.METHOD)
        throw new IllegalArgumentException("Unsupported kind: "+ kind);
    final int[] result = new int[1];
    
    doc.render(new Runnable() {
        public void run() {
            result[0] = findBodyStartImpl(info, cltree, cu, positions, doc);
        }
    });
    
    return result[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:Utilities.java

示例14: call

import javax.swing.text.Document; //导入方法依赖的package包/类
public Boolean call() {
    sharp = true;
    final Document doc = component.getDocument();
    doc.render(this);
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:FoldingEditorSupport.java

示例15: invokeDefaultAction

import javax.swing.text.Document; //导入方法依赖的package包/类
boolean invokeDefaultAction(final JTextComponent comp) {
    final Document doc = comp.getDocument();
    
    if (doc instanceof BaseDocument) {
        final int currentPosition = comp.getCaretPosition();
        final Annotations annotations = ((BaseDocument) doc).getAnnotations();
        final Map<String, List<ElementDescription>> caption2Descriptions = new LinkedHashMap<String, List<ElementDescription>>();
        final Point[] p = new Point[1];
        
        doc.render(new Runnable() {
            public void run() {
                try {
                    int line = Utilities.getLineOffset((BaseDocument) doc, currentPosition);
                    int startOffset = Utilities.getRowStartFromLineOffset((BaseDocument) doc, line);
                    p[0] = comp.modelToView(startOffset).getLocation();
                    AnnotationDesc desc = annotations.getActiveAnnotation(line);

                    if (desc == null) {
                        return ;
                    }
                    
                    Collection<IsOverriddenAnnotation> annots;

                    if (COMBINED_TYPES.contains(desc.getAnnotationType())) {
                        annots = findAnnotations(comp, startOffset);
                    } else {
                        annots = Collections.singletonList(findAnnotation(comp, desc, startOffset));
                    }

                    for (IsOverriddenAnnotation a : annots) {
                        if (a != null) {
                            caption2Descriptions.put(computeCaption(a.getType(), a.getShortDescription()), a.getDeclarations());
                        }
                    }
                }  catch (BadLocationException ex) {
                    ErrorManager.getDefault().notify(ex);
                }
            }
        });
        
        if (caption2Descriptions.isEmpty())
            return false;
        
        JumpList.checkAddEntry(comp, currentPosition);

        mouseClicked(caption2Descriptions, comp, p[0]);
        
        return true;
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:IsOverriddenAnnotationAction.java


注:本文中的javax.swing.text.Document.render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。