| Summary: | [Help] isEnabled is not called for children of ITocs which are created by a toc provider | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Riccardo Mising name <riccardo.nimser> |
| Component: | User Assistance | Assignee: | Platform-UI-Inbox <Platform-UI-Inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | CC: | cgold, thorsten.richter |
| Version: | 3.7.1 | Keywords: | helpwanted |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | stalebug | ||
I took a look at your example and was able to reproduce the problem. The children of the Toc were not getting copied correctly when a Toc object was created from a SimpleToc. I think I know how to fix the problem, targeting 3.8M3. Fixed in master with commit message Bug 360983 - [Help] isEnabled is not called for children of ITocs which are created by a toc provider. This also enabled a previously disabled JUnit test to pass, testUserTopicWithFilteredChildren. The failing test should have alerted me to the problem earlier but I had thought that it was another instance of Bug 210024 which caused two other test cases in the same class to fail. Hallo Chris, your patch only works for primary tocs. If I contribute a toc which is linked to another toc only the first level entriesof my provited toc have the reference to the original source. The problem seems to be in the method importElement(UAElement) where the children of the element to import are set to NULL. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Build Identifier: M20110909-1335 The interface IUAElement defines a method isEnabled(IEvaluationContext context) which can be used to filter out elements. An example is, that a topic is only included in the TOC if plugin x.y.z is running. <topic href="html/subtopic.html" label="This topic is shown only if plugin x.y.z is running"> <enablement> <with variable="platform"> <test property="org.eclipse.core.runtime.isBundleInstalled" args="x.y.z"/> </with> </enablement> </topic> This defenition works as expected. However, if a toc provider is used, own implementation of the various interfaces (eg. IToc and ITopic) can be returned, which can determine the enabled state to their own logic. The problem is, that the isEnabled method of the implementation is never called by the bundles of the eclipse help. The reason seems to be the fact, that the help plugins create a wrapper for tocs (and all children via appendChildren(src.getChildren())) created by the toc provider whereat the method appendChild(UAElement uaElementToAppend) does not store the element as a child since the varibale children of the class UAElement is still null at this moment. At a later point the method getChildren() of the class UAElement is called by the help bundles and new UAElement of the corresponding type (eg. ITopic) are created without a connection to the original source element. Reproducible: Always Steps to Reproduce: 1. Implement a toc provider like the following and register it via the extension point "org.eclipse.help.toc". Note that the topic should be filtered out, since the isEnabled method returns false. public class SimpleTocProvider extends AbstractTocProvider { public ITocContribution[] getTocContributions( final String locale ) { ITocContribution contribution = new ITocContribution() { public String getContributorId() { return "TocProvider Example"; } public String getId() { return "SimpleTocProvider"; } public String getCategoryId() { return null; } public boolean isPrimary() { return true; } public IToc getToc() { return new SimpleToc(); } public String getLocale() { return locale; } public String[] getExtraDocuments() { return new String[ 0 ]; } public String getLinkTo() { return null; } }; return new ITocContribution[] { contribution }; } } public class SimpleToc implements IToc { private ITopic topic; public SimpleToc() { this.topic = new SimpleTopic(); } public boolean isEnabled(IEvaluationContext context) { return true; } public IUAElement[] getChildren() { return getTopics(); } public String getHref() { return null; } public String getLabel() { return "SimpleToc" } public ITopic[] getTopics() { return new ITopic[] { this.topic }; } public ITopic getTopic(String href) { if( href.equals( this.topic.getHref() ) ) return this.topic; return null; } } public class SimpleTopic implements ITopic { public boolean isEnabled(IEvaluationContext context) { System.out.println( "isEnabled is never called" ); return false; } public IUAElement[] getChildren() { return getSubtopics(); } public ITopic[] getSubtopics() { return new ITopic[0]; } public String getLabel() { return "SimpleTopic" } public String getHref() { return "simple.xhtml"; } } 2. Open the help of eclipse.