1 11 package org.eclipse.help.ui.internal; 12 13 import java.util.StringTokenizer ; 14 15 import org.eclipse.help.HelpSystem; 16 import org.eclipse.help.IHelpResource; 17 import org.eclipse.help.ILiveHelpAction; 18 import org.eclipse.help.IToc; 19 import org.eclipse.help.ITopic; 20 import org.eclipse.help.ui.internal.views.AllTopicsPart; 21 import org.eclipse.help.ui.internal.views.ReusableHelpPart; 22 23 public class ShowInTocAction implements ILiveHelpAction { 24 25 private String path; 26 27 public void setInitializationString(String data) { 28 path = data; 29 } 30 31 public void run() { 32 final IHelpResource res = getHelpResource(); 33 final ReusableHelpPart helpPart = ReusableHelpPart.getLastActiveInstance(); 34 if (helpPart != null) { 35 helpPart.getControl().getDisplay().syncExec(new Runnable () { 36 public void run() { 37 helpPart.showPage(IHelpUIConstants.HV_ALL_TOPICS_PAGE); 38 AllTopicsPart part = (AllTopicsPart)helpPart.findPart(IHelpUIConstants.HV_TOPIC_TREE); 39 if (part != null) { 40 part.selectReveal(res); 41 } 42 } 43 }); 44 } 45 } 46 47 private IHelpResource getHelpResource() { 48 StringTokenizer tok = new StringTokenizer (path, "_"); int index = Integer.parseInt(tok.nextToken()); 50 IToc[] tocs = HelpSystem.getTocs(); 51 IToc toc = tocs[index]; 52 if (tok.hasMoreTokens()) { 53 ITopic topic = toc.getTopic(null); 54 while (tok.hasMoreTokens()) { 55 index = Integer.parseInt(tok.nextToken()); 56 topic = topic.getSubtopics()[index]; 57 } 58 return topic; 59 } 60 return toc; 61 } 62 } | Popular Tags |