本文整理了Java中org.openide.cookies.EditorCookie.openDocument()
方法的一些代码示例,展示了EditorCookie.openDocument()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EditorCookie.openDocument()
方法的具体详情如下:
包路径:org.openide.cookies.EditorCookie
类名称:EditorCookie
方法名:openDocument
[英]Get the document (and wait). See the org.openide.text for details on how this document should behave.
If the document is not yet loaded the method blocks until it is.
Note that this does not involve opening the actual Editor window. For that, use #open.
[中]获取文档(然后等待)。见组织。openide。有关此文档应如何操作的详细信息,请参阅文本。
如果文档尚未加载,则方法将阻塞,直到加载完毕。
注意这不涉及打开实际的编辑器窗口。为此,请使用#open。
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core
public javax.swing.text.StyledDocument openDocument() throws java.io.IOException {
return currentEditorCookie().openDocument();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-wizards
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-html-custom
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project
@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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
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) {
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui
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) {
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
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;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
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();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5
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();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-hints-analyzer
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);
代码示例来源:origin: dcaoyuan/nbscala
/** 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);
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui
/** 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);
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
/** 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);
}
}
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages
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 ();
}
}
};
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
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;
}
内容来源于网络,如有侵权,请联系作者删除!