KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.jdt.internal.ui.preferences;
12
13 import org.eclipse.core.resources.IProject;
14
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17
18 import org.eclipse.ui.IWorkbenchPreferencePage;
19 import org.eclipse.ui.PlatformUI;
20 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
21
22 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
23 import org.eclipse.jdt.internal.ui.JavaPlugin;
24
25 /*
26  * The page to configure the naming style options.
27  */

28 public class CodeStylePreferencePage extends PropertyAndPreferencePage implements IWorkbenchPreferencePage {
29
30     public static final String JavaDoc PREF_ID= "org.eclipse.jdt.ui.preferences.CodeStylePreferencePage"; //$NON-NLS-1$
31
public static final String JavaDoc PROP_ID= "org.eclipse.jdt.ui.propertyPages.CodeStylePreferencePage"; //$NON-NLS-1$
32

33     private NameConventionConfigurationBlock fConfigurationBlock;
34
35     public CodeStylePreferencePage() {
36         setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
37         //setDescription(PreferencesMessages.getString("CodeStylePreferencePage.description")); //$NON-NLS-1$
38

39         // only used when page is shown programatically
40
setTitle(PreferencesMessages.CodeStylePreferencePage_title);
41     }
42
43     /*
44      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
45      */

46     public void createControl(Composite parent) {
47         IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
48         fConfigurationBlock= new NameConventionConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
49         
50         super.createControl(parent);
51         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
52     }
53
54     protected Control createPreferenceContent(Composite composite) {
55         return fConfigurationBlock.createContents(composite);
56     }
57     
58     protected boolean hasProjectSpecificOptions(IProject project) {
59         return fConfigurationBlock.hasProjectSpecificOptions(project);
60     }
61     
62     /* (non-Javadoc)
63      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
64      */

65     protected String JavaDoc getPreferencePageID() {
66         return PREF_ID;
67     }
68     
69     /* (non-Javadoc)
70      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
71      */

72     protected String JavaDoc getPropertyPageID() {
73         return PROP_ID;
74     }
75     
76     /* (non-Javadoc)
77      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
78      */

79     protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
80         super.enableProjectSpecificSettings(useProjectSpecificSettings);
81         if (fConfigurationBlock != null) {
82             fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
83         }
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     /*
97      * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
98      */

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

109     public boolean performOk() {
110         if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
111             return false;
112         }
113         return super.performOk();
114     }
115     
116     /*
117      * @see org.eclipse.jface.preference.IPreferencePage#performApply()
118      */

119     public void performApply() {
120         if (fConfigurationBlock != null) {
121             fConfigurationBlock.performApply();
122         }
123     }
124     
125
126 }
127
128
129
130
Popular Tags