001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.ui.preferences;
011:
012: import java.util.Map;
013:
014: import org.eclipse.core.runtime.IAdaptable;
015:
016: import org.eclipse.core.resources.IProject;
017:
018: import org.eclipse.swt.widgets.Composite;
019: import org.eclipse.swt.widgets.Control;
020:
021: import org.eclipse.ui.PlatformUI;
022: import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
023:
024: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
025: import org.eclipse.jdt.internal.ui.JavaPlugin;
026:
027: /**
028: * Page used to configure both workspace and project specific compiler settings
029: */
030: public class ProblemSeveritiesPreferencePage extends
031: PropertyAndPreferencePage {
032:
033: public static final String PREF_ID = "org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
034: public static final String PROP_ID = "org.eclipse.jdt.ui.propertyPages.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
035:
036: public static final String DATA_SELECT_OPTION_KEY = "select_option_key"; //$NON-NLS-1$
037: public static final String DATA_SELECT_OPTION_QUALIFIER = "select_option_qualifier"; //$NON-NLS-1$
038:
039: private ProblemSeveritiesConfigurationBlock fConfigurationBlock;
040:
041: public ProblemSeveritiesPreferencePage() {
042: setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
043: //setDescription(PreferencesMessages.getString("ProblemSeveritiesPreferencePage.description")); //$NON-NLS-1$
044:
045: // only used when page is shown programatically
046: setTitle(PreferencesMessages.ProblemSeveritiesPreferencePage_title);
047: }
048:
049: /*
050: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
051: */
052: public void createControl(Composite parent) {
053: IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
054: fConfigurationBlock = new ProblemSeveritiesConfigurationBlock(
055: getNewStatusChangedListener(), getProject(), container);
056:
057: super .createControl(parent);
058: if (isProjectPreferencePage()) {
059: PlatformUI
060: .getWorkbench()
061: .getHelpSystem()
062: .setHelp(
063: getControl(),
064: IJavaHelpContextIds.PROBLEM_SEVERITIES_PROPERTY_PAGE);
065: } else {
066: PlatformUI
067: .getWorkbench()
068: .getHelpSystem()
069: .setHelp(
070: getControl(),
071: IJavaHelpContextIds.PROBLEM_SEVERITIES_PREFERENCE_PAGE);
072: }
073: }
074:
075: protected Control createPreferenceContent(Composite composite) {
076: return fConfigurationBlock.createContents(composite);
077: }
078:
079: protected boolean hasProjectSpecificOptions(IProject project) {
080: return fConfigurationBlock.hasProjectSpecificOptions(project);
081: }
082:
083: /* (non-Javadoc)
084: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
085: */
086: protected String getPreferencePageID() {
087: return PREF_ID;
088: }
089:
090: /* (non-Javadoc)
091: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
092: */
093: protected String getPropertyPageID() {
094: return PROP_ID;
095: }
096:
097: /* (non-Javadoc)
098: * @see org.eclipse.jface.dialogs.DialogPage#dispose()
099: */
100: public void dispose() {
101: if (fConfigurationBlock != null) {
102: fConfigurationBlock.dispose();
103: }
104: super .dispose();
105: }
106:
107: /* (non-Javadoc)
108: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
109: */
110: protected void enableProjectSpecificSettings(
111: boolean useProjectSpecificSettings) {
112: super .enableProjectSpecificSettings(useProjectSpecificSettings);
113: if (fConfigurationBlock != null) {
114: fConfigurationBlock
115: .useProjectSpecificSettings(useProjectSpecificSettings);
116: }
117: }
118:
119: /*
120: * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
121: */
122: protected void performDefaults() {
123: super .performDefaults();
124: if (fConfigurationBlock != null) {
125: fConfigurationBlock.performDefaults();
126: }
127: }
128:
129: /*
130: * @see org.eclipse.jface.preference.IPreferencePage#performOk()
131: */
132: public boolean performOk() {
133: if (fConfigurationBlock != null
134: && !fConfigurationBlock.performOk()) {
135: return false;
136: }
137: return super .performOk();
138: }
139:
140: /*
141: * @see org.eclipse.jface.preference.IPreferencePage#performApply()
142: */
143: public void performApply() {
144: if (fConfigurationBlock != null) {
145: fConfigurationBlock.performApply();
146: }
147: }
148:
149: /* (non-Javadoc)
150: * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
151: */
152: public void applyData(Object data) {
153: super .applyData(data);
154: if (data instanceof Map && fConfigurationBlock != null) {
155: Map map = (Map) data;
156: Object key = map.get(DATA_SELECT_OPTION_KEY);
157: Object qualifier = map.get(DATA_SELECT_OPTION_QUALIFIER);
158: if (key instanceof String && qualifier instanceof String) {
159: fConfigurationBlock.selectOption((String) key,
160: (String) qualifier);
161: }
162: }
163: }
164:
165: /* (non-Javadoc)
166: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
167: */
168: public void setElement(IAdaptable element) {
169: super .setElement(element);
170: setDescription(null); // no description for property page
171: }
172:
173: }
|