org.openide.cookies.EditorCookie.prepareDocument()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(88)

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

EditorCookie.prepareDocument介绍

[英]Should load the document into memory. This is done in a different thread. A task for the thread is returned so other components can test whether the loading is finished or not.

Note that this does not involve opening the actual Editor window. For that, use #open.
[中]应该将文档加载到内存中。这是在不同的线程中完成的。返回线程的任务,以便其他组件可以测试加载是否完成。
注意这不涉及打开实际的编辑器窗口。为此,请使用#open。

代码示例

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

public Task prepareDocument() {
  return currentEditorCookie().prepareDocument();
}

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

/** This method returns a BaseDocument for the configuration file. If the configuration
 *  file is not opened, then the document is not created yet and this method push to load 
 *  the document to the memory. 
 */
public static BaseDocument getBaseDocument(DataObject dataObject){
  BaseDocument document = null;
  
  if (dataObject != null){
    synchronized (dataObject){
      EditorCookie editor = dataObject.getLookup().lookup(EditorCookie.class);
      if (editor != null){
        document = (BaseDocument)editor.getDocument();
        if (document == null){
          Task preparing = editor.prepareDocument();
          preparing.waitFinished();
          document = (BaseDocument)editor.getDocument();
        }
      }
    }
  }
  return document;
}

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

/** This method returns a BaseDocument for the configuration file. If the configuration
   *  file is not opened, then the document is not created yet and this method push to load 
   *  the document to the memory. 
   */
  public static BaseDocument getBaseDocument(DataObject dataObject){
    BaseDocument document = null;
    
    if (dataObject != null){
      synchronized (dataObject){
        EditorCookie editor = dataObject.getLookup().lookup(EditorCookie.class);
        if (editor != null){
          document = (BaseDocument)editor.getDocument();
          if (document == null){
            Task preparing = editor.prepareDocument();
            preparing.waitFinished();
            document = (BaseDocument)editor.getDocument();
          }
        }
      }
    }
    return document;
  }
}

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

/**
 * opens document even if it is very big by silently confirming open
 * @param cookie
 * @return
 */
public static StyledDocument openDocument(EditorCookie cookie) {
  if (cookie == null) {
    return null;
  }
  StyledDocument document = null;
  try {
    try {
      document = cookie.openDocument();
    } catch (UserQuestionException e) {
      e.confirmed();
      document = cookie.openDocument();
    }
  } catch(UserQuestionException e) {
    // no need to report
  } catch (IOException ex) {
    Exceptions.printStackTrace(ex);
  }
  cookie.prepareDocument().waitFinished();
  return document;
}

代码示例来源:origin: dcaoyuan/nbscala

private static int findNumLines(String url) {
  FileObject file;
  try {
    file = URLMapper.findFileObject (new URL(url));
  } catch (MalformedURLException e) {
    return 0;
  }
  if (file == null) return 0;
  DataObject dataObject;
  try {
    dataObject = DataObject.find (file);
  } catch (DataObjectNotFoundException ex) {
    return 0;
  }
  EditorCookie ec = (EditorCookie) dataObject.getCookie(EditorCookie.class);
  if (ec == null) return 0;
  ec.prepareDocument().waitFinished();
  Document d = ec.getDocument();
  if (!(d instanceof StyledDocument)) return 0;
  StyledDocument sd = (StyledDocument) d;
  return NbDocument.findLineNumber(sd, sd.getLength());
}

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

editor.prepareDocument().waitFinished(1500);
} catch (InterruptedException ie) {

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

EditorCookie ec = curentLine.getLookup().lookup(EditorCookie.class);
if (ec != null) {
  ec.prepareDocument().waitFinished();

相关文章