| Summary: | [Help][Context] NPE in ContextHelpDialog when context has no description | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Anton Leherbauer <aleherb+eclipse> | ||||
| Component: | User Assistance | Assignee: | Chris Goldthorpe <cgold> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | minor | ||||||
| Priority: | P3 | CC: | cgold, mober.at+eclipse | ||||
| Version: | 3.6 | ||||||
| Target Milestone: | 3.7 M6 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
CQ:WIND00254022 Specification of the org.eclipse.help.contexts extension point and the respective contexts.xml file format clearly says that the <description> element is optional: http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/ua_help_context_xml.htm "Each context element can have an optional <description> element ..." Running into an NPE therefore violates the spec. Workaround: have an empty <description></description> element in contexts.xml This is easy to fix in Eclipse 3.7 but too late for 3.6.2. The way the code is written the intention is to show this as the description if none is provided. "No description was provided for this user interface element." I am not sure that this has any value to the user who is trying to get some help, maybe it would be better to show an empty description rather than this message. My expectation is that when there's a SINGLE context contributed only, and no description exists, it directly navigates into the help rather than showing an infopop first. If there is no description and exactly one topic the help system will indeed take you straight to the help topic. This bug only shows when there are two or more topics and no description. Then I would suggest doing something similar as when NLS is not available, ie print the internal context ID as pert of the "description missing" message when there's 2 or more contexts available. Created attachment 188540 [details]
Patch
The situation is slightly different from NLS not available in that having no description is not considered and error. Here's a patch that eliminates the NPE.
Patch committed to HEAD, Fixed. |
Opening a context which does not contain a description element will cause an NPE in the ContextHelpDialog: java.lang.NullPointerException at org.eclipse.help.ui.internal.ContextHelpDialog.createInfoArea(ContextHelpDialog.java:231) at org.eclipse.help.ui.internal.ContextHelpDialog.createContents(ContextHelpDialog.java:213) at org.eclipse.help.ui.internal.ContextHelpDialog.<init>(ContextHelpDialog.java:171) at org.eclipse.help.ui.internal.DefaultHelpUI.displayContextAsInfopop(DefaultHelpUI.java:413) at org.eclipse.help.ui.internal.DefaultHelpUI.displayContext(DefaultHelpUI.java:308) at org.eclipse.help.ui.internal.DefaultHelpUI.displayContext(DefaultHelpUI.java:289) at org.eclipse.ui.internal.help.WorkbenchHelpSystem.displayContext(WorkbenchHelpSystem.java:905) at org.eclipse.ui.internal.help.WorkbenchHelpSystem.displayHelp(WorkbenchHelpSystem.java:933) Looking at the code in ContextHelpDialog line 228ff, it looks like the null checks are somewhat inconsequent. The second if is quite useless, because at this point styledText is either non-null or a NPE was already thrown. Note also the useless duplicate assignment. if (styledText == null) { styledText = context.getText(); styledText = context.getText(); styledText= styledText.replaceAll("<b>","<@#\\$b>"); styledText= styledText.replaceAll("</b>", "</@#\\$b>"); } if (styledText == null) { // no description found in context objects. styledText = Messages.ContextHelpPart_noDescription; }