Package org.netbeans.editor

Examples of org.netbeans.editor.BaseDocument


            }
        }
    }

    protected void substituteText(JTextComponent c, final int offset, final int len, String toAdd) {
        final BaseDocument doc = (BaseDocument) c.getDocument();
        final CharSequence prefix = getSubstitutionText();
        final StringBuffer textBuffer = new StringBuffer(prefix.toString());
        if (toAdd != null) {
            textBuffer.append(toAdd);
        }

        doc.runAtomic(new Runnable() {

            public void run() {
                try {
                    Position position = doc.createPosition(offset);
                    doc.remove(offset, len);
                    doc.insertString(position.getOffset(), textBuffer.toString(), null);
                } catch (BadLocationException ble) {
                    // nothing can be done to update
                }
            }
        });
View Full Code Here


        // First check that we are working with BaseDocument:
        if (!(doc instanceof BaseDocument)) {
            return false;
        }

        BaseDocument bdoc = (BaseDocument) doc;
        JTextComponent target = Utilities.getFocusedComponent();

        // We want to work only with the open editor
        // and the editor has to be the active component and
        // the document has to be the same as was used in the isHyperlinkPoint method:
View Full Code Here

    public boolean isHyperlinkPoint(Document doc, int offset) {
        if(!isHyperlinkPointValid(doc)){
            return false;
        }

        BaseDocument bdoc = (BaseDocument) doc;
       
        try {
           
            TokenHierarchy hi = TokenHierarchy.create(
                    doc.getText(0, doc.getLength()), HTMLTokenId.language());
View Full Code Here

    public void performClickAction(Document doc, int offset) {
        if(!isPerformClickActionValid(doc)){
            return;
        }

        BaseDocument bdoc = (BaseDocument) doc;
       
        //Start a new thread for opening the Java document:
        OpenActionBeanThread run = new OpenActionBeanThread(bdoc, identifier);
        RequestProcessor.getDefault().post(run);
    }
View Full Code Here

    public boolean isHyperlinkPoint(Document doc, int offset) {
        if(!isHyperlinkPointValid(doc)){
            return false;
        }
       
        BaseDocument bdoc = (BaseDocument) doc;
       
        try {
           
            TokenHierarchy hi = TokenHierarchy.create(
                    doc.getText(0, doc.getLength()), JavaTokenId.language());
View Full Code Here

    public void performClickAction(Document doc, int offset) {
        if(!isPerformClickActionValid(doc)){
            return;
        }
       
        BaseDocument bdoc = (BaseDocument) doc;
       
        //Start a new thread for opening the Jsp document:
        OpenJspFileThread run = new OpenJspFileThread(bdoc, identifier);
        RequestProcessor.getDefault().post(run);
    }
View Full Code Here

        }
        return null;
    }
   
    private static FileObject getFileObject(JTextComponent target) {
        BaseDocument doc = (BaseDocument) target.getDocument();
        DataObject dobj = NbEditorUtilities.getDataObject(doc);
        FileObject fobj = (dobj != null) ? NbEditorUtilities.getDataObject(doc).getPrimaryFile() : null;
        return fobj;
    }
View Full Code Here

        if (pr == null) {
            return Collections.emptyMap();
        }
        try {
            Map<String, List<OffsetRange>> folds = new HashMap<String, List<OffsetRange>>();
            BaseDocument document = (BaseDocument) pr.getSnapshot().getSource().getDocument(true);
            TokenHierarchy<CoffeeScriptTokenId> th = (TokenHierarchy<CoffeeScriptTokenId>) pr.getSnapshot().getTokenHierarchy();
            TokenSequence<CoffeeScriptTokenId> ts = th.tokenSequence(CoffeeScriptLanguage.getLanguage());
            List<OffsetRange> ranges = new ArrayList<OffsetRange>();
            Deque<IdentRegion> indents = new ArrayDeque<IdentRegion>();
            while (ts.moveNext()) {
                Token<CoffeeScriptTokenId> token = ts.token();
                switch (token.id()) {
//                    case COMMENT:
//                        TokenSequence<CoffeeScriptTokenId> commentTS = ts.subSequence(ts.offset());
//                        int start = token.offset(th);
//                        int end = start + token.length();
//                        while (commentTS.moveNext()) {
//                            Token<CoffeeScriptTokenId> commentNextToken = commentTS.token();
//                            if (commentNextToken.id() == CoffeeScriptTokenId.COMMENT) {
//                                end = commentNextToken.offset(th) + commentNextToken.length();
//                                continue;
//                            }
//                            if (commentNextToken.id().getCategory() == CoffeeScriptTokenId.Category.WHITESPACE_CAT) {
//                                continue;
//                            }
//                            break;
//                        }
//                        addIndent(document, ranges, start, end);
//                        break;
                    case INDENT:
                        Integer indent = (Integer) token.getProperty("indent");
                        indents.push(new IdentRegion(token.offset(th), indent));
                        break;
                    case OUTDENT:
                        Integer outdent = (Integer) token.getProperty("indent");
                        int to = token.offset(th) + token.length();
                        addIndent(document, ranges, indents, outdent, to);
                        break;
                }
            }
            addIndent(document, ranges, indents, -1, document.getLength());
            folds.put("codeblocks", ranges);
            return folds;
        } catch (Exception e) {
            Exceptions.printStackTrace(e);
        }
View Full Code Here

        if (_doc == null || !(_doc instanceof BaseDocument)) {
            return;
        }

        BaseDocument doc = (BaseDocument) _doc;
        final Reformat reformatter = Reformat.get(doc);
        reformatter.lock();
        try {
            doc.runAtomic(new Runnable() {

                public void run() {
                    try {
                        String s2 = s == null ? "" : s;
                        int start = insert(s2, target, _doc);
View Full Code Here

      return AbstractHint.getDescription(name);
    }

    @Override
    public ChangeInfo implement() throws Exception {
      final BaseDocument bdoc = (BaseDocument) doc;
      bdoc.runAtomic(new Runnable() {
        @Override
        public void run() {
          try {
            bdoc.remove(start, "widget".length());
            bdoc.insertString(start, "control", null);
          } catch(BadLocationException ex) {
            Exceptions.printStackTrace(ex);
          }
        }
      });
View Full Code Here

TOP

Related Classes of org.netbeans.editor.BaseDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.