Community
Participate
Working Groups
Build ID: 3.3.2 (and seems to also still be broken in HEAD) Steps To Reproduce: As described in this News Posting: http://dev.eclipse.org/newslists/news.eclipse.platform.ua/msg00176.html (I couldn't find a bug filed...) The LinkTo field is not copied over when the IToc is converted to a Toc in TocManager.java:211 IToc toc = contrib[j].getToc(); contribution.setToc(toc instanceof Toc ? (Toc)toc : (Toc)UAElementFactory.newElement(toc)); contributions.add(contribution); The Toc constructor does this: public Toc(IToc src) { super(NAME, src); setHref(src.getHref()); setLabel(src.getLabel()); ITopic topic = src.getTopic(null); if (topic != null) { setTopic(topic.getHref()); } appendChildren(src.getChildren()); } It should probably also have a setLinkTo(src.getLinkTo()) as well. More information: The workaround for integrators is to have, in their ITocContribution implementation: public IToc getToc() { Toc t = new Toc(...); t.setLinkTo(getLinkTo()); return t; } but this requires referencing internal classes
I agree that this was an oversight and easy to fix. I will target RC1 for this bug because it is incorrectly functioning API and is easy to fix.
This is not as easy to fix as I had first though, IToc does not have a getLinkTo() function. Fixing this will have to wait until Eclipse 3.5.
Created attachment 99230 [details] Patch to setLinkTo when IToc is converted to Toc in TocManager Woops, as my class implemented both IToc and ITocContribution, must have missed setLinkTo in IToc... Attached is a patch containing an alternative solution -- setLinkTo when the Toc is created by TocManager.
I'm looking at fixing this bug for the next milestone. In order to fix this in a way that allows user to use only API classes (org.eclipse.help.internal.toc.Toc is internal) the API needs to be extended slightly. We have a similar situation with the new "icon" attricute in Toc and Topic and more attributes could be added in the future. My proposal is to create a new interface IUAElement2 which would allow access to the attributes. If your class which implemented IToc also implements IUAElement2 then the link_to attribute will get copied. Would this solution work for you? Here's what the new interface would look like. package org.eclipse.help; /** * Interface which extends IUAElement to allow access to attributes. This * enables copy operations to preserve all attributes when user defined * classes are used to implement IToc etc. */ public interface IUAElement2 extends IUAElement { /** * @param name the name of the attribute * @return the attribute value, or if the attribute is undefined the empty string. */ String getAttribute(String name); }
The patch is good, I committed the patch and added a new JUnit test to verify the behavior.