|
Lines 66-71
Link Here
|
| 66 |
throw new InterruptedException(); |
66 |
throw new InterruptedException(); |
| 67 |
} |
67 |
} |
| 68 |
|
68 |
|
|
|
69 |
// see if the file is up to date |
| 70 |
if (shell != null && promptToUpdateFiles(files, shell)) { |
| 71 |
// The user wants to update the file |
| 72 |
// Run the update in a runnable in order to get a busy cursor. |
| 73 |
// This runnable is syncExeced in order to get a busy cursor |
| 74 |
IRunnableWithProgress updateRunnable = new IRunnableWithProgress() { |
| 75 |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
| 76 |
try { |
| 77 |
performUpdate(files, monitor); |
| 78 |
} catch (CVSException e) { |
| 79 |
new InvocationTargetException(e); |
| 80 |
} |
| 81 |
} |
| 82 |
}; |
| 83 |
if (isRunningInUIThread()) { |
| 84 |
// Only show a busy cursor if validate edit is blocking the UI |
| 85 |
CVSUIPlugin.runWithProgress(shell, false, updateRunnable); |
| 86 |
} else { |
| 87 |
// We can't show a busy cursor (i.e., run in the UI thread) |
| 88 |
// since this thread may hold locks and |
| 89 |
// running an edit in the UI thread could try to obtain the |
| 90 |
// same locks, resulting in a deadlock. |
| 91 |
updateRunnable.run(new NullProgressMonitor()); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 69 |
// Run the edit in a runnable in order to get a busy cursor. |
95 |
// Run the edit in a runnable in order to get a busy cursor. |
| 70 |
// This runnable is syncExeced in order to get a busy cursor |
96 |
// This runnable is syncExeced in order to get a busy cursor |
| 71 |
IRunnableWithProgress editRunnable = new IRunnableWithProgress() { |
97 |
IRunnableWithProgress editRunnable = new IRunnableWithProgress() { |
|
Lines 139-144
Link Here
|
| 139 |
} |
165 |
} |
| 140 |
} |
166 |
} |
| 141 |
|
167 |
|
|
|
168 |
private boolean promptToUpdateFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { |
| 169 |
if (files.length == 0) |
| 170 |
return false; |
| 171 |
|
| 172 |
if (isNeverUpdate()) |
| 173 |
return false; |
| 174 |
|
| 175 |
// Contact the server to see if the files are up-to-date |
| 176 |
for (int i = 0; i < files.length; i++) { |
| 177 |
if (needsUpdate(files[i], new NullProgressMonitor())) { |
| 178 |
if (isPromptUpdate()) |
| 179 |
return (promptUpdate(shell)); |
| 180 |
return true; // auto update |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
return false; |
| 185 |
} |
| 186 |
|
| 142 |
private boolean promptEdit(Shell shell) { |
187 |
private boolean promptEdit(Shell shell) { |
| 143 |
// Open the dialog using a sync exec (there are no guarentees that we |
188 |
// Open the dialog using a sync exec (there are no guarentees that we |
| 144 |
// were called from the UI thread |
189 |
// were called from the UI thread |
|
Lines 152-157
Link Here
|
| 152 |
return result[0]; |
197 |
return result[0]; |
| 153 |
} |
198 |
} |
| 154 |
|
199 |
|
|
|
200 |
private boolean promptUpdate(Shell shell) { |
| 201 |
// Open the dialog using a sync exec (there are no guarentees that we |
| 202 |
// were called from the UI thread |
| 203 |
final boolean[] result = new boolean[] { false }; |
| 204 |
int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC; |
| 205 |
CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { |
| 206 |
public void open(Shell shell) { |
| 207 |
result[0] = MessageDialog.openQuestion(shell,CVSUIMessages.FileModificationValidator_5,CVSUIMessages.FileModificationValidator_6); |
| 208 |
} |
| 209 |
}, flags); |
| 210 |
return result[0]; |
| 211 |
} |
| 212 |
|
| 155 |
private boolean isPerformEdit() { |
213 |
private boolean isPerformEdit() { |
| 156 |
return ICVSUIConstants.PREF_EDIT_PROMPT_EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION)); |
214 |
return ICVSUIConstants.PREF_EDIT_PROMPT_EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION)); |
| 157 |
} |
215 |
} |
|
Lines 187-190
Link Here
|
| 187 |
private boolean isAlwaysPrompt() { |
245 |
private boolean isAlwaysPrompt() { |
| 188 |
return ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT)); |
246 |
return ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT)); |
| 189 |
} |
247 |
} |
|
|
248 |
|
| 249 |
private boolean isPromptUpdate() { |
| 250 |
return ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); |
| 251 |
} |
| 252 |
|
| 253 |
private boolean isNeverUpdate() { |
| 254 |
return ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); |
| 255 |
} |
| 190 |
} |
256 |
} |