Package javax.swing.text

Examples of javax.swing.text.AbstractDocument$ElementEdit


    /** Cleanup whatever would cause a leak. */
    @Override
    public void cleanup() {
        getWidgetListeners().clear();
        final AbstractDocument dtfp = (AbstractDocument) textFieldPart.getDocument();
        for (final DocumentListener dl : dtfp.getDocumentListeners()) {
            dtfp.removeDocumentListener(dl);
        }
        for (final ItemListener il : unitComboBox.getItemListeners()) {
            unitComboBox.removeItemListener(il);
        }
    }
View Full Code Here


    /** Cleanup whatever would cause a leak. */
    @Override
    public void cleanup() {
        getWidgetListeners().clear();
        final AbstractDocument d = (AbstractDocument) getDocument();
        for (final DocumentListener dl : d.getDocumentListeners()) {
            d.removeDocumentListener(dl);
        }
    }
View Full Code Here

    /** Cleanup whatever would cause a leak. */
    @Override
    public void cleanup() {
        getWidgetListeners().clear();
        final MComboBox<Value> thisCB = getInternalComponent();
        final AbstractDocument dc = (AbstractDocument) getDocument();
        for (final DocumentListener dl : dc.getDocumentListeners()) {
            dc.removeDocumentListener(dl);
        }
        for (final ItemListener il : thisCB.getItemListeners()) {
            thisCB.removeItemListener(il);
        }
    }
View Full Code Here

     *
     * @param doc
     * @return
     */
    public static TokenSequence<PHPTokenId> getTokenSequence(Document doc) {
        AbstractDocument abstractDoc = (AbstractDocument) doc;
        abstractDoc.readLock();
        TokenSequence<PHPTokenId> ts = null;
        try {
            TokenHierarchy<Document> hierarchy = TokenHierarchy.get(doc);
            ts = hierarchy.tokenSequence(PHPTokenId.language());
        } finally {
            abstractDoc.readUnlock();
        }
        return ts;
    }
View Full Code Here

     * @param document
     * @return TokenSequence
     */
    public static TokenSequence<MarkdownTokenId> getTokenSequence(Document document) {
        TokenHierarchy<Document> tokenHierarchy = TokenHierarchy.get(document);
        AbstractDocument ad = (AbstractDocument) document;
        ad.readLock();
        TokenSequence<MarkdownTokenId> ts;
        try {
            ts = tokenHierarchy.tokenSequence(MarkdownTokenId.language());
        } finally {
            ad.readUnlock();
        }
        return ts;
    }
View Full Code Here

        this.rule = rule;
    }

    @Override
    public Interval getWord(Document doc, int offset) {
        AbstractDocument adoc = (AbstractDocument) doc;
        int docLength = adoc.getLength();
        Segment segment = new Segment();
        segment.setPartialReturn(true);
        int start = locateWordStart(adoc, offset, docLength, segment);
        if (start == -1) {
            return null;
View Full Code Here

          for( int i = 0; i < collDocListeners.size(); i++ ) {
            oldDoc.removeDocumentListener( (DocumentListener) collDocListeners.get( i ));
//System.out.println( "remove " + collDocListeners.get( i ));
          }
          if( oldDoc instanceof AbstractDocument ) {
            final AbstractDocument adoc = (AbstractDocument) oldDoc;
            final DocumentEvent de =
              adoc.new DefaultDocumentEvent( oldDoc.getStartPosition().getOffset(),
                                             oldDoc.getLength(),
                                             DocumentEvent.EventType.REMOVE );
            // simulate clear
            for( int i = 0; i < collDocListeners.size(); i++ ) {
              final DocumentListener l = (DocumentListener) collDocListeners.get( i );
              l.removeUpdate( de );
            }
          }
        }
               
        // re-register new
        final Document newDoc = (Document) pce.getNewValue();
        if( newDoc != null ) {
          newDoc.addUndoableEditListener( TextView.this );
          for( int i = 0; i < collDocListeners.size(); i++ ) {
            newDoc.addDocumentListener( (DocumentListener) collDocListeners.get( i ));
//System.out.println( "add " + collDocListeners.get( i ));
          }
          if( newDoc instanceof AbstractDocument ) {
            final AbstractDocument adoc = (AbstractDocument) newDoc;
            final DocumentEvent de =
              adoc.new DefaultDocumentEvent( newDoc.getStartPosition().getOffset(),
                                             newDoc.getLength(),
                                             DocumentEvent.EventType.INSERT );
            // simulate clear
View Full Code Here

        phpModule = PhpModule.Factory.forFileObject(fileObject);
        if (phpModule == null || !WPUtils.isWP(phpModule)) {
            return false;
        }

        AbstractDocument ad = (AbstractDocument) doc;
        ad.readLock();
        try {
            TokenSequence<PHPTokenId> ts = LexUtilities.getPHPTokenSequence(doc, offset);
            if (ts == null) {
                return false;
            }
            ts.move(offset);
            ts.moveNext();
            Token<PHPTokenId> token = ts.token();
            target = token.text().toString();
            PHPTokenId tokenId = token.id();
            int targetOffset = ts.offset();
            if (!isValid(ts)) {
                return false;
            }
            if (tokenId == PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING) {
                int length = target.length();
                if (length > 2) {
                    startOffset = targetOffset;
                    endOffset = targetOffset + target.length();
                    target = NavUtils.dequote(target);
                    return true;
                }
            }
        } finally {
            ad.readUnlock();
        }
        target = ""; // NOI18N
        return false;
    }
View Full Code Here

     *
     * @param doc
     * @return token sequence
     */
    public static TokenSequence<PHPTokenId> getTokenSequence(Document doc) {
        AbstractDocument ad = (AbstractDocument) doc;
        ad.readLock();
        TokenSequence<PHPTokenId> ts = null;
        try {
            TokenHierarchy<Document> hierarchy = TokenHierarchy.get(doc);
            ts = hierarchy.tokenSequence(PHPTokenId.language());
        } finally {
            ad.readUnlock();
        }
        return ts;
    }
View Full Code Here

  }


  public void surroundSelection(String prefix, String suffix) {

    AbstractDocument document = (AbstractDocument) getDocument();
    String selection = getSelectedText();
    if (selection == null)
      selection = "";

    try {

      document.replace(getSelectionStart(),
          selection.length(),
          prefix + selection + suffix,
          null);

    } catch (BadLocationException e) {
View Full Code Here

TOP

Related Classes of javax.swing.text.AbstractDocument$ElementEdit

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.