KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > preferences > SpellingPreferenceBlock


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.preferences;
13
14 import org.eclipse.core.runtime.IStatus;
15
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18
19 import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor;
20 import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock;
21
22 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
23
24 /**
25  * Spelling preference block
26  *
27  * @since 3.1
28  */

29 public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
30     
31     private class NullStatusChangeListener implements IStatusChangeListener {
32         
33         /*
34          * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
35          */

36         public void statusChanged(IStatus status) {
37         }
38     }
39
40     private class StatusChangeListenerAdapter implements IStatusChangeListener {
41         
42         private IPreferenceStatusMonitor fMonitor;
43         
44         private IStatus fStatus;
45         
46         public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) {
47             super();
48             fMonitor= monitor;
49         }
50         
51         /*
52          * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
53          */

54         public void statusChanged(IStatus status) {
55             fStatus= status;
56             fMonitor.statusChanged(status);
57         }
58         
59         public IStatus getStatus() {
60             return fStatus;
61         }
62     }
63
64     private SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null);
65     
66     private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor;
67     
68     /*
69      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#createControl(org.eclipse.swt.widgets.Composite)
70      */

71     public Control createControl(Composite parent) {
72         return fBlock.createContents(parent);
73     }
74
75     /*
76      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#initialize(org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor)
77      */

78     public void initialize(IPreferenceStatusMonitor statusMonitor) {
79         fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor);
80         fBlock.fContext= fStatusMonitor;
81     }
82
83     /*
84      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#canPerformOk()
85      */

86     public boolean canPerformOk() {
87         return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
88     }
89
90     /*
91      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performOk()
92      */

93     public void performOk() {
94         fBlock.performOk();
95     }
96
97     /*
98      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performDefaults()
99      */

100     public void performDefaults() {
101         fBlock.performDefaults();
102     }
103     
104     /*
105      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performRevert()
106      */

107     public void performRevert() {
108         fBlock.performRevert();
109     }
110
111     /*
112      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#dispose()
113      */

114     public void dispose() {
115         fBlock.dispose();
116     }
117
118     /*
119      * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#setEnabled(boolean)
120      */

121     public void setEnabled(boolean enabled) {
122         fBlock.setEnabled(enabled);
123     }
124 }
125
Popular Tags