This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
openDocument is programmatic way for opening document without creating editor window => there must not be UI dialog with question/notification about big size of underlying document in case of standard: EditorCookie cookie = (EditorCookie)dataObject.getCookie(EditorCookie.class); StyledDocument doc = cookie.openDocument(); When tried to get document using above approach with big size I've got exception. org.openide.text.DataEditorSupport$Env$1ME: The file sql_yacc.cc seems to be too large (1 Mb) to safely open. Opening the file could cause OutOfMemoryError, which would make the IDE unusable. Do you really want to open it? at org.openide.text.DataEditorSupport$Env.inputStream(DataEditorSupport.java:717) at org.openide.text.CloneableEditorSupport.loadDocument(CloneableEditorSupport.java:1869) at org.openide.text.CloneableEditorSupport.access$2200(CloneableEditorSupport.java:120) at org.openide.text.CloneableEditorSupport$Listener.run(CloneableEditorSupport.java:2624) at org.openide.text.CloneableEditorSupport$1.doRun(CloneableEditorSupport.java:594) at org.openide.text.CloneableEditorSupport$1.run(CloneableEditorSupport.java:565) at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:251) at org.openide.text.NbDocument.runAtomic(NbDocument.java:384) at org.openide.text.CloneableEditorSupport$1.doRun(CloneableEditorSupport.java:575) at org.openide.text.CloneableEditorSupport$1.run(CloneableEditorSupport.java:565) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
The exception that you get is not waning about opening big file in Editor. It is about just reading file in memory. "Open" file here means reading in memory. Such mechanism prevents allocation a huge amount of memory. And it doesn't concern to any UI. So this exception is normal way to warn client ( user or developer that uses this API ) about such situation. You can catch this exception ( I believe this is exactly what you need to do ) for avoiding dialog . In "try/catch" block you can use method "confirmed" http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/UserQuestionException.html#confirmed() and then call openDocument() once again. In this case you will not get this exception one more time. If you don't catch this exception then it will be shown in dialog.
I did exactly with try/catch/confirm If it is expected behavior, let's close bug after updating the correspondent JavaDoc for methods which could throw this exception (to help other people). Thanks, Vladimir.
Agreed.
Javadoc comments are added to EditorCookie.openDocument and ClonableEditorSupport.openDocument() methods. changeset: 74244:f26672d69b54
See also: issue 138281