KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > CVSFieldEditorPreferencePage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.team.internal.ccvs.ui;
12
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.jface.preference.FieldEditorPreferencePage;
15 import org.eclipse.jface.preference.IPreferenceStore;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.ui.*;
19
20 /**
21  * This class acts as an abstract superclass for CVS preference pages that use
22  * field editors.
23  */

24 public abstract class CVSFieldEditorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
25
26     public static IPreferenceStore getCVSPreferenceStore() {
27         return CVSUIPlugin.getPlugin().getPreferenceStore();
28     }
29     
30     /**
31      * Constructor for CVSFieldEditorPreferencePage.
32      */

33     public CVSFieldEditorPreferencePage() {
34         super(GRID);
35         setPreferenceStore(getCVSPreferenceStore());
36         String JavaDoc description = getPageDescription();
37         if (description != null)
38             setDescription(description);
39     }
40
41     /**
42      * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
43      */

44     protected Control createContents(Composite parent) {
45         Control control = super.createContents(parent);
46         String JavaDoc id = getPageHelpContextId();
47         if (id != null)
48             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), id);
49         Dialog.applyDialogFont(control);
50         return control;
51     }
52     
53     /**
54      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
55      */

56     public void init(IWorkbench workbench) {
57     }
58     
59     /**
60      * Method getPageHelpContextId must be overridden by subclasses to provide
61      * the help context ID of the page. Return null for no page F1 help.
62      *
63      * @return String
64      */

65     protected abstract String JavaDoc getPageHelpContextId();
66     
67     /**
68      * Method getPageDescription must be overridden by subclasses to provide the
69      * description of the page. Return null for no description.
70      * @return String
71      */

72     protected abstract String JavaDoc getPageDescription();
73     
74     /**
75      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
76      */

77     public boolean performOk() {
78         if (!super.performOk()) return false;
79         pushPreferences();
80         return true;
81     }
82
83     /**
84      * Push the preferences to the Core plugin as required
85      */

86     protected void pushPreferences() {
87         // Do nothing by default
88
}
89     
90 }
91
Popular Tags