1 /*******************************************************************************
2  * Copyright (c) 2009, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 
15 package org.eclipse.ua.tests.help.toc;
16 
17 import org.eclipse.help.AbstractTocProvider;
18 import org.eclipse.help.IToc;
19 import org.eclipse.help.ITocContribution;
20 import org.eclipse.ua.tests.help.other.UserToc;
21 import org.eclipse.ua.tests.help.other.UserTopic;
22 
23 public class UaTestTocProvider extends AbstractTocProvider {
24 
25 	UserToc toc;
26 	TocContribution contribution;
27 	private ITocContribution[] contributions;
28 
29 	private class TocContribution implements ITocContribution {
30 
31 		@Override
getCategoryId()32 		public String getCategoryId() {
33 			return null;
34 		}
35 
36 		@Override
getContributorId()37 		public String getContributorId() {
38 			return "org.eclipse.ua.tests";
39 		}
40 
41 		@Override
getExtraDocuments()42 		public String[] getExtraDocuments() {
43 			return new String[0];
44 		}
45 
46 		@Override
getId()47 		public String getId() {
48 			return "generatedToc";
49 		}
50 
51 		@Override
getLinkTo()52 		public String getLinkTo() {
53 			return "PLUGINS_ROOT/org.eclipse.ua.tests/data/help/toc/root.xml#generatedContent";
54 		}
55 
56 		@Override
getLocale()57 		public String getLocale() {
58 			return null;
59 		}
60 
61 		@Override
getToc()62 		public IToc getToc() {
63 			return toc;
64 		}
65 
66 		@Override
isPrimary()67 		public boolean isPrimary() {
68 			return false;
69 		}
70 
71 	}
72 
UaTestTocProvider()73 	public UaTestTocProvider() {
74 		toc = new UserToc("Generated Toc", null, true);
75 		UserTopic parentTopic = new UserTopic("Generated Parent",
76 				"generated/Generated+Parent/Parent+page+with+searchable+word+egrology+.html", true);
77 		for (int i = 1; i <= 4; i++) {
78 			UserTopic childTopic = new UserTopic("Generated Child " + i,
79 					"generated/Generated+Child" + i +
80 					"/Child+topic+" + i + ".html", true);
81 			parentTopic.addTopic(childTopic);
82 		}
83 		toc.addTopic(parentTopic);
84 		contribution = new TocContribution();
85 		contributions = new ITocContribution[] { contribution };
86 	}
87 
88 	@Override
getTocContributions(String locale)89 	public ITocContribution[] getTocContributions(String locale) {
90 		return contributions;
91 	}
92 
93 }
94