KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > ui > internal > preferences > BasePreferencePage


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
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  * wharley@bea.com - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.apt.ui.internal.preferences;
13
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.core.runtime.IAdaptable;
16 import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Control;
19 import org.eclipse.ui.PlatformUI;
20
21 /**
22  * Base class for APT preference and property pages.
23  */

24 public abstract class BasePreferencePage extends PropertyAndPreferencePage {
25     private BaseConfigurationBlock fConfigurationBlock;
26
27     protected Control createPreferenceContent(Composite composite) {
28         return getConfigurationBlock().createPreferenceContent(composite);
29     }
30     
31     @Override JavaDoc
32     public void createControl(Composite parent) {
33         super.createControl(parent);
34         String JavaDoc contextId = getContextHelpId();
35         if (contextId != null) {
36             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), contextId);
37         }
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.jface.dialogs.DialogPage#dispose()
42      */

43     public void dispose() {
44         if (getConfigurationBlock() != null) {
45             getConfigurationBlock().dispose();
46         }
47         super.dispose();
48     }
49     /* (non-Javadoc)
50      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
51      */

52     protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
53         if (getConfigurationBlock() != null) {
54             getConfigurationBlock().useProjectSpecificSettings(useProjectSpecificSettings);
55         }
56         super.enableProjectSpecificSettings(useProjectSpecificSettings);
57     }
58
59     protected BaseConfigurationBlock getConfigurationBlock() {
60         return fConfigurationBlock;
61     }
62     
63     /**
64      * Derived classes should override by returning a string that refers
65      * to a context topic entry in docs/contexts_APT.xml. The default
66      * implementation returns null, which causes context help to be disabled.
67      */

68     protected String JavaDoc getContextHelpId() {
69         return null;
70     }
71     
72     protected boolean hasProjectSpecificOptions(IProject project) {
73         // Workaround for bug 106111 / 111144:
74
// See BaseConfigurationBlock.hasProjectSpecificOptionsNoCache() for details.
75
return getConfigurationBlock().hasProjectSpecificOptionsNoCache(project);
76     }
77     
78     /*
79      * See bug 136498: don't show workspace preferences.
80      */

81     @Override JavaDoc
82     protected boolean offerLink() {
83         return false;
84     }
85
86     /*
87      * @see org.eclipse.jface.preference.IPreferencePage#performApply()
88      */

89     public void performApply() {
90         if (getConfigurationBlock() != null) {
91             getConfigurationBlock().performApply();
92         }
93     }
94     
95     /*
96      * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
97      */

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

108     public boolean performOk() {
109         if (getConfigurationBlock() != null && !getConfigurationBlock().performOk()) {
110             return false;
111         }
112         return super.performOk();
113     }
114     
115     protected void setConfigurationBlock(BaseConfigurationBlock configurationBlock) {
116         fConfigurationBlock = configurationBlock;
117     }
118     
119     
120     /* (non-Javadoc)
121      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
122      */

123     public void setElement(IAdaptable element) {
124         super.setElement(element);
125         setDescription(null); // no description for property page
126
}
127 }
128
Popular Tags