KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 package org.eclipse.jdt.internal.ui.preferences;
12
13 import java.util.Map JavaDoc;
14
15 import org.eclipse.core.runtime.IAdaptable;
16
17 import org.eclipse.core.resources.IProject;
18
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
24
25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
26 import org.eclipse.jdt.internal.ui.JavaPlugin;
27
28 /**
29  * Page used to configure both workspace and project specific compiler settings
30  */

31 public class ProblemSeveritiesPreferencePage extends PropertyAndPreferencePage {
32
33     public static final String JavaDoc PREF_ID= "org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
34
public static final String JavaDoc PROP_ID= "org.eclipse.jdt.ui.propertyPages.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
35

36     public static final String JavaDoc DATA_SELECT_OPTION_KEY= "select_option_key"; //$NON-NLS-1$
37
public static final String JavaDoc DATA_SELECT_OPTION_QUALIFIER= "select_option_qualifier"; //$NON-NLS-1$
38

39     private ProblemSeveritiesConfigurationBlock fConfigurationBlock;
40
41     public ProblemSeveritiesPreferencePage() {
42         setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
43         //setDescription(PreferencesMessages.getString("ProblemSeveritiesPreferencePage.description")); //$NON-NLS-1$
44

45         // only used when page is shown programatically
46
setTitle(PreferencesMessages.ProblemSeveritiesPreferencePage_title);
47     }
48
49     /*
50      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
51      */

52     public void createControl(Composite parent) {
53         IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
54         fConfigurationBlock= new ProblemSeveritiesConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
55         
56         super.createControl(parent);
57         if (isProjectPreferencePage()) {
58             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROBLEM_SEVERITIES_PROPERTY_PAGE);
59         } else {
60             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROBLEM_SEVERITIES_PREFERENCE_PAGE);
61         }
62     }
63
64     protected Control createPreferenceContent(Composite composite) {
65         return fConfigurationBlock.createContents(composite);
66     }
67     
68     protected boolean hasProjectSpecificOptions(IProject project) {
69         return fConfigurationBlock.hasProjectSpecificOptions(project);
70     }
71     
72     /* (non-Javadoc)
73      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
74      */

75     protected String JavaDoc getPreferencePageID() {
76         return PREF_ID;
77     }
78     
79     /* (non-Javadoc)
80      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
81      */

82     protected String JavaDoc getPropertyPageID() {
83         return PROP_ID;
84     }
85     
86     /* (non-Javadoc)
87      * @see org.eclipse.jface.dialogs.DialogPage#dispose()
88      */

89     public void dispose() {
90         if (fConfigurationBlock != null) {
91             fConfigurationBlock.dispose();
92         }
93         super.dispose();
94     }
95     
96     /* (non-Javadoc)
97      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
98      */

99     protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
100         super.enableProjectSpecificSettings(useProjectSpecificSettings);
101         if (fConfigurationBlock != null) {
102             fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
103         }
104     }
105     
106     /*
107      * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
108      */

109     protected void performDefaults() {
110         super.performDefaults();
111         if (fConfigurationBlock != null) {
112             fConfigurationBlock.performDefaults();
113         }
114     }
115
116     /*
117      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
118      */

119     public boolean performOk() {
120         if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
121             return false;
122         }
123         return super.performOk();
124     }
125     
126     /*
127      * @see org.eclipse.jface.preference.IPreferencePage#performApply()
128      */

129     public void performApply() {
130         if (fConfigurationBlock != null) {
131             fConfigurationBlock.performApply();
132         }
133     }
134     
135     /* (non-Javadoc)
136      * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
137      */

138     public void applyData(Object JavaDoc data) {
139         super.applyData(data);
140         if (data instanceof Map JavaDoc && fConfigurationBlock != null) {
141             Map JavaDoc map= (Map JavaDoc) data;
142             Object JavaDoc key= map.get(DATA_SELECT_OPTION_KEY);
143             Object JavaDoc qualifier= map.get(DATA_SELECT_OPTION_QUALIFIER);
144             if (key instanceof String JavaDoc && qualifier instanceof String JavaDoc) {
145                 fConfigurationBlock.selectOption((String JavaDoc) key, (String JavaDoc) qualifier);
146             }
147         }
148     }
149     
150     /* (non-Javadoc)
151      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
152      */

153     public void setElement(IAdaptable element) {
154         super.setElement(element);
155         setDescription(null); // no description for property page
156
}
157     
158 }
159
Popular Tags