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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.preferences;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.core.resources.IProject;
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
23 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
24 import org.eclipse.jdt.internal.ui.JavaPlugin;
25 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
28 * The page to configure the code templates.
30 public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
32 public static final String PREF_ID= "org.eclipse.jdt.ui.preferences.CodeTemplatePreferencePage"; //$NON-NLS-1$
33 public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.CodeTemplatePreferencePage"; //$NON-NLS-1$
35 public static final String DATA_SELECT_TEMPLATE= "CodeTemplatePreferencePage.select_template"; //$NON-NLS-1$
37 CodeTemplateBlock fCodeTemplateConfigurationBlock;
39 public CodeTemplatePreferencePage() {
40 setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
41 //setDescription(PreferencesMessages.getString("CodeTemplatesPreferencePage.description")); //$NON-NLS-1$
43 // only used when page is shown programatically
44 setTitle(PreferencesMessages.CodeTemplatesPreferencePage_title);
48 * @see PreferencePage#createControl(Composite)
51 public void createControl(Composite parent) {
52 IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
53 fCodeTemplateConfigurationBlock= new CodeTemplateBlock(getNewStatusChangedListener(), getProject(), container);
55 super.createControl(parent);
56 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.CODE_TEMPLATES_PREFERENCE_PAGE);
60 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
63 protected Control createPreferenceContent(Composite composite) {
64 return fCodeTemplateConfigurationBlock.createContents(composite);
68 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
71 protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
72 super.enableProjectSpecificSettings(useProjectSpecificSettings);
73 if (fCodeTemplateConfigurationBlock != null) {
74 fCodeTemplateConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
79 * @see IPreferencePage#performOk()
82 public boolean performOk() {
83 if (fCodeTemplateConfigurationBlock != null) {
84 return fCodeTemplateConfigurationBlock.performOk(useProjectSettings());
90 * @see PreferencePage#performDefaults()
93 protected void performDefaults() {
94 super.performDefaults();
95 if (fCodeTemplateConfigurationBlock != null) {
96 fCodeTemplateConfigurationBlock.performDefaults();
101 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
104 public void dispose() {
105 if (fCodeTemplateConfigurationBlock != null) {
106 fCodeTemplateConfigurationBlock.dispose();
112 * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
114 public void statusChanged(IStatus status) {
115 setValid(!status.matches(IStatus.ERROR));
116 StatusUtil.applyToStatusLine(this, status);
120 * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
123 public boolean performCancel() {
124 if (fCodeTemplateConfigurationBlock != null) {
125 fCodeTemplateConfigurationBlock.performCancel();
127 return super.performCancel();
131 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
134 protected boolean hasProjectSpecificOptions(IProject project) {
135 return fCodeTemplateConfigurationBlock.hasProjectSpecificOptions(project);
139 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
142 protected String getPreferencePageID() {
147 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
150 protected String getPropertyPageID() {
155 * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
158 public void applyData(Object data) {
159 fCodeTemplateConfigurationBlock.generated_7434189675184227133(this, data);
160 super.applyData(data);