Lines 11-23
Link Here
|
11 |
|
11 |
|
12 |
package org.eclipse.ui.internal.dialogs; |
12 |
package org.eclipse.ui.internal.dialogs; |
13 |
|
13 |
|
14 |
import org.eclipse.ui.internal.*; |
14 |
import java.io.IOException; |
15 |
import org.eclipse.core.runtime.*; |
15 |
import java.io.InputStream; |
16 |
import org.xml.sax.*; |
16 |
import java.util.ArrayList; |
17 |
import org.apache.xerces.parsers.*; |
17 |
|
18 |
import org.xml.sax.helpers.*; |
18 |
import javax.xml.parsers.FactoryConfigurationError; |
19 |
import java.io.*; |
19 |
import javax.xml.parsers.ParserConfigurationException; |
20 |
import java.util.*; |
20 |
import javax.xml.parsers.SAXParser; |
|
|
21 |
import javax.xml.parsers.SAXParserFactory; |
22 |
|
23 |
import org.eclipse.core.runtime.IStatus; |
24 |
import org.eclipse.core.runtime.Status; |
25 |
|
26 |
import org.eclipse.ui.internal.WorkbenchMessages; |
27 |
import org.eclipse.ui.internal.WorkbenchPlugin; |
28 |
|
29 |
import org.xml.sax.Attributes; |
30 |
import org.xml.sax.ContentHandler; |
31 |
import org.xml.sax.InputSource; |
32 |
import org.xml.sax.Locator; |
33 |
import org.xml.sax.SAXException; |
34 |
import org.xml.sax.helpers.DefaultHandler; |
35 |
|
21 |
/** |
36 |
/** |
22 |
* A parser for the the welcome page |
37 |
* A parser for the the welcome page |
23 |
*/ |
38 |
*/ |
Lines 67-73
Link Here
|
67 |
} |
82 |
} |
68 |
public void skippedEntity(String name) throws SAXException { |
83 |
public void skippedEntity(String name) throws SAXException { |
69 |
} |
84 |
} |
70 |
public void startDocument() throws org.xml.sax.SAXException { |
85 |
public void startDocument() throws SAXException { |
71 |
} |
86 |
} |
72 |
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { |
87 |
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { |
73 |
} |
88 |
} |
Lines 83-93
Link Here
|
83 |
if (localName.equals(TAG_INTRO)) { |
98 |
if (localName.equals(TAG_INTRO)) { |
84 |
ItemHandler h = new IntroItemHandler(); |
99 |
ItemHandler h = new IntroItemHandler(); |
85 |
h.setParent(WelcomePageHandler.this); |
100 |
h.setParent(WelcomePageHandler.this); |
86 |
parser.setContentHandler(h); |
101 |
parser.getXMLReader().setContentHandler(h); |
87 |
} else if (localName.equals(TAG_ITEM)) { |
102 |
} else if (localName.equals(TAG_ITEM)) { |
88 |
ItemHandler h = new ItemHandler(); |
103 |
ItemHandler h = new ItemHandler(); |
89 |
h.setParent(WelcomePageHandler.this); |
104 |
h.setParent(WelcomePageHandler.this); |
90 |
parser.setContentHandler(h); |
105 |
parser.getXMLReader().setContentHandler(h); |
91 |
} |
106 |
} |
92 |
} |
107 |
} |
93 |
} |
108 |
} |
Lines 113-119
Link Here
|
113 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
128 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
114 |
if (localName.equals(TAG_BOLD)) { |
129 |
if (localName.equals(TAG_BOLD)) { |
115 |
boldRanges.add(new int[] {textStart, offset - textStart}); |
130 |
boldRanges.add(new int[] {textStart, offset - textStart}); |
116 |
parser.setContentHandler(parent); |
131 |
parser.getXMLReader().setContentHandler(parent); |
117 |
} |
132 |
} |
118 |
} |
133 |
} |
119 |
} |
134 |
} |
Lines 128-134
Link Here
|
128 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
143 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
129 |
if (localName.equals(TAG_ACTION)) { |
144 |
if (localName.equals(TAG_ACTION)) { |
130 |
actionRanges.add(new int[] {textStart, offset - textStart}); |
145 |
actionRanges.add(new int[] {textStart, offset - textStart}); |
131 |
parser.setContentHandler(parent); |
146 |
parser.getXMLReader().setContentHandler(parent); |
132 |
} |
147 |
} |
133 |
} |
148 |
} |
134 |
} |
149 |
} |
Lines 143-149
Link Here
|
143 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
158 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
144 |
if (localName.equals(TAG_TOPIC)) { |
159 |
if (localName.equals(TAG_TOPIC)) { |
145 |
helpRanges.add(new int[] {textStart, offset - textStart}); |
160 |
helpRanges.add(new int[] {textStart, offset - textStart}); |
146 |
parser.setContentHandler(parent); |
161 |
parser.getXMLReader().setContentHandler(parent); |
147 |
} |
162 |
} |
148 |
} |
163 |
} |
149 |
} |
164 |
} |
Lines 185-207
Link Here
|
185 |
if (localName.equals(TAG_BOLD)) { |
200 |
if (localName.equals(TAG_BOLD)) { |
186 |
BoldHandler h = new BoldHandler(); |
201 |
BoldHandler h = new BoldHandler(); |
187 |
h.setParent(ItemHandler.this); |
202 |
h.setParent(ItemHandler.this); |
188 |
parser.setContentHandler(h); |
203 |
parser.getXMLReader().setContentHandler(h); |
189 |
} else if(localName.equals(TAG_ACTION)) { |
204 |
} else if(localName.equals(TAG_ACTION)) { |
190 |
ActionHandler h = new ActionHandler(atts.getValue(ATT_PLUGIN_ID), atts.getValue(ATT_CLASS)); |
205 |
ActionHandler h = new ActionHandler(atts.getValue(ATT_PLUGIN_ID), atts.getValue(ATT_CLASS)); |
191 |
h.setParent(ItemHandler.this); |
206 |
h.setParent(ItemHandler.this); |
192 |
parser.setContentHandler(h); |
207 |
parser.getXMLReader().setContentHandler(h); |
193 |
} else if(localName.equals(TAG_PARAGRAPH)) { |
208 |
} else if(localName.equals(TAG_PARAGRAPH)) { |
194 |
wrapStart = textStart; |
209 |
wrapStart = textStart; |
195 |
} else if(localName.equals(TAG_TOPIC)) { |
210 |
} else if(localName.equals(TAG_TOPIC)) { |
196 |
TopicHandler h = new TopicHandler(atts.getValue(ATT_ID), atts.getValue(ATT_HREF)); |
211 |
TopicHandler h = new TopicHandler(atts.getValue(ATT_ID), atts.getValue(ATT_HREF)); |
197 |
h.setParent(ItemHandler.this); |
212 |
h.setParent(ItemHandler.this); |
198 |
parser.setContentHandler(h); |
213 |
parser.getXMLReader().setContentHandler(h); |
199 |
} |
214 |
} |
200 |
} |
215 |
} |
201 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
216 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
202 |
if (localName.equals(TAG_ITEM)) { |
217 |
if (localName.equals(TAG_ITEM)) { |
203 |
items.add(constructWelcomeItem()); |
218 |
items.add(constructWelcomeItem()); |
204 |
parser.setContentHandler(parent); |
219 |
parser.getXMLReader().setContentHandler(parent); |
205 |
} else if (localName.equals(TAG_PARAGRAPH)) { |
220 |
} else if (localName.equals(TAG_PARAGRAPH)) { |
206 |
wrapRanges.add(new int[] {wrapStart, offset - wrapStart}); |
221 |
wrapRanges.add(new int[] {wrapStart, offset - wrapStart}); |
207 |
} |
222 |
} |
Lines 211-217
Link Here
|
211 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
226 |
public void endElement (String namespaceURI, String localName, String qName) throws SAXException { |
212 |
if (localName.equals(TAG_INTRO)) { |
227 |
if (localName.equals(TAG_INTRO)) { |
213 |
introItem = constructWelcomeItem(); |
228 |
introItem = constructWelcomeItem(); |
214 |
parser.setContentHandler(parent); |
229 |
parser.getXMLReader().setContentHandler(parent); |
215 |
} else if (localName.equals(TAG_PARAGRAPH)) { |
230 |
} else if (localName.equals(TAG_PARAGRAPH)) { |
216 |
wrapRanges.add(new int[] {wrapStart, offset - wrapStart}); |
231 |
wrapRanges.add(new int[] {wrapStart, offset - wrapStart}); |
217 |
} |
232 |
} |
Lines 220-232
Link Here
|
220 |
/** |
235 |
/** |
221 |
* Creates a new welcome parser. |
236 |
* Creates a new welcome parser. |
222 |
*/ |
237 |
*/ |
223 |
public WelcomeParser() { |
238 |
public WelcomeParser() throws ParserConfigurationException, SAXException, FactoryConfigurationError { |
224 |
super(); |
239 |
super(); |
225 |
parser = new SAXParser(); |
240 |
SAXParserFactory factory = SAXParserFactory.newInstance(); |
226 |
parser.setContentHandler(this); |
241 |
factory.setFeature("http://xml.org/sax/features/namespaces", true); |
227 |
parser.setDTDHandler(this); |
242 |
parser = factory.newSAXParser(); |
228 |
parser.setEntityResolver(this); |
243 |
|
229 |
parser.setErrorHandler(this); |
244 |
parser.getXMLReader().setContentHandler(this); |
|
|
245 |
parser.getXMLReader().setDTDHandler(this); |
246 |
parser.getXMLReader().setEntityResolver(this); |
247 |
parser.getXMLReader().setErrorHandler(this); |
230 |
} |
248 |
} |
231 |
/** |
249 |
/** |
232 |
* Returns the intro item. |
250 |
* Returns the intro item. |
Lines 257-263
Link Here
|
257 |
*/ |
275 |
*/ |
258 |
public void parse(InputStream is) { |
276 |
public void parse(InputStream is) { |
259 |
try { |
277 |
try { |
260 |
parser.parse(new InputSource(is)); |
278 |
parser.parse(new InputSource(is), this); |
261 |
} catch (SAXException e) { |
279 |
} catch (SAXException e) { |
262 |
IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 1, WorkbenchMessages.getString("WelcomeParser.parseException"), e); //$NON-NLS-1$ |
280 |
IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 1, WorkbenchMessages.getString("WelcomeParser.parseException"), e); //$NON-NLS-1$ |
263 |
WorkbenchPlugin.log(WorkbenchMessages.getString("WelcomeParser.parseError"), status); //$NON-NLS-1$ |
281 |
WorkbenchPlugin.log(WorkbenchMessages.getString("WelcomeParser.parseError"), status); //$NON-NLS-1$ |
Lines 274-280
Link Here
|
274 |
WelcomeContentHandler h = new WelcomePageHandler(atts.getValue(ATT_TITLE)); |
292 |
WelcomeContentHandler h = new WelcomePageHandler(atts.getValue(ATT_TITLE)); |
275 |
format = atts.getValue(ATT_FORMAT); |
293 |
format = atts.getValue(ATT_FORMAT); |
276 |
h.setParent(this); |
294 |
h.setParent(this); |
277 |
parser.setContentHandler(h); |
295 |
parser.getXMLReader().setContentHandler(h); |
278 |
} |
296 |
} |
279 |
} |
297 |
} |
280 |
} |
298 |
} |