KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.runtime.Preferences;
14 import org.eclipse.jface.preference.*;
15 import org.eclipse.jface.util.PropertyChangeEvent;
16 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
17
18 /**
19  * This page contains preferences related to the cvs watch/edit commands
20  */

21 public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
22     
23     private RadioGroupFieldEditor promptEditor;
24     private RadioGroupFieldEditor updateEditor;
25     private RadioGroupFieldEditor actionEditor;
26     private IPreferenceStore store;
27
28     /* (non-Javadoc)
29      * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageHelpContextId()
30      */

31     protected String JavaDoc getPageHelpContextId() {
32         return IHelpContextIds.WATCH_EDIT_PREFERENCE_PAGE;
33     }
34     
35     /* (non-Javadoc)
36      * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageDescription()
37      */

38     protected String JavaDoc getPageDescription() {
39         return CVSUIMessages.WatchEditPreferencePage_description; //;
40
}
41
42     /* (non-Javadoc)
43      * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
44      */

45     protected void createFieldEditors() {
46         addField(new BooleanFieldEditor(
47             ICVSUIConstants.PREF_CHECKOUT_READ_ONLY,
48             CVSUIMessages.WatchEditPreferencePage_checkoutReadOnly,
49             BooleanFieldEditor.DEFAULT,
50             getFieldEditorParent()));
51         addField(new BooleanFieldEditor(
52                 ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT,
53                 CVSUIMessages.WatchEditPreferencePage_0,
54                 BooleanFieldEditor.DEFAULT,
55                 getFieldEditorParent()));
56         
57         actionEditor = new RadioGroupFieldEditor(
58             ICVSUIConstants.PREF_EDIT_ACTION,
59             CVSUIMessages.WatchEditPreferencePage_validateEditSaveAction,
60             1,
61             new String JavaDoc[][] {{CVSUIMessages.WatchEditPreferencePage_edit, ICVSUIConstants.PREF_EDIT_PROMPT_EDIT},
62                             {CVSUIMessages.WatchEditPreferencePage_editInBackground, ICVSUIConstants.PREF_EDIT_IN_BACKGROUND},
63                             {CVSUIMessages.WatchEditPreferencePage_highjack, ICVSUIConstants.PREF_EDIT_PROMPT_HIGHJACK},
64                             }, //
65
getFieldEditorParent(), true);
66         addField(actionEditor);
67         
68         promptEditor = new RadioGroupFieldEditor(
69             ICVSUIConstants.PREF_EDIT_PROMPT,
70             CVSUIMessages.WatchEditPreferencePage_editPrompt,
71             1,
72             new String JavaDoc[][] {{CVSUIMessages.WatchEditPreferencePage_alwaysPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS},
73                             {CVSUIMessages.WatchEditPreferencePage_onlyPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS},
74                             {CVSUIMessages.WatchEditPreferencePage_neverPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_NEVER},
75                             }, //
76
getFieldEditorParent(), true);
77         
78         updateEditor = new RadioGroupFieldEditor(
79                 ICVSUIConstants.PREF_UPDATE_PROMPT,
80                 CVSUIMessages.WatchEditPreferencePage_updatePrompt,
81                 1,
82                 new String JavaDoc[][] {{CVSUIMessages.WatchEditPreferencePage_autoUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_AUTO},
83                                 {CVSUIMessages.WatchEditPreferencePage_promptUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED},
84                                 {CVSUIMessages.WatchEditPreferencePage_neverUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER},
85                                 }, //
86
getFieldEditorParent(), true);
87         
88         store = getCVSPreferenceStore();
89         addField(promptEditor);
90         addField(updateEditor);
91     }
92
93     private boolean isEditEnabled() {
94         return store.getString(ICVSUIConstants.PREF_EDIT_ACTION).equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT);
95     }
96
97     /* (non-Javadoc)
98      * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#pushPreferences()
99      */

100     protected void pushPreferences() {
101         store = getCVSPreferenceStore();
102         Preferences target = CVSProviderPlugin.getPlugin().getPluginPreferences();
103         target.setValue(
104             CVSProviderPlugin.READ_ONLY,
105             store.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY));
106         target.setValue(
107                 CVSProviderPlugin.ENABLE_WATCH_ON_EDIT,
108                 store.getBoolean(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT));
109     }
110     
111     /* (non-Javadoc)
112      * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
113      */

114     public void propertyChange(PropertyChangeEvent event) {
115         if (event.getSource() == actionEditor) {
116             boolean enabled = event.getNewValue().equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT);
117             promptEditor.setEnabled(enabled, getFieldEditorParent());
118             updateEditor.setEnabled(enabled, getFieldEditorParent());
119         }
120         super.propertyChange(event);
121     }
122
123
124     /* (non-Javadoc)
125      * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
126      */

127     protected void initialize() {
128         super.initialize();
129         promptEditor.setEnabled(isEditEnabled(), getFieldEditorParent());
130         updateEditor.setEnabled(isEditEnabled(), getFieldEditorParent());
131     }
132 }
133
Popular Tags