KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > externaltools > internal > ui > ExternalToolsPreferencePage


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.ui.externaltools.internal.ui;
12
13
14 import org.eclipse.jface.preference.PreferencePage;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Button;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23 import org.eclipse.ui.PlatformUI;
24 import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
25 import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
26 import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants;
27
28 /**
29  * Preference page that allows the user to customize external tools
30  */

31 public class ExternalToolsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
32
33     private Button promptForToolMigrationButton;
34     private Button promptForProjectMigrationButton;
35     
36     public ExternalToolsPreferencePage() {
37         setPreferenceStore(ExternalToolsPlugin.getDefault().getPreferenceStore());
38         setDescription(ExternalToolsUIMessages.ExternalToolsPreferencePage_External_tool_project_builders_migration_2);
39     }
40
41     /**
42      * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
43      */

44     protected Control createContents(Composite parent) {
45         PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IExternalToolsHelpContextIds.EXTERNAL_TOOLS_PREFERENCE_PAGE);
46         //The main composite
47
Composite composite = new Composite(parent, SWT.NULL);
48         GridLayout layout = new GridLayout();
49         layout.marginHeight=0;
50         layout.marginWidth=0;
51         composite.setLayout(layout);
52         composite.setFont(parent.getFont());
53                 
54         promptForToolMigrationButton= createCheckButton(composite, ExternalToolsUIMessages.ExternalToolsPreferencePage_Prompt_before_migrating_3, IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION);
55         promptForProjectMigrationButton= createCheckButton(composite, ExternalToolsUIMessages.ExternalToolsPreferencePage_1, IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION);
56         
57         applyDialogFont(composite);
58         
59         return composite;
60     }
61     
62     /**
63      * Returns a new check button with the given label for the given preference.
64      */

65     private Button createCheckButton(Composite parent, String JavaDoc label, String JavaDoc preferenceKey) {
66         Button button= new Button(parent, SWT.CHECK | SWT.LEFT);
67         button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
68         button.setFont(parent.getFont());
69         button.setText(label);
70         button.setSelection(getPreferenceStore().getBoolean(preferenceKey));
71         return button;
72     }
73     
74     /**
75      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
76      */

77     public void init(IWorkbench workbench) {
78     }
79
80     /**
81      * @see org.eclipse.jface.preference.PreferencePage#performOk()
82      */

83     public boolean performOk() {
84         getPreferenceStore().setValue(IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION, promptForToolMigrationButton.getSelection());
85         getPreferenceStore().setValue(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION, promptForProjectMigrationButton.getSelection());
86         return super.performOk();
87     }
88
89     /**
90      * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
91      */

92     protected void performDefaults() {
93         promptForToolMigrationButton.setSelection(getPreferenceStore().getDefaultBoolean(IPreferenceConstants.PROMPT_FOR_TOOL_MIGRATION));
94         promptForToolMigrationButton.setSelection(getPreferenceStore().getDefaultBoolean(IPreferenceConstants.PROMPT_FOR_PROJECT_MIGRATION));
95         super.performDefaults();
96     }
97 }
98
Popular Tags