View | Details | Raw Unified | Return to bug 44868 | Differences between
and this patch

Collapse All | Expand All

(-).classpath (-1 lines)
Lines 2-8 Link Here
2
<classpath>
2
<classpath>
3
    <classpathentry kind="src" path="Eclipse UI/"/>
3
    <classpathentry kind="src" path="Eclipse UI/"/>
4
    <classpathentry kind="src" path="Eclipse UI Editor Support/"/>
4
    <classpathentry kind="src" path="Eclipse UI Editor Support/"/>
5
    <classpathentry kind="src" path="/org.apache.xerces"/>
6
    <classpathentry kind="src" path="/org.eclipse.core.resources"/>
5
    <classpathentry kind="src" path="/org.eclipse.core.resources"/>
7
    <classpathentry kind="src" path="/org.eclipse.update.core"/>
6
    <classpathentry kind="src" path="/org.eclipse.update.core"/>
8
    <classpathentry kind="src" path="/org.eclipse.help"/>
7
    <classpathentry kind="src" path="/org.eclipse.help"/>
(-).project (-1 lines)
Lines 3-9 Link Here
3
	<name>org.eclipse.ui.workbench</name>
3
	<name>org.eclipse.ui.workbench</name>
4
	<comment></comment>
4
	<comment></comment>
5
	<projects>
5
	<projects>
6
		<project>org.apache.xerces</project>
7
		<project>org.eclipse.core.boot</project>
6
		<project>org.eclipse.core.boot</project>
8
		<project>org.eclipse.core.resources</project>
7
		<project>org.eclipse.core.resources</project>
9
		<project>org.eclipse.core.runtime</project>
8
		<project>org.eclipse.core.runtime</project>
(-)plugin.xml (-1 lines)
Lines 12-18 Link Here
12
      </library>
12
      </library>
13
   </runtime>
13
   </runtime>
14
   <requires>
14
   <requires>
15
      <import plugin="org.apache.xerces"/>
16
      <import plugin="org.eclipse.core.resources"/>
15
      <import plugin="org.eclipse.core.resources"/>
17
      <import plugin="org.eclipse.update.core"/>
16
      <import plugin="org.eclipse.update.core"/>
18
      <import plugin="org.eclipse.help"/>
17
      <import plugin="org.eclipse.help"/>
(-)Eclipse UI/org/eclipse/ui/XMLMemento.java (-12 / +51 lines)
Lines 18-30 Link Here
18
18
19
import javax.xml.parsers.DocumentBuilder;
19
import javax.xml.parsers.DocumentBuilder;
20
import javax.xml.parsers.DocumentBuilderFactory;
20
import javax.xml.parsers.DocumentBuilderFactory;
21
import javax.xml.parsers.FactoryConfigurationError;
21
import javax.xml.parsers.ParserConfigurationException;
22
import javax.xml.parsers.ParserConfigurationException;
22
import org.apache.xerces.dom.DocumentImpl;
23
import javax.xml.transform.OutputKeys;
23
import org.apache.xml.serialize.OutputFormat;
24
import javax.xml.transform.Result;
24
import org.apache.xml.serialize.Serializer;
25
import javax.xml.transform.Source;
25
import org.apache.xml.serialize.SerializerFactory;
26
import javax.xml.transform.Transformer;
27
import javax.xml.transform.TransformerConfigurationException;
28
import javax.xml.transform.TransformerException;
29
import javax.xml.transform.TransformerFactory;
30
import javax.xml.transform.TransformerFactoryConfigurationError;
31
import javax.xml.transform.dom.DOMSource;
32
import javax.xml.transform.stream.StreamResult;
33
26
import org.eclipse.ui.internal.WorkbenchMessages;
34
import org.eclipse.ui.internal.WorkbenchMessages;
27
import org.eclipse.ui.internal.WorkbenchPlugin;
35
import org.eclipse.ui.internal.WorkbenchPlugin;
36
28
import org.w3c.dom.Attr;
37
import org.w3c.dom.Attr;
29
import org.w3c.dom.Document;
38
import org.w3c.dom.Document;
30
import org.w3c.dom.Element;
39
import org.w3c.dom.Element;
Lines 119-130 Link Here
119
	 * 
128
	 * 
120
	 * @param type the element node type to create on the document
129
	 * @param type the element node type to create on the document
121
	 * @return the root memento for writing a document
130
	 * @return the root memento for writing a document
131
     * @throws RuntimeException if there is a problem creating the document factory 
122
	 */
132
	 */
123
	public static XMLMemento createWriteRoot(String type) {
133
	public static XMLMemento createWriteRoot(String type) {
124
		Document document = new DocumentImpl();
134
        Document document;
125
		Element element = document.createElement(type);
135
        try {
126
		document.appendChild(element);
136
            document = DocumentBuilderFactory
127
		return new XMLMemento(document, element);
137
                            .newInstance()
138
                            .newDocumentBuilder()
139
                            .newDocument();
140
            Element element = document.createElement(type);
141
            document.appendChild(element);
142
            return new XMLMemento(document, element);            
143
        }
144
        catch (ParserConfigurationException e) {
145
            throw new RuntimeException(e);
146
        }
147
        catch (FactoryConfigurationError e) {
148
            throw new RuntimeException(e);
149
        }
128
	}
150
	}
129
	
151
	
130
	/**
152
	/**
Lines 385-395 Link Here
385
	 * specified writer. 
407
	 * specified writer. 
386
	 * 
408
	 * 
387
	 * @param writer the writer used to save the memento's document
409
	 * @param writer the writer used to save the memento's document
410
     * @throws IOException if there is a problem serializing the document to the stream.
388
	 */
411
	 */
389
	public void save(Writer writer) throws IOException {
412
	public void save(Writer writer) throws IOException {
390
		OutputFormat format = new OutputFormat();
413
        Result result = new StreamResult(writer);
391
		format.setPreserveSpace(true);
414
        Source source = new DOMSource(factory);
392
		Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(writer, format); //$NON-NLS-1$
415
        try {
393
		serializer.asDOMSerializer().serialize(factory);
416
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
417
            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
418
            transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
419
            transformer.transform(source, result);            
420
        }
421
        catch (TransformerConfigurationException e) {
422
            throw (IOException) (new IOException().initCause(e));
423
        }
424
        catch (TransformerFactoryConfigurationError e) {
425
            throw (IOException) (new IOException().initCause(e));
426
        }
427
        catch (TransformerException e) {
428
            throw (IOException) (new IOException().initCause(e));
429
        }        
430
        catch (FactoryConfigurationError e) {
431
            throw (IOException) (new IOException().initCause(e));
432
        }
394
	}
433
	}
395
}
434
}
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/WelcomeEditor.java (-18 / +71 lines)
Lines 17-42 Link Here
17
import java.util.ArrayList;
17
import java.util.ArrayList;
18
import java.util.Iterator;
18
import java.util.Iterator;
19
19
20
import javax.xml.parsers.FactoryConfigurationError;
21
import javax.xml.parsers.ParserConfigurationException;
22
20
import org.eclipse.core.resources.IMarker;
23
import org.eclipse.core.resources.IMarker;
21
import org.eclipse.core.runtime.*;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.Status;
27
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.custom.CLabel;
30
import org.eclipse.swt.custom.ScrolledComposite;
31
import org.eclipse.swt.custom.StyleRange;
32
import org.eclipse.swt.custom.StyledText;
33
import org.eclipse.swt.events.DisposeEvent;
34
import org.eclipse.swt.events.DisposeListener;
35
import org.eclipse.swt.events.FocusAdapter;
36
import org.eclipse.swt.events.FocusEvent;
37
import org.eclipse.swt.events.KeyEvent;
38
import org.eclipse.swt.events.KeyListener;
39
import org.eclipse.swt.events.MouseAdapter;
40
import org.eclipse.swt.events.MouseEvent;
41
import org.eclipse.swt.events.MouseMoveListener;
42
import org.eclipse.swt.events.SelectionAdapter;
43
import org.eclipse.swt.events.SelectionEvent;
44
import org.eclipse.swt.events.TraverseEvent;
45
import org.eclipse.swt.events.TraverseListener;
46
import org.eclipse.swt.graphics.Color;
47
import org.eclipse.swt.graphics.Cursor;
48
import org.eclipse.swt.graphics.GC;
49
import org.eclipse.swt.graphics.Point;
50
import org.eclipse.swt.graphics.Rectangle;
51
import org.eclipse.swt.layout.GridData;
52
import org.eclipse.swt.layout.GridLayout;
53
import org.eclipse.swt.widgets.Composite;
54
import org.eclipse.swt.widgets.Display;
55
import org.eclipse.swt.widgets.Event;
56
import org.eclipse.swt.widgets.Label;
57
import org.eclipse.swt.widgets.Listener;
58
22
import org.eclipse.jface.action.MenuManager;
59
import org.eclipse.jface.action.MenuManager;
23
import org.eclipse.jface.preference.JFacePreferences;
60
import org.eclipse.jface.preference.JFacePreferences;
24
import org.eclipse.jface.resource.JFaceColors;
61
import org.eclipse.jface.resource.JFaceColors;
25
import org.eclipse.jface.resource.JFaceResources;
62
import org.eclipse.jface.resource.JFaceResources;
26
import org.eclipse.jface.util.IPropertyChangeListener;
63
import org.eclipse.jface.util.IPropertyChangeListener;
27
import org.eclipse.jface.util.PropertyChangeEvent;
64
import org.eclipse.jface.util.PropertyChangeEvent;
28
import org.eclipse.swt.SWT;
65
29
import org.eclipse.swt.custom.*;
66
import org.eclipse.ui.IEditorInput;
30
import org.eclipse.swt.events.*;
67
import org.eclipse.ui.IEditorSite;
31
import org.eclipse.swt.graphics.*;
68
import org.eclipse.ui.PartInitException;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.*;
35
import org.eclipse.ui.*;
36
import org.eclipse.ui.help.WorkbenchHelp;
69
import org.eclipse.ui.help.WorkbenchHelp;
37
import org.eclipse.ui.internal.*;
70
import org.eclipse.ui.internal.IHelpContextIds;
71
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
72
import org.eclipse.ui.internal.WorkbenchImages;
73
import org.eclipse.ui.internal.WorkbenchMessages;
74
import org.eclipse.ui.internal.WorkbenchPlugin;
38
import org.eclipse.ui.part.EditorPart;
75
import org.eclipse.ui.part.EditorPart;
39
76
77
import org.xml.sax.SAXException;
78
40
/**
79
/**
41
 * A "fake" editor to show a welcome page
80
 * A "fake" editor to show a welcome page
42
 * The contents of this page are supplied in the product configuration
81
 * The contents of this page are supplied in the product configuration
Lines 554-566 Link Here
554
					if (i==0) extent = w - adjustFirst;
593
					if (i==0) extent = w - adjustFirst;
555
					else extent = w - adjust;
594
					else extent = w - adjust;
556
					StyledText text = (StyledText)texts.get(i);
595
					StyledText text = (StyledText)texts.get(i);
557
					Point p = text.computeSize(extent, SWT.DEFAULT, false);
596
					Point point = text.computeSize(extent, SWT.DEFAULT, false);
558
					((GridData)text.getLayoutData()).widthHint = p.x;
597
					((GridData)text.getLayoutData()).widthHint = point.x;
559
				}
598
				}
560
				// reset the scrolled composite height since the height of the 
599
				// reset the scrolled composite height since the height of the 
561
				// styled text widgets have changed
600
				// styled text widgets have changed
562
				Point p = infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
601
				Point point = infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
563
				scrolledComposite.setMinHeight(p.y);
602
				scrolledComposite.setMinHeight(point.y);
564
			}
603
			}
565
		});
604
		});
566
	}
605
	}
Lines 842-851 Link Here
842
}
881
}
843
/**
882
/**
844
 * Read the contents of the welcome page
883
 * Read the contents of the welcome page
845
 */
884
 * 
846
public void read(InputStream is) {
885
 * @param is the <code>InputStream</code> to parse
847
	parser = new WelcomeParser();
886
 * @throws IOException if there is a problem parsing the stream.
848
	parser.parse(is);
887
 */
888
public void read(InputStream is) throws IOException {
889
    try {
890
        parser = new WelcomeParser();
891
    }
892
    catch (ParserConfigurationException e) {
893
        throw (IOException) (new IOException().initCause(e));
894
    }
895
    catch (SAXException e) {
896
        throw (IOException) (new IOException().initCause(e));
897
    }
898
    catch (FactoryConfigurationError e) {
899
        throw (IOException) (new IOException().initCause(e));
900
    }
901
    parser.parse(is);
849
}
902
}
850
/**
903
/**
851
 * Reads the welcome file
904
 * Reads the welcome file
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/WelcomeParser.java (-26 / +44 lines)
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
}

Return to bug 44868