|
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 |
} |