private static StyledDocument findDocument(DataObject dataObject) { EditorCookie ec = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class); if (ec == null) { return null; } StyledDocument doc; try { doc = ec.openDocument(); } catch (IOException ex) { return null; } return doc; }
private static StyledDocument findDocument(DataObject dataObject) { EditorCookie ec = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class); if (ec == null) { return null; } StyledDocument doc; try { doc = ec.openDocument(); } catch (IOException ex) { return null; } return doc; }
public javax.swing.text.StyledDocument openDocument() throws java.io.IOException { return currentEditorCookie().openDocument(); }
private static BaseDocument getDocument(final FileObject fo) throws DataObjectNotFoundException, IOException { BaseDocument doc = null; DataObject dObj = DataObject.find(fo); if (dObj != null) { EditorCookie editor = dObj.getLookup().lookup(EditorCookie.class); if (editor != null) { doc = (BaseDocument) editor.openDocument(); } } return doc; }
private Document getDocument(FileObject file) throws IOException { DataObject dobj = DataObject.find(file); EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class); if (ec != null) { return ec.openDocument(); } return null; }
private static StyledDocument findDocument(FileObject fo) { DataObject dataObject; try { dataObject = DataObject.find (fo); } catch (DataObjectNotFoundException ex) { return null; } EditorCookie ec = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class); if (ec == null) { return null; } StyledDocument doc; try { doc = ec.openDocument(); } catch (IOException ex) { return null; } return doc; }
private static StyledDocument findDocument(FileObject fo) { DataObject dataObject; try { dataObject = DataObject.find (fo); } catch (DataObjectNotFoundException ex) { return null; } EditorCookie ec = (EditorCookie) dataObject.getLookup().lookup(EditorCookie.class); if (ec == null) { return null; } StyledDocument doc; try { doc = ec.openDocument(); } catch (IOException ex) { return null; } return doc; }
@NbBundle.Messages("EditableTmpLocalFileStreamSource.open.confirm=File is too big. Do you really want to open it?") private Document getDocument() throws IOException { if (editorCookie == null) { return null; } try { return editorCookie.openDocument(); } catch (UserQuestionException uqe) { NotifyDescriptor.Confirmation desc = new NotifyDescriptor.Confirmation(uqe.getLocalizedMessage(), Bundle.EditableTmpLocalFileStreamSource_open_confirm(), NotifyDescriptor.Confirmation.OK_CANCEL_OPTION); if (DialogDisplayer.getDefault().notify(desc).equals(NotifyDescriptor.OK_OPTION)) { uqe.confirmed(); return editorCookie.openDocument(); } } return null; }
public HighlightAnnotatable(AttributeSet attrs, int start, int end, FileObject fo) { this.attrs = attrs; this.start = start; this.end = end; try { DataObject dobj = DataObject.find(fo); EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class); if (ec != null) { doc = ec.getDocument(); if (doc == null) { try { doc = ec.openDocument(); } catch (java.io.IOException ioex) {} } } } catch (DataObjectNotFoundException ex) { } }
public HighlightAnnotatable(AttributeSet attrs, int start, int end, FileObject fo) { this.attrs = attrs; this.start = start; this.end = end; try { DataObject dobj = DataObject.find(fo); EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class); if (ec != null) { doc = ec.getDocument(); if (doc == null) { try { doc = ec.openDocument(); } catch (java.io.IOException ioex) {} } } } catch (DataObjectNotFoundException ex) { } }
private Document getSourceDocument(StreamSource ss) { Document sdoc = null; FileObject fo = ss.getLookup().lookup(FileObject.class); if (fo != null) { try { DataObject dao = DataObject.find(fo); if (dao.getPrimaryFile() == fo) { EditorCookie ec = dao.getCookie(EditorCookie.class); if (ec != null) { sdoc = ec.openDocument(); } } } catch (Exception e) { // fallback to other means of obtaining the source } } else { sdoc = ss.getLookup().lookup(Document.class); } return sdoc; }
private StyledDocument getDocument(CompilationController ci) { // Do NOT use ci.getDocument(), since it returns null when the document is not loaded yet! FileObject file = ci.getFileObject(); if (file == null || !file.isValid()) { return null; } try { DataObject od = DataObject.find(file); EditorCookie ec = od.getLookup().lookup(EditorCookie.class); if (ec != null) { return ec.openDocument(); } else { return null; } } catch (DataObjectNotFoundException e) { return null; } catch (IOException ioex) { return null; } }
private void doParse(FileObject fo, boolean updateTask) throws IOException { assert ExclusiveAccess.getInstance().isCurrentThreadAccess(); BaseDocument document = (BaseDocument)getEditorCookie(fo).openDocument(); document.readLock(); try { doParse(fo, document, updateTask); } finally { document.readUnlock(); } }
public static void updateDocument(DataObject dobj, org.w3c.dom.Document doc) throws javax.swing.text.BadLocationException, java.io.IOException { org.openide.cookies.EditorCookie editor = (EditorCookie)dobj.getCookie(EditorCookie.class); javax.swing.text.Document textDoc = editor.getDocument(); if (textDoc == null) { textDoc = editor.openDocument(); } TomcatInstallUtil.updateDocument(textDoc,TomcatInstallUtil.getDocumentText(doc),"<Server"); //NOI18N SaveCookie savec = (SaveCookie) dobj.getCookie(SaveCookie.class); if (savec!=null) savec.save(); }
public void run(CompilationController cc) throws Exception { if (cancel.get()) return; HintsSettings.setPreferencesOverride(preferencesOverlay); DataObject d = DataObject.find(cc.getFileObject()); EditorCookie ec = d.getLookup().lookup(EditorCookie.class); Document doc = ec.openDocument(); try { handle.progress(FileUtil.getFileDisplayName(cc.getFileObject())); if (cc.toPhase(JavaSource.Phase.RESOLVED).compareTo(JavaSource.Phase.RESOLVED) < 0) { return; } handle.progress(f.incrementAndGet()); eds.addAll(new HintsTask().computeHints(cc)); } finally { HintsSettings.setPreferencesOverride(null); } } }, true);
/** Add the line offset into the jump history */ private void addPositionToJumpList(String url, Line l, int column) { DataObject dataObject = getDataObject(url); if (dataObject != null) { EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class); if (ec != null) { try { StyledDocument doc = ec.openDocument(); JEditorPane[] eps = ec.getOpenedPanes(); if (eps != null && eps.length > 0) { JumpList.addEntry(eps[0], NbDocument.findLineOffset(doc, l.getLineNumber()) + column); } } catch (java.io.IOException ioex) { ErrorManager.getDefault().notify(ioex); } } } }
/** Add the line offset into the jump history */ private void addPositionToJumpList(String url, Line l, int column) { DataObject dataObject = getDataObject (url); if (dataObject != null) { EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class); if (ec != null) { try { StyledDocument doc = ec.openDocument(); JEditorPane[] eps = ec.getOpenedPanes(); if (eps != null && eps.length > 0) { JumpList.addEntry(eps[0], NbDocument.findLineOffset(doc, l.getLineNumber()) + column); } } catch (java.io.IOException ioex) { ErrorManager.getDefault().notify(ioex); } } } }
/** Add the line offset into the jump history */ private void addPositionToJumpList(String url, Line l, int column) { DataObject dataObject = getDataObject (url); if (dataObject != null) { EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class); if (ec != null) { try { StyledDocument doc = ec.openDocument(); JEditorPane[] eps = ec.getOpenedPanes(); if (eps != null && eps.length > 0) { JumpList.addEntry(eps[0], NbDocument.findLineOffset(doc, l.getLineNumber()) + column); } } catch (java.io.IOException ioex) { ErrorManager.getDefault().notify(ioex); } } } }
public void run () { int definitionOffset = definition.getOffset (); try { DataObject dobj = DataObject.find (fo); EditorCookie ec = dobj.getCookie (EditorCookie.class); StyledDocument doc2 = ec.openDocument (); LineCookie lc = dobj.getCookie (LineCookie.class); Line.Set lineSet = lc.getLineSet (); Line line = lineSet.getCurrent (NbDocument.findLineNumber (doc2, definitionOffset)); int column = NbDocument.findLineColumn (doc2, definitionOffset); line.show (ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column); } catch (IOException ex) { ex.printStackTrace (); } } };
private static boolean openFileAtOffset(DataObject dataObject, int offset) throws IOException { EditorCookie ec = dataObject.getCookie(EditorCookie.class); LineCookie lc = dataObject.getCookie(LineCookie.class); if (ec != null && lc != null) { StyledDocument doc = ec.openDocument(); if (doc != null) { int lineNumber = NbDocument.findLineNumber(doc, offset); if (lineNumber != -1) { Line line = lc.getLineSet().getCurrent(lineNumber); if (line != null) { int lineOffset = NbDocument.findLineOffset(doc, lineNumber); int column = offset - lineOffset; line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column); return true; } } } } return false; }