Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9d8b0266eae46232eca22cc7740ec7051d5e7fdb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package org.eclipse.help.internal.contributions.xml;

/*
 * Licensed Materials - Property of IBM,
 * WebSphere Studio Workbench
 * (c) Copyright IBM Corp 2000
 */

import java.util.*;
import org.xml.sax.*;
import org.eclipse.help.*;
import org.eclipse.help.internal.contributors.*;
import org.eclipse.help.internal.contributions.*;

/**
 * Context object, as defined in the map.xml
 */
public class HelpContext
	extends HelpContribution
	implements Context, IContext {
	private String description;
	/**
	 * Context constructor comment.
	 */
	public HelpContext(Attributes attrs) {
		super(attrs);
		///merge(contextNode);
	}
	/**
	 * Overriden to handle <description>
	 */
	public Contribution addChild(Contribution child) {
		/*
		if (child instanceof Topic)
			return super.addChild(child);
		else
			description = "some description. Change the <description> specs and parsing.";
		return null;
		*/
		return super.addChild(child);
	}
	public Context getContext(String id) {
		for (Iterator it = children.iterator(); it.hasNext();) {
			Context c = (Context) it.next();
			if (c.getID().equals(id))
				return c;
		}
		return null;
	}
	public String getDescription() {
		// description is already NL enabled when the XML files are parsed.
		return description;
	}
	/** List of topic ids */
	public IHelpTopic[] getRelatedTopics() {
		if (children.size() > 0) {
			IHelpTopic[] related = new IHelpTopic[children.size()];
			children.toArray(related);
			return related;
		} else {
			// signal empty topics. handled by calling class.
			return null;
		}
	}
	public String getText() {
		return getDescription();
	}
	/**
	 * Merges the current context with info from an XML
	 * definition of the context.
	 * Contexts are nested and maintained as trees;
	 */
	void merge(HelpContext context) {
		/*
		for (Iterator it=context.getChildren(); it.hasNext(); )
		{
			HelpContext child = (Context)it.next();
			if (child.getNodeType() != Node.ELEMENT_NODE) continue;
			Element childElement = (Element)child;
		
			if (childElement.getTagName().equals(ContextContributor.DESC_ELEM))
			{
				Node text = childElement.getFirstChild();
				if (text != null)
					description = text.getNodeValue();
		
				continue;
			}
		
			if (childElement.getTagName().equals(ContextContributor.RELATED_ELEM))
			{
				if (relatedTopics == null) relatedTopics = new Vector();
				relatedTopics.add(childElement.getAttribute(ContextContributor.RELATED_ATTR));
				continue;
			}
		
			if (!childElement.getTagName().equals(ContextContributor.CONTEXT_ELEM))
			{
				System.out.println("error: unexpected " + childElement.getTagName());
				continue;
			}
				
			String id = childElement.getAttribute(ContextContributor.ID_ATTR);
			HelpContext oldChildContext = (HelpContext)getContext(id);
			if (oldChildContext == null)
			{
				Context newChildContext = new HelpContext(childElement);
				addChild(newChildContext);
			}
			else
			{
				oldChildContext.merge(childElement);
			}
		}
		*/
	}
	public void setDescription(String s) {
		description = s;
	}
}

Back to the top