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.
Summary: | The file cannot be safely opened with encoding UTF-8. Do you want to continue opening it? | ||
---|---|---|---|
Product: | platform | Reporter: | everflux <everflux> |
Component: | Text | Assignee: | dgaitan1 |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jtulach, masaki |
Priority: | P3 | ||
Version: | 7.0.1 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
Bugsito
UTF-8 |
Description
everflux
2011-09-05 14:13:17 UTC
I guess we need an additional handling for UserQuestionException mechanism. Multiple UQEs can be thrown during opening of a single file e.g. first one for file being >1MB and another one for the case when file cannot be opened in UTF-8. Some codes (such as DiffSideBar) call uqe.confirmed() automatically supposing it's the >1MB case but it might be the encoding case as well so such code is wrong. However currently I'm not aware of any way of how to determine type of UQE. So we possibly need an enum (or a string id) to accompany each UQE giving type of the UQE. Also we should revisit all the UQE client codes and possibly use loops (instead of just a single try-catch): Document doc = null; do { try { doc = edCookie.openDocument(); } catch (UserQuestionException ex) { String type = ex.getType(); // new method if ("bigFile".equals(type)) { ex.confirmed(); } else { NotifyDescriptor nd = new NotifyDescriptor.Confirmation( e.getLocalizedMessage(), NotifyDescriptor.YES_NO_OPTION ); nd.setOptions(new Object[] { NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION }); Object res = DialogDisplayer.getDefault().notify(nd); if (NotifyDescriptor.OK_OPTION.equals(res)) { try { e.confirmed(); } catch (IOException ex1) { Exceptions.printStackTrace(ex1); } } } } while (doc == null); Yardo, what do you think? Or the loop would be in a method like StyledDocument NbDocument.openDocument(EditorCookie ec, boolean allowBigFiles, boolean ignoreBadEncoding) throws IOException The method would not throw UQE. In case the method would return null the user refused opening in the messagebox. I am getting this message on an existing Java file that contains the copyright symbol. Does not happen in Eclipse. Created attachment 117477 [details]
Bugsito
Tested the attached source file and the problem no longer happens in a recent dev build. Created attachment 157683 [details]
UTF-8
|