KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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 java.util.Arrays JavaDoc;
14
15 import org.eclipse.jface.dialogs.Dialog;
16 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
17 import org.eclipse.jface.preference.*;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.team.internal.ccvs.ui.CVSPreferencesPage.PerspectiveDescriptorComparator;
20 import org.eclipse.ui.*;
21
22 public class AnnotatePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
23
24     private RadioGroupFieldEditor quickDiffAnnotateMode = null;
25     private RadioGroupFieldEditor annotatePerspectiveSwitch = null;
26     private RadioGroupFieldEditor binaryPrompt = null;
27     private ComboFieldEditor annotatePerspectiveToUse = null;
28     private String JavaDoc[][] PERSPECTIVES = null;
29
30     public AnnotatePreferencePage() {
31         super(GRID);
32         setTitle(CVSUIMessages.AnnotatePreferencePage_AnnotatePrefPageTitle);
33         setDescription(CVSUIMessages.AnnotatePreferencePage_AnnotatePrefPageMessage);
34         setPreferenceStore(CVSUIPlugin.getPlugin().getPreferenceStore());
35     }
36
37     public void createControl(Composite parent) {
38         super.createControl(parent);
39         // set F1 help
40
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.ANNOTATE_VIEW);
41     }
42
43     public void createFieldEditors() {
44         quickDiffAnnotateMode = new RadioGroupFieldEditor(ICVSUIConstants.PREF_USE_QUICKDIFFANNOTATE, CVSUIMessages.CVSPreferencesPage_QuickDiffAnnotate, 3, new String JavaDoc[][] { {CVSUIMessages.CVSPreferencesPage_11, MessageDialogWithToggle.ALWAYS}, {CVSUIMessages.CVSPreferencesPage_12, MessageDialogWithToggle.NEVER}, {CVSUIMessages.CVSPreferencesPage_13, MessageDialogWithToggle.PROMPT}}, getFieldEditorParent(), true /* use a group */);
45
46         addField(quickDiffAnnotateMode);
47
48         annotatePerspectiveSwitch = new RadioGroupFieldEditor(ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS, CVSUIMessages.CVSPreferencesPage_42, 3, new String JavaDoc[][] { {CVSUIMessages.CVSPreferencesPage_11, MessageDialogWithToggle.ALWAYS}, {CVSUIMessages.CVSPreferencesPage_12, MessageDialogWithToggle.NEVER}, {CVSUIMessages.CVSPreferencesPage_13, MessageDialogWithToggle.PROMPT}}, getFieldEditorParent(), true /* use a group */);
49
50         addField(annotatePerspectiveSwitch);
51
52         initPerspectiveLabels();
53         annotatePerspectiveToUse = new ComboFieldEditor(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS, CVSUIMessages.CVSPreferencesPage_43, PERSPECTIVES, getFieldEditorParent());
54         addField(annotatePerspectiveToUse);
55
56         binaryPrompt = new RadioGroupFieldEditor(ICVSUIConstants.PREF_ANNOTATE_PROMPTFORBINARY, CVSUIMessages.AnnotatePreferencePage_AnnotatePrefPageBinaryFileMessage, 3, new String JavaDoc[][] { {CVSUIMessages.CVSPreferencesPage_11, MessageDialogWithToggle.ALWAYS}, {CVSUIMessages.CVSPreferencesPage_12, MessageDialogWithToggle.NEVER}, {CVSUIMessages.CVSPreferencesPage_13, MessageDialogWithToggle.PROMPT}}, getFieldEditorParent(), true /* use a group */);
57         addField(binaryPrompt);
58
59         Dialog.applyDialogFont(getFieldEditorParent());
60         getFieldEditorParent().layout(true);
61     }
62
63     public void init(IWorkbench workbench) {
64     }
65
66     private void initPerspectiveLabels() {
67         final IPerspectiveDescriptor[] perspectives = PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
68         PERSPECTIVES = new String JavaDoc[perspectives.length + 1][2];
69         Arrays.sort(perspectives, new PerspectiveDescriptorComparator());
70         PERSPECTIVES[0][0] = CVSUIMessages.CVSPreferencesPage_10;
71         PERSPECTIVES[0][1] = ICVSUIConstants.OPTION_NO_PERSPECTIVE;
72         for (int i = 0; i < perspectives.length; i++) {
73             PERSPECTIVES[i + 1][0] = perspectives[i].getLabel();
74             PERSPECTIVES[i + 1][1] = perspectives[i].getId();
75         }
76     }
77
78     /* (non-Javadoc)
79      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
80      */

81     public boolean performOk() {
82         CVSUIPlugin.getPlugin().savePluginPreferences();
83         return super.performOk();
84     }
85 }
86
Popular Tags