e855df286212a788f0147fca496ccc4830e6e20f
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / preferences / XMLSyntaxPreferencePage.java
1 /*
2  * Copyright (c) 2002-2004 Roberto Gonzalez Rocha and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *     Roberto Gonzalez Rocha - Initial version
10  *     Igor Malinin - refactoring, minor changes
11  *
12  * $Id: XMLSyntaxPreferencePage.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
13  */
14
15 package net.sourceforge.phpeclipse.xml.ui.internal.preferences;
16
17 import java.io.BufferedReader;
18 import java.io.IOException;
19 import java.io.InputStreamReader;
20
21 import net.sourceforge.phpeclipse.ui.ColorEditor;
22 import net.sourceforge.phpeclipse.ui.preferences.ITextStylePreferences;
23 import net.sourceforge.phpeclipse.ui.preferences.OverlayPreferenceStore;
24 import net.sourceforge.phpeclipse.ui.preferences.PreferenceDescriptor;
25 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
26 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
27 import net.sourceforge.phpeclipse.xml.ui.text.IXMLSyntaxConstants;
28 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
29
30 import org.eclipse.jface.preference.IPreferenceStore;
31 import org.eclipse.jface.preference.PreferenceConverter;
32 import org.eclipse.jface.preference.PreferencePage;
33 import org.eclipse.jface.resource.JFaceResources;
34 import org.eclipse.jface.text.Document;
35 import org.eclipse.jface.text.IDocument;
36 import org.eclipse.jface.text.IDocumentPartitioner;
37 import org.eclipse.jface.text.source.ISourceViewer;
38 import org.eclipse.jface.text.source.SourceViewer;
39 import org.eclipse.jface.util.IPropertyChangeListener;
40 import org.eclipse.jface.util.PropertyChangeEvent;
41 import org.eclipse.swt.SWT;
42 import org.eclipse.swt.custom.StyledText;
43 import org.eclipse.swt.events.SelectionEvent;
44 import org.eclipse.swt.events.SelectionListener;
45 import org.eclipse.swt.graphics.Color;
46 import org.eclipse.swt.graphics.RGB;
47 import org.eclipse.swt.layout.GridData;
48 import org.eclipse.swt.layout.GridLayout;
49 import org.eclipse.swt.layout.RowLayout;
50 import org.eclipse.swt.widgets.Button;
51 import org.eclipse.swt.widgets.Composite;
52 import org.eclipse.swt.widgets.Control;
53 import org.eclipse.swt.widgets.Display;
54 import org.eclipse.swt.widgets.Group;
55 import org.eclipse.swt.widgets.Label;
56 import org.eclipse.swt.widgets.List;
57 import org.eclipse.ui.IWorkbench;
58 import org.eclipse.ui.IWorkbenchPreferencePage;
59 import org.eclipse.ui.texteditor.AbstractTextEditor;
60
61 /**
62  * The XMLSyntaxPreferencePage is a preference page that handles setting the
63  * colors used by the XML editors.
64  */
65 public class XMLSyntaxPreferencePage extends PreferencePage implements
66                 IWorkbenchPreferencePage {
67
68         public final PreferenceDescriptor[] fKeys = new PreferenceDescriptor[] {
69                         new PreferenceDescriptor(
70                                         PreferenceDescriptor.BOOLEAN,
71                                         AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT),
72                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
73                                         AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND),
74
75                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
76                                         IXMLSyntaxConstants.XML_DEFAULT
77                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
78                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
79                                         IXMLSyntaxConstants.XML_DEFAULT
80                                                         + ITextStylePreferences.SUFFIX_STYLE),
81
82                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
83                                         IXMLSyntaxConstants.XML_TAG
84                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
85                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
86                                         IXMLSyntaxConstants.XML_TAG
87                                                         + ITextStylePreferences.SUFFIX_STYLE),
88
89                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
90                                         IXMLSyntaxConstants.XML_ATT_NAME
91                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
92                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
93                                         IXMLSyntaxConstants.XML_ATT_NAME
94                                                         + ITextStylePreferences.SUFFIX_STYLE),
95
96                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
97                                         IXMLSyntaxConstants.XML_ATT_VALUE
98                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
99                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
100                                         IXMLSyntaxConstants.XML_ATT_VALUE
101                                                         + ITextStylePreferences.SUFFIX_STYLE),
102
103                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
104                                         IXMLSyntaxConstants.XML_ENTITY
105                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
106                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
107                                         IXMLSyntaxConstants.XML_ENTITY
108                                                         + ITextStylePreferences.SUFFIX_STYLE),
109
110                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
111                                         IXMLSyntaxConstants.XML_CDATA
112                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
113                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
114                                         IXMLSyntaxConstants.XML_CDATA
115                                                         + ITextStylePreferences.SUFFIX_STYLE),
116
117                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
118                                         IXMLSyntaxConstants.XML_PI
119                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
120                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
121                                         IXMLSyntaxConstants.XML_PI
122                                                         + ITextStylePreferences.SUFFIX_STYLE),
123
124                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
125                                         IXMLSyntaxConstants.XML_COMMENT
126                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
127                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
128                                         IXMLSyntaxConstants.XML_COMMENT
129                                                         + ITextStylePreferences.SUFFIX_STYLE),
130
131                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
132                                         IXMLSyntaxConstants.XML_DECL
133                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
134                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
135                                         IXMLSyntaxConstants.XML_DECL
136                                                         + ITextStylePreferences.SUFFIX_STYLE),
137
138                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
139                                         IXMLSyntaxConstants.XML_SMARTY
140                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
141                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
142                                         IXMLSyntaxConstants.XML_SMARTY
143                                                         + ITextStylePreferences.SUFFIX_STYLE),
144
145                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
146                                         IXMLSyntaxConstants.DTD_CONDITIONAL
147                                                         + ITextStylePreferences.SUFFIX_FOREGROUND),
148                         new PreferenceDescriptor(PreferenceDescriptor.STRING,
149                                         IXMLSyntaxConstants.DTD_CONDITIONAL
150                                                         + ITextStylePreferences.SUFFIX_STYLE), };
151
152         OverlayPreferenceStore overlay;
153
154         final String[][] fSyntaxColorListModel = new String[][] {
155                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.others"), //$NON-NLS-1$
156                                         IXMLSyntaxConstants.XML_DEFAULT },
157                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.Tag"), //$NON-NLS-1$
158                                         IXMLSyntaxConstants.XML_TAG },
159                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.AttName"), //$NON-NLS-1$
160                                         IXMLSyntaxConstants.XML_ATT_NAME },
161                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.AttValue"), //$NON-NLS-1$
162                                         IXMLSyntaxConstants.XML_ATT_VALUE },
163                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.Entity"), //$NON-NLS-1$
164                                         IXMLSyntaxConstants.XML_ENTITY },
165                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.CDATA"), //$NON-NLS-1$
166                                         IXMLSyntaxConstants.XML_CDATA },
167                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.PI"), //$NON-NLS-1$
168                                         IXMLSyntaxConstants.XML_PI },
169                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.Comment"), //$NON-NLS-1$
170                                         IXMLSyntaxConstants.XML_COMMENT },
171                         {
172                                         XMLPlugin
173                                                         .getResourceString("XmlSyntaxPreferencePage.Declaration"), //$NON-NLS-1$
174                                         IXMLSyntaxConstants.XML_DECL },
175                         {
176                                         XMLPlugin
177                                                         .getResourceString("XmlSyntaxPreferencePage.Conditional"), //$NON-NLS-1$
178                                         IXMLSyntaxConstants.XML_SMARTY },
179                         { XMLPlugin.getResourceString("XmlSyntaxPreferencePage.SmartyTag"), //$NON-NLS-1$
180                                         IXMLSyntaxConstants.DTD_CONDITIONAL }, };
181
182         private XMLTextTools xmlTextTools;
183
184         private Color bgColor;
185
186         Button bgDefault;
187
188         Button bgCustom;
189
190         ColorEditor bgColorEditor;
191
192         List colors;
193
194         ColorEditor fgColorEditor;
195
196         Button fgBold;
197
198         SourceViewer preview;
199
200         /**
201          * Constructor for XMLSyntaxPreferencePage.
202          */
203         public XMLSyntaxPreferencePage() {
204                 setDescription(XMLPlugin
205                                 .getResourceString("XmlSyntaxPreferencePage.description")); //$NON-NLS-1$
206
207                 setPreferenceStore(XMLPlugin.getDefault().getPreferenceStore());
208
209                 overlay = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
210         }
211
212         protected Control createContents(Composite parent) {
213                 overlay.load();
214                 overlay.start();
215
216                 Composite colorComposite = new Composite(parent, SWT.NULL);
217                 colorComposite.setLayout(new GridLayout());
218
219                 Group backgroundComposite = new Group(colorComposite,
220                                 SWT.SHADOW_ETCHED_IN);
221
222                 backgroundComposite.setLayout(new RowLayout());
223                 backgroundComposite.setText(XMLPlugin
224                                 .getResourceString("XmlSyntaxPreferencePage.backgroundColor")); //$NON-NLS-1$
225
226                 SelectionListener backgroundSelectionListener = new SelectionListener() {
227                         public void widgetSelected(SelectionEvent e) {
228                                 boolean custom = bgCustom.getSelection();
229                                 bgColorEditor.getButton().setEnabled(custom);
230                                 overlay
231                                                 .setValue(
232                                                                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT,
233                                                                 !custom);
234                         }
235
236                         public void widgetDefaultSelected(SelectionEvent e) {
237                         }
238                 };
239
240                 bgDefault = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
241                 bgDefault.setText(XMLPlugin
242                                 .getResourceString("XmlSyntaxPreferencePage.systemDefault")); //$NON-NLS-1$
243                 bgDefault.addSelectionListener(backgroundSelectionListener);
244
245                 bgCustom = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
246                 bgCustom.setText(XMLPlugin
247                                 .getResourceString("XmlSyntaxPreferencePage.custom")); //$NON-NLS-1$
248                 bgCustom.addSelectionListener(backgroundSelectionListener);
249
250                 bgColorEditor = new ColorEditor(backgroundComposite);
251
252                 Label label = new Label(colorComposite, SWT.LEFT);
253                 label.setText(XMLPlugin
254                                 .getResourceString("XmlSyntaxPreferencePage.foreground")); //$NON-NLS-1$
255                 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
256
257                 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
258                 GridLayout layout = new GridLayout();
259                 layout.numColumns = 2;
260                 layout.marginHeight = 0;
261                 layout.marginWidth = 0;
262                 editorComposite.setLayout(layout);
263                 GridData gd = new GridData(GridData.FILL_BOTH);
264                 editorComposite.setLayoutData(gd);
265
266                 colors = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
267                                 | SWT.BORDER);
268                 gd = new GridData(GridData.FILL_BOTH);
269                 gd.heightHint = convertHeightInCharsToPixels(5);
270                 colors.setLayoutData(gd);
271
272                 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
273                 layout = new GridLayout();
274                 layout.marginHeight = 0;
275                 layout.marginWidth = 0;
276                 layout.numColumns = 2;
277                 stylesComposite.setLayout(layout);
278                 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
279
280                 label = new Label(stylesComposite, SWT.LEFT);
281                 label.setText(XMLPlugin
282                                 .getResourceString("XmlSyntaxPreferencePage.color")); //$NON-NLS-1$
283                 gd = new GridData();
284                 gd.horizontalAlignment = GridData.BEGINNING;
285                 label.setLayoutData(gd);
286
287                 fgColorEditor = new ColorEditor(stylesComposite);
288
289                 Button fgColorButton = fgColorEditor.getButton();
290                 gd = new GridData(GridData.FILL_HORIZONTAL);
291                 gd.horizontalAlignment = GridData.BEGINNING;
292                 fgColorButton.setLayoutData(gd);
293
294                 label = new Label(stylesComposite, SWT.LEFT);
295                 label.setText(XMLPlugin
296                                 .getResourceString("XmlSyntaxPreferencePage.bold")); //$NON-NLS-1$
297                 gd = new GridData();
298                 gd.horizontalAlignment = GridData.BEGINNING;
299                 label.setLayoutData(gd);
300
301                 fgBold = new Button(stylesComposite, SWT.CHECK);
302                 gd = new GridData(GridData.FILL_HORIZONTAL);
303                 gd.horizontalAlignment = GridData.BEGINNING;
304                 fgBold.setLayoutData(gd);
305
306                 label = new Label(colorComposite, SWT.LEFT);
307                 label.setText(XMLPlugin
308                                 .getResourceString("XmlSyntaxPreferencePage.preview")); //$NON-NLS-1$
309                 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
310
311                 Control previewer = createPreviewer(colorComposite);
312                 gd = new GridData(GridData.FILL_BOTH);
313                 gd.widthHint = convertWidthInCharsToPixels(20);
314                 gd.heightHint = convertHeightInCharsToPixels(5);
315                 previewer.setLayoutData(gd);
316
317                 colors.addSelectionListener(new SelectionListener() {
318
319                         public void widgetDefaultSelected(SelectionEvent e) {
320                         }
321
322                         public void widgetSelected(SelectionEvent e) {
323                                 handleSyntaxColorListSelection();
324                         }
325                 });
326
327                 bgColorEditor.getButton().addSelectionListener(new SelectionListener() {
328                         public void widgetDefaultSelected(SelectionEvent e) {
329                         }
330
331                         public void widgetSelected(SelectionEvent e) {
332                                 PreferenceConverter.setValue(overlay,
333                                                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
334                                                 bgColorEditor.getColorValue());
335                         }
336                 });
337
338                 fgColorButton.addSelectionListener(new SelectionListener() {
339                         public void widgetDefaultSelected(SelectionEvent e) {
340                         }
341
342                         public void widgetSelected(SelectionEvent e) {
343                                 int i = colors.getSelectionIndex();
344
345                                 String key = fSyntaxColorListModel[i][1];
346
347                                 PreferenceConverter.setValue(overlay, key
348                                                 + ITextStylePreferences.SUFFIX_FOREGROUND,
349                                                 fgColorEditor.getColorValue());
350                         }
351                 });
352
353                 fgBold.addSelectionListener(new SelectionListener() {
354                         public void widgetDefaultSelected(SelectionEvent e) {
355                         }
356
357                         public void widgetSelected(SelectionEvent e) {
358                                 int i = colors.getSelectionIndex();
359
360                                 String key = fSyntaxColorListModel[i][1];
361
362                                 String value = (fgBold.getSelection()) ? ITextStylePreferences.STYLE_BOLD
363                                                 : ITextStylePreferences.STYLE_NORMAL;
364
365                                 overlay.setValue(key + ITextStylePreferences.SUFFIX_STYLE,
366                                                 value);
367                         }
368                 });
369
370                 initialize();
371
372                 return colorComposite;
373         }
374
375         private Control createPreviewer(Composite parent) {
376                 xmlTextTools = new XMLTextTools(overlay); // REVISIT: DTD
377
378                 preview = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL
379                                 | SWT.BORDER);
380
381                 preview.configure(new XMLConfiguration(xmlTextTools));
382                 preview.getTextWidget().setFont(
383                                 JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
384                 preview.setEditable(false);
385
386                 initializeViewerColors(preview);
387
388                 String content = loadPreviewContentFromFile("preview.xml"); //$NON-NLS-1$
389                 IDocument document = new Document(content);
390
391                 // REVISIT: DTD
392                 IDocumentPartitioner partitioner = xmlTextTools.createXMLPartitioner();
393
394                 partitioner.connect(document);
395                 document.setDocumentPartitioner(partitioner);
396
397                 preview.setDocument(document);
398
399                 overlay.addPropertyChangeListener(new IPropertyChangeListener() {
400                         public void propertyChange(PropertyChangeEvent event) {
401                                 String p = event.getProperty();
402                                 if (p.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)
403                                                 || p
404                                                                 .equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
405                                         initializeViewerColors(preview);
406                                 }
407
408                                 preview.invalidateTextPresentation();
409                         }
410                 });
411
412                 return preview.getControl();
413         }
414
415         /**
416          * Initializes the given viewer's colors.
417          * 
418          * @param viewer
419          *            the viewer to be initialized
420          */
421         void initializeViewerColors(ISourceViewer viewer) {
422                 if (overlay != null) {
423                         StyledText styledText = viewer.getTextWidget();
424
425                         // ---------- background color ----------------------
426                         Color color = null;
427                         if (!overlay
428                                         .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
429                                 color = createColor(overlay,
430                                                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
431                                                 styledText.getDisplay());
432                         }
433
434                         styledText.setBackground(color);
435
436                         if (bgColor != null) {
437                                 bgColor.dispose();
438                         }
439
440                         bgColor = color;
441                 }
442         }
443
444         /**
445          * Creates a color from the information stored in the given preference
446          * store. Returns <code>null</code> if there is no such information
447          * available.
448          */
449         private Color createColor(IPreferenceStore store, String key,
450                         Display display) {
451                 RGB rgb = null;
452
453                 if (store.contains(key)) {
454                         if (store.isDefault(key)) {
455                                 rgb = PreferenceConverter.getDefaultColor(store, key);
456                         } else {
457                                 rgb = PreferenceConverter.getColor(store, key);
458                         }
459
460                         if (rgb != null) {
461                                 return new Color(display, rgb);
462                         }
463                 }
464
465                 return null;
466         }
467
468         void handleSyntaxColorListSelection() {
469                 int i = colors.getSelectionIndex();
470
471                 String key = fSyntaxColorListModel[i][1];
472
473                 RGB rgb = PreferenceConverter.getColor(overlay, key
474                                 + ITextStylePreferences.SUFFIX_FOREGROUND);
475
476                 fgColorEditor.setColorValue(rgb);
477
478                 // REVISIT
479                 fgBold.setSelection(overlay.getString(
480                                 key + ITextStylePreferences.SUFFIX_STYLE).indexOf(
481                                 ITextStylePreferences.STYLE_BOLD) >= 0);
482         }
483
484         private String loadPreviewContentFromFile(String filename) {
485                 StringBuffer string = new StringBuffer(512);
486
487                 try {
488                         char[] buf = new char[512];
489                         BufferedReader reader = new BufferedReader(
490                                         new InputStreamReader(XMLSyntaxPreferencePage.class
491                                                         .getResourceAsStream(filename)));
492
493                         try {
494                                 while (true) {
495                                         int n = reader.read(buf);
496                                         if (n < 0) {
497                                                 break;
498                                         }
499
500                                         string.append(buf, 0, n);
501                                 }
502                         } finally {
503                                 reader.close();
504                         }
505                 } catch (IOException e) {
506                 }
507
508                 return string.toString();
509         }
510
511         /**
512          * 
513          */
514         private void initialize() {
515                 initializeFields();
516
517                 for (int i = 0; i < fSyntaxColorListModel.length; i++) {
518                         colors.add(fSyntaxColorListModel[i][0]);
519                 }
520
521                 colors.getDisplay().asyncExec(new Runnable() {
522
523                         public void run() {
524                                 colors.select(0);
525                                 handleSyntaxColorListSelection();
526                         }
527                 });
528         }
529
530         private void initializeFields() {
531                 RGB rgb = PreferenceConverter.getColor(overlay,
532                                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
533                 bgColorEditor.setColorValue(rgb);
534
535                 boolean def = overlay
536                                 .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
537                 bgDefault.setSelection(def);
538                 bgCustom.setSelection(!def);
539                 bgColorEditor.getButton().setEnabled(!def);
540         }
541
542         /*
543          * @see IWorkbenchPreferencePage#init(IWorkbench)
544          */
545         public void init(IWorkbench workbench) {
546         }
547
548         /*
549          * @see PreferencePage#performDefaults()
550          */
551         protected void performDefaults() {
552                 overlay.loadDefaults();
553                 // initializeFields();
554                 handleSyntaxColorListSelection();
555
556                 super.performDefaults();
557
558                 preview.invalidateTextPresentation();
559         }
560
561         /*
562          * @see org.eclipse.jface.preference.IPreferencePage#performOk()
563          */
564         public boolean performOk() {
565                 overlay.propagate();
566                 XMLPlugin.getDefault().savePluginPreferences();
567
568                 return true;
569         }
570
571         /*
572          * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
573          */
574         public void dispose() {
575                 if (xmlTextTools != null) {
576                         xmlTextTools.dispose();
577                         xmlTextTools = null;
578                 }
579
580                 if (overlay != null) {
581                         overlay.stop();
582                         overlay = null;
583                 }
584
585                 super.dispose();
586         }
587 }