Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bf56f01ea6e19a2a3cff41407c3abd30b180bda4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.*;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;

/**
 * This page contains preferences related to the cvs watch/edit commands
 */
public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
	
	private RadioGroupFieldEditor promptEditor;
    private RadioGroupFieldEditor updateEditor;
	private RadioGroupFieldEditor actionEditor;
	private IPreferenceStore store;

	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageHelpContextId()
	 */
	protected String getPageHelpContextId() {
		return IHelpContextIds.WATCH_EDIT_PREFERENCE_PAGE;
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageDescription()
	 */
	protected String getPageDescription() {
		return CVSUIMessages.WatchEditPreferencePage_description; //;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
	 */
	protected void createFieldEditors() {
		addField(new BooleanFieldEditor(
			ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, 
			CVSUIMessages.WatchEditPreferencePage_checkoutReadOnly,  
			BooleanFieldEditor.DEFAULT, 
			getFieldEditorParent()));
		addField(new BooleanFieldEditor(
				ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, 
				CVSUIMessages.WatchEditPreferencePage_0,  
				BooleanFieldEditor.DEFAULT, 
				getFieldEditorParent()));
		
		actionEditor = new RadioGroupFieldEditor(
			ICVSUIConstants.PREF_EDIT_ACTION,
			CVSUIMessages.WatchEditPreferencePage_validateEditSaveAction, 
			1,
			new String[][] {{CVSUIMessages.WatchEditPreferencePage_edit, ICVSUIConstants.PREF_EDIT_PROMPT_EDIT},
                            {CVSUIMessages.WatchEditPreferencePage_editInBackground, ICVSUIConstants.PREF_EDIT_IN_BACKGROUND},
							{CVSUIMessages.WatchEditPreferencePage_highjack, ICVSUIConstants.PREF_EDIT_PROMPT_HIGHJACK},
							}, 	// 
			getFieldEditorParent(), true);
		addField(actionEditor);
		
		promptEditor = new RadioGroupFieldEditor(
			ICVSUIConstants.PREF_EDIT_PROMPT,
			CVSUIMessages.WatchEditPreferencePage_editPrompt, 
			1,
			new String[][] {{CVSUIMessages.WatchEditPreferencePage_alwaysPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS}, 
							{CVSUIMessages.WatchEditPreferencePage_onlyPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS}, 
							{CVSUIMessages.WatchEditPreferencePage_neverPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_NEVER}, 
							},	// 
			getFieldEditorParent(), true);
        
        updateEditor = new RadioGroupFieldEditor(
                ICVSUIConstants.PREF_UPDATE_PROMPT,
                CVSUIMessages.WatchEditPreferencePage_updatePrompt, 
                1,
                new String[][] {{CVSUIMessages.WatchEditPreferencePage_autoUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_AUTO}, 
                                {CVSUIMessages.WatchEditPreferencePage_promptUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED}, 
                                {CVSUIMessages.WatchEditPreferencePage_neverUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER}, 
                                },  // 
                getFieldEditorParent(), true);
        
		store = getCVSPreferenceStore();
		addField(promptEditor);
        addField(updateEditor);
	}

	private boolean isEditEnabled() {
		return store.getString(ICVSUIConstants.PREF_EDIT_ACTION).equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#pushPreferences()
	 */
	protected void pushPreferences() {
		store = getCVSPreferenceStore();
		Preferences target = CVSProviderPlugin.getPlugin().getPluginPreferences();
		target.setValue(
			CVSProviderPlugin.READ_ONLY,
			store.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY));
		target.setValue(
				CVSProviderPlugin.ENABLE_WATCH_ON_EDIT,
				store.getBoolean(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT));
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
	 */
	public void propertyChange(PropertyChangeEvent event) {
		if (event.getSource() == actionEditor) {
            boolean enabled = event.getNewValue().equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT);
			promptEditor.setEnabled(enabled, getFieldEditorParent());
            updateEditor.setEnabled(enabled, getFieldEditorParent());
        }
		super.propertyChange(event);
	}


	/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
	 */
	protected void initialize() {
		super.initialize();
		promptEditor.setEnabled(isEditEnabled(), getFieldEditorParent());
        updateEditor.setEnabled(isEditEnabled(), getFieldEditorParent());
	}
}

Back to the top