Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 30657
Collapse All | Expand All

(-).project (+1 lines)
Lines 18-23 Link Here
18
		<project>org.eclipse.ui.editors</project>
18
		<project>org.eclipse.ui.editors</project>
19
		<project>org.eclipse.ui.ide</project>
19
		<project>org.eclipse.ui.ide</project>
20
		<project>org.eclipse.ui.views</project>
20
		<project>org.eclipse.ui.views</project>
21
		<project>org.eclipse.ui.workbench</project>
21
		<project>org.eclipse.ui.workbench.texteditor</project>
22
		<project>org.eclipse.ui.workbench.texteditor</project>
22
	</projects>
23
	</projects>
23
	<buildSpec>
24
	<buildSpec>
(-)src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java (-1 / +4 lines)
Lines 98-104 Link Here
98
	// constants used by watch/edit as values for string preference
98
	// constants used by watch/edit as values for string preference
99
	public static final String EDIT = "edit"; //$NON-NLS-1$
99
	public static final String EDIT = "edit"; //$NON-NLS-1$
100
	public static final String HIGHJACK = "highjack"; //$NON-NLS-1$
100
	public static final String HIGHJACK = "highjack"; //$NON-NLS-1$
101
	
101
	public static final String NEVERPROMPT = "neverPompt";
102
	public static final String ALWAYSPROMPT = "alwaysPompt";	
103
	public static final String ONLYPROMPT = "onlyPompt";	
102
	/**
104
	/**
103
	 * CVSUIPlugin constructor
105
	 * CVSUIPlugin constructor
104
	 * 
106
	 * 
Lines 644-649 Link Here
644
		// Set the watch/edit preferences defaults and values
646
		// Set the watch/edit preferences defaults and values
645
		store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY));
647
		store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY));
646
		store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, EDIT);
648
		store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, EDIT);
649
		store.setDefault(ICVSUIConstants.PREF_EDIT_PROMPT,ALWAYSPROMPT);
647
		// Ensure that the preference values in UI match Core
650
		// Ensure that the preference values in UI match Core
648
		store.setValue(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getBoolean(CVSProviderPlugin.READ_ONLY));
651
		store.setValue(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getBoolean(CVSProviderPlugin.READ_ONLY));
649
		
652
		
(-)src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java (-9 / +44 lines)
Lines 19-24 Link Here
19
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.jface.dialogs.MessageDialog;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
23
import org.eclipse.jface.operation.IRunnableWithProgress;
23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.team.core.RepositoryProvider;
25
import org.eclipse.team.core.RepositoryProvider;
Lines 30-35 Link Here
30
import org.eclipse.team.internal.ccvs.core.ICVSFileModificationValidator;
31
import org.eclipse.team.internal.ccvs.core.ICVSFileModificationValidator;
31
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
32
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
32
import org.eclipse.team.internal.ccvs.ui.actions.EditorsAction;
33
import org.eclipse.team.internal.ccvs.ui.actions.EditorsAction;
34
import org.eclipse.team.internal.ccvs.ui.Policy;
33
35
34
/**
36
/**
35
 * IFileModificationValidator that is pluged into the CVS Repository Provider
37
 * IFileModificationValidator that is pluged into the CVS Repository Provider
Lines 118-124 Link Here
118
		}
120
		}
119
		return new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, Policy.bind("internal"), target); //$NON-NLS-1$
121
		return new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, Policy.bind("internal"), target); //$NON-NLS-1$
120
	}
122
	}
121
		
123
	
122
	private IStatus edit(final IFile[] files, Shell shell) {
124
	private IStatus edit(final IFile[] files, Shell shell) {
123
		try {
125
		try {
124
			if (!promptToEditFiles(files, shell)) {
126
			if (!promptToEditFiles(files, shell)) {
Lines 152-165 Link Here
152
154
153
	private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
155
	private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
154
		if (files.length == 0)
156
		if (files.length == 0)
155
			return true;
157
			return true;		
156
		
158
157
		EditorsAction editors = new EditorsAction(getProvider(files),files);
159
		if (isPerformEdit() ) {
158
		if (editors.isPerformEdit()) {
160
			if(isNeverPrompt())	
159
			// determine if there are any editors of the file registered on the server
161
				return true;
160
			run(shell, editors);
162
161
			// prompt if there are
163
			// Contact the server to see if anyone else is editing the files
162
			return editors.promptToEdit(shell);
164
			EditorsAction editors = fetchEditors(files, shell);
165
			if (editors.isEmpty()) {
166
				if (isAlwaysPrompt())
167
					return (promptEdit(shell));
168
				else
169
					return true;
170
			} else {
171
				return (editors.promptToEdit(shell));
172
			}								
173
163
		} else {
174
		} else {
164
			// Allow the files to be edited without notifying the server
175
			// Allow the files to be edited without notifying the server
165
			for (int i = 0; i < files.length; i++) {
176
			for (int i = 0; i < files.length; i++) {
Lines 171-176 Link Here
171
182
172
	}
183
	}
173
	
184
	
185
	private boolean promptEdit(Shell shell) {
186
		return MessageDialog.openQuestion(shell,Policy.bind("FileModificationValidator.3"),Policy.bind("FileModificationValidator.4")); //$NON-NLS-1$ //$NON-NLS-2$
187
	}
188
189
	public boolean isPerformEdit() {
190
		return CVSUIPlugin.EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
191
	}
192
	
193
	private EditorsAction fetchEditors(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
194
		EditorsAction editors = new EditorsAction(getProvider(files),files);
195
		run(shell, editors);
196
		return editors;
197
	}
198
199
	private boolean isNeverPrompt() {
200
		return CVSUIPlugin.NEVERPROMPT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT));
201
	}
202
203
	private boolean isAlwaysPrompt() {
204
		return CVSUIPlugin.ALWAYSPROMPT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT));
205
	}	
206
207
174
	private void run(Shell shell, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
208
	private void run(Shell shell, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
175
		final InvocationTargetException[] exception = new InvocationTargetException[] { null };
209
		final InvocationTargetException[] exception = new InvocationTargetException[] { null };
176
		CVSUIPlugin.runWithProgress(shell, false, runnable, CVSUIPlugin.PERFORM_SYNC_EXEC);
210
		CVSUIPlugin.runWithProgress(shell, false, runnable, CVSUIPlugin.PERFORM_SYNC_EXEC);
Lines 179-182 Link Here
179
	private void edit(IFile[] files, IProgressMonitor monitor) throws CVSException {
213
	private void edit(IFile[] files, IProgressMonitor monitor) throws CVSException {
180
		getProvider(files).edit(files, false /* recurse */, true /* notify server */, ICVSFile.NO_NOTIFICATION, monitor);
214
		getProvider(files).edit(files, false /* recurse */, true /* notify server */, ICVSFile.NO_NOTIFICATION, monitor);
181
	}
215
	}
216
182
}
217
}
(-)src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java (+1 lines)
Lines 102-107 Link Here
102
	// watch/edit preferences
102
	// watch/edit preferences
103
	public final String PREF_CHECKOUT_READ_ONLY = "pref_checkout_read_only"; //$NON-NLS-1$
103
	public final String PREF_CHECKOUT_READ_ONLY = "pref_checkout_read_only"; //$NON-NLS-1$
104
	public final String PREF_EDIT_ACTION = "pref_edit_action"; //$NON-NLS-1$
104
	public final String PREF_EDIT_ACTION = "pref_edit_action"; //$NON-NLS-1$
105
	public final String PREF_EDIT_PROMPT = "pref_edit_prompt";
105
	
106
	
106
	// Repositories view preferences
107
	// Repositories view preferences
107
	public final String PREF_GROUP_VERSIONS_BY_PROJECT = "pref_group_versions_by_project"; //$NON-NLS-1$
108
	public final String PREF_GROUP_VERSIONS_BY_PROJECT = "pref_group_versions_by_project"; //$NON-NLS-1$
(-)src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java (-6 / +49 lines)
Lines 14-19 Link Here
14
import org.eclipse.jface.preference.BooleanFieldEditor;
14
import org.eclipse.jface.preference.BooleanFieldEditor;
15
import org.eclipse.jface.preference.IPreferenceStore;
15
import org.eclipse.jface.preference.IPreferenceStore;
16
import org.eclipse.jface.preference.RadioGroupFieldEditor;
16
import org.eclipse.jface.preference.RadioGroupFieldEditor;
17
import org.eclipse.jface.util.PropertyChangeEvent;
17
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
18
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
18
19
19
/**
20
/**
Lines 21-26 Link Here
21
 */
22
 */
22
public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
23
public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
23
	
24
	
25
	private RadioGroupFieldEditor promptEditor;
26
	private RadioGroupFieldEditor actionEditor;
27
	private IPreferenceStore source;
28
	private IPreferenceStore store;
29
24
	/**
30
	/**
25
	 * @see org.eclipse.team.internal.ccvs.ui.CVSPreferencePage#getPageHelpContextId()
31
	 * @see org.eclipse.team.internal.ccvs.ui.CVSPreferencePage#getPageHelpContextId()
26
	 */
32
	 */
Lines 43-55 Link Here
43
			Policy.bind("WatchEditPreferencePage.checkoutReadOnly"),  //$NON-NLS-1$
49
			Policy.bind("WatchEditPreferencePage.checkoutReadOnly"),  //$NON-NLS-1$
44
			BooleanFieldEditor.DEFAULT, 
50
			BooleanFieldEditor.DEFAULT, 
45
			getFieldEditorParent()));
51
			getFieldEditorParent()));
46
		addField(new RadioGroupFieldEditor(
52
		
53
		actionEditor = new RadioGroupFieldEditor(
47
			ICVSUIConstants.PREF_EDIT_ACTION,
54
			ICVSUIConstants.PREF_EDIT_ACTION,
48
			Policy.bind("WatchEditPreferencePage.validateEditSaveAction"), //$NON-NLS-1$
55
			Policy.bind("WatchEditPreferencePage.validateEditSaveAction"), //$NON-NLS-1$
49
			1,
56
			1,
50
			new String[][] {{Policy.bind("WatchEditPreferencePage.edit"), CVSUIPlugin.EDIT}, {Policy.bind("WatchEditPreferencePage.highjack"), CVSUIPlugin.HIGHJACK}}, //$NON-NLS-1$ //$NON-NLS-2$
57
			new String[][] {{Policy.bind("WatchEditPreferencePage.edit"), CVSUIPlugin.EDIT},  //$NON-NLS-1$
51
			getFieldEditorParent(), true));
58
							{Policy.bind("WatchEditPreferencePage.highjack"), CVSUIPlugin.HIGHJACK}, //$NON-NLS-1$
52
	}
59
							}, 	//$NON-NLS-1$ //$NON-NLS-2$
60
			getFieldEditorParent(), true);
61
		addField(actionEditor);
62
63
		
64
		promptEditor = new RadioGroupFieldEditor(
65
			ICVSUIConstants.PREF_EDIT_PROMPT,
66
			Policy.bind("WatchEditPreferencePage.editPrompt"), //$NON-NLS-1$
67
			1,
68
			new String[][] {{Policy.bind("WatchEditPreferencePage.alwaysPrompt"), CVSUIPlugin.ALWAYSPROMPT}, //$NON-NLS-1$
69
							{Policy.bind("WatchEditPreferencePage.onlyPrompt"), CVSUIPlugin.ONLYPROMPT}, //$NON-NLS-1$
70
							{Policy.bind("WatchEditPreferencePage.neverPrompt"), CVSUIPlugin.NEVERPROMPT}, //$NON-NLS-1$
71
							},	//$NON-NLS-1$ //$NON-NLS-2$
72
			getFieldEditorParent(), true);
73
		store = getCVSPreferenceStore();
74
		addField(promptEditor);
75
		}
53
76
54
	/**
77
	/**
55
	 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
78
	 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
Lines 61-71 Link Here
61
	}
84
	}
62
85
63
	private void pushPreferences() {
86
	private void pushPreferences() {
64
		IPreferenceStore source = getCVSPreferenceStore();
87
		store = getCVSPreferenceStore();
65
		Preferences target = CVSProviderPlugin.getPlugin().getPluginPreferences();
88
		Preferences target = CVSProviderPlugin.getPlugin().getPluginPreferences();
66
		target.setValue(
89
		target.setValue(
67
			CVSProviderPlugin.READ_ONLY,
90
			CVSProviderPlugin.READ_ONLY,
68
			source.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY));
91
			store.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY));
69
	}
92
	}
70
	
93
	
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
96
	 */
97
	public void propertyChange(PropertyChangeEvent event) {
98
		if (event.getNewValue().equals(CVSUIPlugin.HIGHJACK))
99
		{	
100
			promptEditor.loadDefault();
101
			promptEditor.setEnabled(false,getFieldEditorParent());
102
		}
103
		else if (event.getNewValue().equals(CVSUIPlugin.EDIT))
104
		{
105
			promptEditor.loadDefault();
106
			promptEditor.setEnabled(true,getFieldEditorParent());
107
		}
108
		else 
109
			promptEditor.setEnabled(true,getFieldEditorParent());
110
		super.propertyChange(event);
111
	}
112
113
71
}
114
}
(-)src/org/eclipse/team/internal/ccvs/ui/messages.properties (-2 / +8 lines)
Lines 863-870 Link Here
863
WatchEditPreferencePage.description=Settings for CVS Watch/Edit.
863
WatchEditPreferencePage.description=Settings for CVS Watch/Edit.
864
WatchEditPreferencePage.checkoutReadOnly=&Configure projects to use Watch/Edit on checkout
864
WatchEditPreferencePage.checkoutReadOnly=&Configure projects to use Watch/Edit on checkout
865
WatchEditPreferencePage.validateEditSaveAction=When read-only files are modified in an editor
865
WatchEditPreferencePage.validateEditSaveAction=When read-only files are modified in an editor
866
WatchEditPreferencePage.edit=Send a cvs &edit notification to the server
866
WatchEditPreferencePage.edit=Send a CVS &edit notification to the server
867
WatchEditPreferencePage.highjack=Edit the file &without informing the server
867
WatchEditPreferencePage.highjack=Edit the file &without informing the server
868
WatchEditPreferencePage.editPrompt=Before a CVS edit notification is sent to server
869
WatchEditPreferencePage.neverPrompt=&Never prompt
870
WatchEditPreferencePage.alwaysPrompt=Always &prompt
871
WatchEditPreferencePage.onlyPrompt=&Only prompt if there are other editors
868
872
869
Uneditaction.confirmMessage=Overwrite local changes to edited files?
873
Uneditaction.confirmMessage=Overwrite local changes to edited files?
870
Uneditaction.confirmTitle=Confirm Unedit
874
Uneditaction.confirmTitle=Confirm Unedit
Lines 886-892 Link Here
886
EditorsView.computer=Computer name
890
EditorsView.computer=Computer name
887
891
888
EditorsDialog.title=Editors
892
EditorsDialog.title=Editors
889
EditorsDialog.question=The resource already has editors. Do you still want to edit the resource?
893
EditorsDialog.question=The resource already has editors. Do you still want to edit the resource and send a CVS edit notification to server?
890
EditorsAction.classNotInitialized={0} not initialized
894
EditorsAction.classNotInitialized={0} not initialized
891
895
892
TargetLocationSelectionDialog.projectNameLabel=&Project Name:
896
TargetLocationSelectionDialog.projectNameLabel=&Project Name:
Lines 1053-1055 Link Here
1053
SubscriberConfirmMergedAction.0=Synchronization information is missing for resource {0}
1057
SubscriberConfirmMergedAction.0=Synchronization information is missing for resource {0}
1054
SubscriberConfirmMergedAction.jobName=Performing a CVS Mark as Merged operation on {0} resources.
1058
SubscriberConfirmMergedAction.jobName=Performing a CVS Mark as Merged operation on {0} resources.
1055
CVSSubscriberAction.0=Invalid attemp to make unsupervised resource {0} in-sync.
1059
CVSSubscriberAction.0=Invalid attemp to make unsupervised resource {0} in-sync.
1060
FileModificationValidator.3=Perform Edit?
1061
FileModificationValidator.4=A CVS edit notification is required to be sent to the server in order to allow editing of one or more selected files. Continue?
(-)src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java (-8 / +6 lines)
Lines 57-73 Link Here
57
			f_editorsInfo = provider.editors(resources, monitor);
57
			f_editorsInfo = provider.editors(resources, monitor);
58
			return Team.OK_STATUS;
58
			return Team.OK_STATUS;
59
	}
59
	}
60
61
	public boolean isPerformEdit() {
62
		return CVSUIPlugin.EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
63
	}
64
	
65
	
60
	
66
	public boolean promptToEdit(Shell shell) {
61
	public boolean promptToEdit(Shell shell) {
67
	
62
	
68
		if (!isPerformEdit()) return true;
63
		if (!isEmpty()) {
69
		
70
		if (f_editorsInfo.length > 0) {
71
			final EditorsDialog view = new EditorsDialog(shell, f_editorsInfo);
64
			final EditorsDialog view = new EditorsDialog(shell, f_editorsInfo);
72
			// Open the dialog using a sync exec (there are no guarentees that we
65
			// Open the dialog using a sync exec (there are no guarentees that we
73
			// were called from the UI thread
66
			// were called from the UI thread
Lines 105-110 Link Here
105
	 */
98
	 */
106
	public EditorsInfo[] getEditorsInfo() {
99
	public EditorsInfo[] getEditorsInfo() {
107
		return f_editorsInfo;
100
		return f_editorsInfo;
101
	}
102
103
104
	public boolean isEmpty() {
105
		return f_editorsInfo.length == 0;
108
	}
106
	}
109
107
110
}
108
}

Return to bug 30657