1 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 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 31 protected String getPageHelpContextId() { 32 return IHelpContextIds.WATCH_EDIT_PREFERENCE_PAGE; 33 } 34 35 38 protected String getPageDescription() { 39 return CVSUIMessages.WatchEditPreferencePage_description; } 41 42 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 [][] {{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 }, getFieldEditorParent(), true); 66 addField(actionEditor); 67 68 promptEditor = new RadioGroupFieldEditor( 69 ICVSUIConstants.PREF_EDIT_PROMPT, 70 CVSUIMessages.WatchEditPreferencePage_editPrompt, 71 1, 72 new String [][] {{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 }, getFieldEditorParent(), true); 77 78 updateEditor = new RadioGroupFieldEditor( 79 ICVSUIConstants.PREF_UPDATE_PROMPT, 80 CVSUIMessages.WatchEditPreferencePage_updatePrompt, 81 1, 82 new String [][] {{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 }, 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 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 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 127 protected void initialize() { 128 super.initialize(); 129 promptEditor.setEnabled(isEditEnabled(), getFieldEditorParent()); 130 updateEditor.setEnabled(isEditEnabled(), getFieldEditorParent()); 131 } 132 } 133 | Popular Tags |