javax.swing.text.AbstractDocument.readUnlock()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中javax.swing.text.AbstractDocument.readUnlock()方法的一些代码示例,展示了AbstractDocument.readUnlock()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractDocument.readUnlock()方法的具体详情如下:
包路径:javax.swing.text.AbstractDocument
类名称:AbstractDocument
方法名:readUnlock

AbstractDocument.readUnlock介绍

暂无

代码示例

代码示例来源:origin: RPTools/maptool

/**
 * Invokes <code>preferenceChanged</code> on the event displatching thread.
 */
private void safePreferenceChanged() {
  if (SwingUtilities.isEventDispatchThread()) {
    Document doc = getDocument();
    if (doc instanceof AbstractDocument) {
      ((AbstractDocument) doc).readLock();
    }
    preferenceChanged(null, true, true);
    if (doc instanceof AbstractDocument) {
      ((AbstractDocument) doc).readUnlock();
    }
  } else {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        safePreferenceChanged();
      }
    });
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

static void refreshHack () {
    Iterator<Document> it = managers.keySet ().iterator ();
    while (it.hasNext ()) {
      AbstractDocument document = (AbstractDocument) it.next ();
      document.readLock ();
      try {
        MutableTextInput mti = (MutableTextInput) document.getProperty (MutableTextInput.class);
        mti.tokenHierarchyControl ().rebuild ();
      } finally {
        document.readUnlock ();
      }
//            final StyledDocument document = (StyledDocument) it.next ();
//            NbDocument.runAtomic (document, new Runnable () {
//                public void run() {
//                    MutableTextInput mti = (MutableTextInput) document.getProperty (MutableTextInput.class);
//                    mti.tokenHierarchyControl ().rebuild ();
//                }
//            });
    }
  }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

((AbstractDocument) context.getDocument()).readUnlock();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-highlight

private static boolean isPreprocessorConditionalBlock(AbstractDocument doc, int offset) {
  if (doc == null) {
    return false;
  }
  doc.readLock();
  try {
    TokenSequence<TokenId> ts = cppTokenSequence(doc, offset, false);
    if (ts != null) {
      int[] span = getPreprocConditionalOffsets(ts);
      if (isIn(span, offset)) {
        return true;
      }
    }
  } finally {
    doc.readUnlock();
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-lexer

/**
 * method should be called under document read lock
 * @param doc
 * @param offset
 * @return
 */
public static boolean isInPreprocessorDirective(Document doc, int offset) {
  AbstractDocument aDoc = (AbstractDocument)doc;
  aDoc.readLock();
  try {
    TokenSequence<TokenId> cppTokenSequence = CndLexerUtilities.getCppTokenSequenceWithoutEmbeddings(doc, offset);
    if (cppTokenSequence != null) {
      return cppTokenSequence.token().id() == CppTokenId.PREPROCESSOR_DIRECTIVE;
    }
  } finally {
    aDoc.readUnlock();
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-lexer

/**
 * method should be called under document read lock
 * @param doc
 * @param offset
 * @return
 */
public static boolean isInProCDirective(Document doc, int offset) {
  AbstractDocument aDoc = (AbstractDocument)doc;
  aDoc.readLock();
  try {
    TokenSequence<TokenId> cppTokenSequence = CndLexerUtilities.getCppTokenSequenceWithoutEmbeddings(doc, offset);
    if (cppTokenSequence != null) {
      return cppTokenSequence.token().id() == CppTokenId.PROC_DIRECTIVE;
    }
  } finally {
    aDoc.readUnlock();
  }
  return false;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

public void run() {
    AbstractDocument doc = getCurrentDocument ();
    TokenSequence ts = null;
    if (doc != null)
      try {
        doc.readLock ();
        TokenHierarchy tokenHierarchy = TokenHierarchy.get (doc);
        if (tokenHierarchy == null) return;
        ts = tokenHierarchy.tokenSequence ();
      } finally {
        doc.readUnlock ();
      }
    if (ts == null)
      tree.setModel (new DefaultTreeModel (new DefaultMutableTreeNode ()));
    else
      tree.setModel (new DefaultTreeModel (new TSNode (null, ts, null, 0, 0)));
    JEditorPane editor = getCurrentEditor ();
    if (editor != null) {
      int position = getCurrentEditor ().getCaret ().getDot ();
      selectPath (position);
    }
  }
});

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

adoc.readUnlock();

代码示例来源:origin: khuxtable/seaglass

} finally {
  if (doc instanceof AbstractDocument) {
    ((AbstractDocument) doc).readUnlock();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

} finally {
  if (doc instanceof AbstractDocument) {
    ((AbstractDocument) doc).readUnlock();

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void propertyChange(java.beans.PropertyChangeEvent evt) {
  JTextComponent component = (JTextComponent)getContainer();
  if (component==null || evt==null || 
    !EditorUI.LINE_HEIGHT_CHANGED_PROP.equals(evt.getPropertyName())) return;
  
  AbstractDocument doc = (AbstractDocument)getDocument();
  if (doc!=null) {
    doc.readLock();
    try{
      LockView lockView = LockView.get(this);
      lockView.lock();
      try {
        rebuild(0, getViewCount());
      } finally {
        lockView.unlock();
      }
    } finally {
      doc.readUnlock();
    }
  component.revalidate();
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void actionPerformed(ActionEvent evt) {
    AbstractDocument doc = (AbstractDocument)getDocument();
    if (doc!=null) {
      doc.readLock();
      try {
        LockView lockView = LockView.get(DrawEngineDocView.this);
        if (lockView != null) { // if there is no lock view no async layout is done
          lockView.lock();
          try {
            setEstimatedSpan(false);
          } finally {
            lockView.unlock();
          }
        }
      } finally {
        doc.readUnlock();
      }
    }
  }
});

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

public Object evaluate (Context context) {
  if (context instanceof SyntaxContext) {
    Object l = ((SyntaxContext) context).getASTPath ().getLeaf ();
    if (l instanceof ASTNode)
      return evaluate ((ASTNode) l);
    if (l instanceof ASTToken)
      return evaluate ((ASTToken) l);
  } else {
    AbstractDocument document = (AbstractDocument) context.getDocument ();
    document.readLock ();
    ASTToken stoken = null;
    try {
      TokenSequence tokenSequence = Utils.getTokenSequence (document, context.getOffset ());
      Token token = tokenSequence.token ();
      if (token != null) 
        stoken = ASTToken.create (
          null,
          token.id ().ordinal (),
          token.text ().toString (),
          tokenSequence.offset ()
        );
    } finally {
      document.readUnlock ();
    }
    return evaluate (stoken);
  }
  throw new IllegalArgumentException ();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

((AbstractDocument) context.getDocument()).readUnlock();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

((AbstractDocument) context.getDocument()).readUnlock();

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void run() {
  AbstractDocument doc = (AbstractDocument)getDocument();
  if (doc!=null){
    doc.readLock();
    try {
      LockView lockView = LockView.get(GapDocumentView.this);
      if (lockView != null) {
        lockView.lock();
        try {
          layoutLock();
          try {
            updateView(lockView);
          } finally {
            updateLayout();
            layoutUnlock();
          }
        } finally {
          lockView.unlock();
        }
      } // missing lock view => likely disconnected from hierarchy
    } finally {
      doc.readUnlock();
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-highlight

doc.readUnlock();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rhtml

public int [] findMatches() throws InterruptedException, BadLocationException {
  ((AbstractDocument) context.getDocument()).readLock();
  try {
    BaseDocument doc = (BaseDocument) context.getDocument();
    int offset = context.getSearchOffset();
    char[] origin = doc.getChars(offset, 1);
    
    if (isRhtmlStartTag(doc, offset, origin)) {
      int limit = doc.getText().length();
      int matching = matchChar(doc, offset, limit, '>');
      while (matching != -1 && doc.getChars(matching - 1, 1)[0] == '=') {
        matching = matchChar(doc, matching + 1, limit,  '>');
      }
      return new int[] {matching, matching + 1};
    } else if (isRhtmlEndTag(doc, offset, origin)) {
      int limit = 0;
      int matching = matchChar(doc, offset, limit, '<');
      if (matching != -1) {
        return new int[] {matching, matching + 1};
      }
    }
  } finally {
    ((AbstractDocument) context.getDocument()).readUnlock();
  }
  return delegate.findMatches();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

adoc.readUnlock();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

((AbstractDocument) context.getDocument()).readUnlock();

相关文章