public Task prepareDocument() { return currentEditorCookie().prepareDocument(); }
/** 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; }
/** 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; } }
/** * 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; }
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()); }
editor.prepareDocument().waitFinished(1500); } catch (InterruptedException ie) {
EditorCookie ec = curentLine.getLookup().lookup(EditorCookie.class); if (ec != null) { ec.prepareDocument().waitFinished();