]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/preferences/CompliancePreferencePage.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / preferences / CompliancePreferencePage.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
15
16 import org.eclipse.core.runtime.IAdaptable;
17
18 import org.eclipse.core.resources.IProject;
19
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
22
23 import org.eclipse.jdt.launching.JavaRuntime;
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 CompliancePreferencePage extends PropertyAndPreferencePage {
32
33         public static final String PREF_ID= "org.eclipse.jdt.ui.preferences.CompliancePreferencePage"; //$NON-NLS-1$
34         public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"; //$NON-NLS-1$
35
36         private ComplianceConfigurationBlock fConfigurationBlock;
37
38         public CompliancePreferencePage() {
39                 setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
40                 //setDescription(PreferencesMessages.CompliancePreferencePage_description);
41
42                 // only used when page is shown programatically
43                 setTitle(PreferencesMessages.CompliancePreferencePage_title);
44
45                 JavaRuntime.getDefaultVMInstall();      // make sure the default JRE is detected (bug 152384)
46         }
47
48         /*
49          * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
50          */
51         @Override
52         public void createControl(Composite parent) {
53                 IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
54                 fConfigurationBlock= new ComplianceConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
55
56                 super.createControl(parent);
57                 if (isProjectPreferencePage()) {
58                         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
59                 } else {
60                         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
61                 }
62         }
63
64         @Override
65         protected Control createPreferenceContent(Composite composite) {
66                 return fConfigurationBlock.createContents(composite);
67         }
68
69         @Override
70         protected boolean hasProjectSpecificOptions(IProject project) {
71                 return fConfigurationBlock.hasProjectSpecificOptions(project);
72         }
73
74         /* (non-Javadoc)
75          * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
76          */
77         @Override
78         protected String getPreferencePageID() {
79                 return PREF_ID;
80         }
81
82         /* (non-Javadoc)
83          * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
84          */
85         @Override
86         protected String getPropertyPageID() {
87                 return PROP_ID;
88         }
89
90         /* (non-Javadoc)
91          * @see org.eclipse.jface.dialogs.DialogPage#dispose()
92          */
93         @Override
94         public void dispose() {
95                 if (fConfigurationBlock != null) {
96                         fConfigurationBlock.dispose();
97                 }
98                 super.dispose();
99         }
100
101         /* (non-Javadoc)
102          * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
103          */
104         @Override
105         protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
106                 super.enableProjectSpecificSettings(useProjectSpecificSettings);
107                 if (fConfigurationBlock != null) {
108                         fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
109                 }
110         }
111
112         /* (non-Javadoc)
113          * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enablePreferenceContent(boolean)
114          */
115         @Override
116         protected void enablePreferenceContent(boolean enable) {
117                 if (fConfigurationBlock != null) {
118                         fConfigurationBlock.enablePreferenceContent(enable);
119                 }
120         }
121         
122         /*
123          * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
124          * @since 3.5
125          */
126         @Override
127         public void setVisible(boolean visible) {
128                 super.setVisible(visible);
129                 if (visible && fConfigurationBlock != null) {
130                         fConfigurationBlock.refreshComplianceSettings();
131                 }
132         }
133
134         /*
135          * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
136          */
137         @Override
138         protected void performDefaults() {
139                 super.performDefaults();
140                 if (fConfigurationBlock != null) {
141                         fConfigurationBlock.performDefaults();
142                 }
143         }
144
145         /*
146          * @see org.eclipse.jface.preference.IPreferencePage#performOk()
147          */
148         @Override
149         public boolean performOk() {
150                 if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
151                         return false;
152                 }
153                 return super.performOk();
154         }
155
156         /*
157          * @see org.eclipse.jface.preference.IPreferencePage#performApply()
158          */
159         @Override
160         public void performApply() {
161                 if (fConfigurationBlock != null) {
162                         fConfigurationBlock.performApply();
163                 }
164         }
165
166         /* (non-Javadoc)
167          * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
168          */
169         @Override
170         public void setElement(IAdaptable element) {
171                 super.setElement(element);
172                 setDescription(null); // no description for property page
173         }
174
175 }