KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > workingset > AdaptableToc


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.workingset;
12
13 import org.eclipse.help.*;
14 import org.w3c.dom.*;
15
16 /**
17  * Makes help resources adaptable and persistable
18  */

19 public class AdaptableToc extends AdaptableHelpResource {
20
21     protected AdaptableTopic[] children;
22
23     /**
24      * This constructor will be called when wrapping help resources.
25      */

26     AdaptableToc(IToc element) {
27         super(element);
28     }
29
30     /**
31      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
32      */

33     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
34         if (adapter == IToc.class)
35             return element;
36         return super.getAdapter(adapter);
37     }
38
39     public AdaptableHelpResource[] getChildren() {
40         if (children == null) {
41             ITopic[] topics = ((IToc) element).getTopics();
42             children = new AdaptableTopic[topics.length];
43             for (int i = 0; i < topics.length; i++) {
44                 children[i] = new AdaptableTopic(topics[i]);
45                 children[i].setParent(this);
46             }
47         }
48         return children;
49     }
50
51     /**
52      * @see org.eclipse.help.IToc#getTopic(java.lang.String)
53      */

54     public ITopic getTopic(String JavaDoc href) {
55         return ((IToc) element).getTopic(href);
56     }
57
58     /**
59      * @see org.eclipse.help.IToc#getTopics()
60      */

61     public ITopic[] getTopics() {
62         return ((IToc) element).getTopics();
63     }
64
65     public void saveState(Element element) {
66         element.setAttribute("toc", getHref()); //$NON-NLS-1$
67
}
68 }
69
Popular Tags