01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.text.toc;
11:
12: /**
13: * Toc - represents the root element of a Table of Contents
14: * The TOC root element, like TOC topics, can hold many child topics,
15: * links and anchors. Aside from being the root element of the TOC,
16: * the element differs from regular topics by having an optional
17: * anchor attribute that determines which anchors this TOC will plug
18: * into.
19: */
20: public class Toc extends TocTopic {
21:
22: private static final long serialVersionUID = 1L;
23:
24: /**
25: * Constructs a new Toc. Only takes a model,
26: * since the root element cannot have a parent.
27: *
28: * @param model The model associated with this TOC.
29: */
30: public Toc(TocModel model) {
31: super (model, ELEMENT_TOC);
32: setInTheModel(true);
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.pde.internal.core.text.plugin.PluginDocumentNode#isRoot()
37: */
38: public boolean isRoot() {
39: return true;
40: }
41:
42: /* (non-Javadoc)
43: * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
44: */
45: public int getType() {
46: return TYPE_TOC;
47: }
48:
49: /**
50: * @return the link associated with this topic, <br />
51: * or <code>null</code> if none exists.
52: */
53: public String getFieldRef() {
54: return getXMLAttributeValue(ATTRIBUTE_TOPIC);
55: }
56:
57: /**
58: * Change the value of the link field and
59: * signal a model change if needed.
60: *
61: * @param value The new page location to be linked by this topic
62: */
63: public void setFieldRef(String value) {
64: setXMLAttribute(ATTRIBUTE_TOPIC, value);
65: }
66:
67: /**
68: * @return the anchor path associated with this TOC
69: */
70: public String getFieldAnchorTo() {
71: return getXMLAttributeValue(ATTRIBUTE_LINK_TO);
72: }
73:
74: /**
75: * Change the value of the anchor field and
76: * signal a model change if needed.
77: *
78: * @param The new anchor path to associate with this TOC
79: */
80: public void setFieldAnchorTo(String name) {
81: setXMLAttribute(ATTRIBUTE_LINK_TO, name);
82: }
83: }
|