Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java256
1 files changed, 128 insertions, 128 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java
index 1dc8cb7b5..3941ece06 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java
@@ -45,11 +45,11 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
public FileModificationValidator() {
}
- @Override
+ @Override
protected IStatus edit(IFile[] readOnlyFiles, FileModificationValidationContext context) {
- return edit(readOnlyFiles, getShell(context));
- }
-
+ return edit(readOnlyFiles, getShell(context));
+ }
+
private Shell getShell(FileModificationValidationContext context) {
if (context == null)
return null;
@@ -77,24 +77,24 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
throw new InterruptedException();
}
- // see if the file is up to date
- if (shell != null && promptToUpdateFiles(files, shell)) {
- // The user wants to update the file
- // Run the update in a runnable in order to get a busy cursor.
- // This runnable is syncExeced in order to get a busy cursor
+ // see if the file is up to date
+ if (shell != null && promptToUpdateFiles(files, shell)) {
+ // The user wants to update the file
+ // Run the update in a runnable in order to get a busy cursor.
+ // This runnable is syncExeced in order to get a busy cursor
IRunnableWithProgress updateRunnable = monitor -> performUpdate(files, monitor);
- if (isRunningInUIThread()) {
- // Only show a busy cursor if validate edit is blocking the UI
- CVSUIPlugin.runWithProgress(shell, false, updateRunnable);
- } else {
- // We can't show a busy cursor (i.e., run in the UI thread)
- // since this thread may hold locks and
- // running an edit in the UI thread could try to obtain the
- // same locks, resulting in a deadlock.
- updateRunnable.run(new NullProgressMonitor());
- }
- }
-
+ if (isRunningInUIThread()) {
+ // Only show a busy cursor if validate edit is blocking the UI
+ CVSUIPlugin.runWithProgress(shell, false, updateRunnable);
+ } else {
+ // We can't show a busy cursor (i.e., run in the UI thread)
+ // since this thread may hold locks and
+ // running an edit in the UI thread could try to obtain the
+ // same locks, resulting in a deadlock.
+ updateRunnable.run(new NullProgressMonitor());
+ }
+ }
+
// Run the edit in a runnable in order to get a busy cursor.
// This runnable is syncExeced in order to get a busy cursor
IRunnableWithProgress editRunnable = monitor -> {
@@ -105,14 +105,14 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
}
};
if (isRunningInUIThread()) {
- // Only show a busy cursor if validate edit is blocking the UI
- CVSUIPlugin.runWithProgress(shell, false, editRunnable);
+ // Only show a busy cursor if validate edit is blocking the UI
+ CVSUIPlugin.runWithProgress(shell, false, editRunnable);
} else {
- // We can't show a busy cursor (i.e., run in the UI thread)
- // since this thread may hold locks and
- // running an edit in the UI thread could try to obtain the
- // same locks, resulting in a deadlock.
- editRunnable.run(new NullProgressMonitor());
+ // We can't show a busy cursor (i.e., run in the UI thread)
+ // since this thread may hold locks and
+ // running an edit in the UI thread could try to obtain the
+ // same locks, resulting in a deadlock.
+ editRunnable.run(new NullProgressMonitor());
}
} catch (InvocationTargetException e) {
return getStatus(e);
@@ -120,11 +120,11 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
// Must return an error to indicate that it is not OK to edit the files
return new Status(IStatus.CANCEL, CVSUIPlugin.ID, 0, CVSUIMessages.FileModificationValidator_vetoMessage, null); //;
}
- } else if (isPerformEditInBackground()) {
- IStatus status = setWritable(files);
- if (status.isOK())
- performEdit(files);
- return status;
+ } else if (isPerformEditInBackground()) {
+ IStatus status = setWritable(files);
+ if (status.isOK())
+ performEdit(files);
+ return status;
} else {
// Allow the files to be edited without notifying the server
return setWritable(files);
@@ -133,23 +133,23 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
return Status.OK_STATUS;
}
-
- @Override
+
+ @Override
protected void scheduleEditJob(Job job) {
- job.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);
- job.setProperty(IProgressConstants.ICON_PROPERTY, getOperationIcon());
- super.scheduleEditJob(job);
- }
-
- private URL getOperationIcon() {
- return FileLocator.find(CVSUIPlugin.getPlugin().getBundle(), new Path(ICVSUIConstants.ICON_PATH + ICVSUIConstants.IMG_CVS_PERSPECTIVE), null);
- }
-
- private boolean isRunningInUIThread() {
- return Display.getCurrent() != null;
- }
+ job.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);
+ job.setProperty(IProgressConstants.ICON_PROPERTY, getOperationIcon());
+ super.scheduleEditJob(job);
+ }
+
+ private URL getOperationIcon() {
+ return FileLocator.find(CVSUIPlugin.getPlugin().getBundle(), new Path(ICVSUIConstants.ICON_PATH + ICVSUIConstants.IMG_CVS_PERSPECTIVE), null);
+ }
+
+ private boolean isRunningInUIThread() {
+ return Display.getCurrent() != null;
+ }
- private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
+ private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
if (files.length == 0)
return true;
@@ -167,22 +167,22 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
}
}
- private boolean promptToUpdateFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
- if (files.length == 0)
- return false;
-
- if (isNeverUpdate())
- return false;
-
- // Contact the server to see if the files are up-to-date
- if (needsUpdate(files, new NullProgressMonitor())) {
- if (isPromptUpdate())
- return (promptUpdate(shell));
- return true; // auto update
- }
-
- return false;
- }
+ private boolean promptToUpdateFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
+ if (files.length == 0)
+ return false;
+
+ if (isNeverUpdate())
+ return false;
+
+ // Contact the server to see if the files are up-to-date
+ if (needsUpdate(files, new NullProgressMonitor())) {
+ if (isPromptUpdate())
+ return (promptUpdate(shell));
+ return true; // auto update
+ }
+
+ return false;
+ }
private boolean promptEdit(Shell shell) {
// Open the dialog using a sync exec (there are no guarantees that we
@@ -197,39 +197,39 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
return result[0];
}
- private boolean promptUpdate(Shell shell) {
- // Open the dialog using a sync exec (there are no guarantees that we
- // were called from the UI thread
- final boolean[] result = new boolean[] { false };
- int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC;
+ private boolean promptUpdate(Shell shell) {
+ // Open the dialog using a sync exec (there are no guarantees that we
+ // were called from the UI thread
+ final boolean[] result = new boolean[] { false };
+ int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC;
CVSUIPlugin
.openDialog(shell,
shell1 -> result[0] = MessageDialog.openQuestion(shell1,
CVSUIMessages.FileModificationValidator_5, CVSUIMessages.FileModificationValidator_6),
flags);
- return result[0];
- }
+ return result[0];
+ }
private boolean isPerformEdit() {
return ICVSUIConstants.PREF_EDIT_PROMPT_EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
}
-
- private boolean isPerformEditInBackground() {
- return ICVSUIConstants.PREF_EDIT_IN_BACKGROUND.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
- }
+
+ private boolean isPerformEditInBackground() {
+ return ICVSUIConstants.PREF_EDIT_IN_BACKGROUND.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
+ }
private EditorsAction fetchEditors(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
final EditorsAction editors = new EditorsAction(getProvider(files), files);
IRunnableWithProgress runnable = monitor -> editors.run(monitor);
if (isRunningInUIThread()) {
- // Show a busy cursor if we are running in the UI thread
- CVSUIPlugin.runWithProgress(shell, false, runnable);
+ // Show a busy cursor if we are running in the UI thread
+ CVSUIPlugin.runWithProgress(shell, false, runnable);
} else {
- // We can't show a busy cursor (i.e., run in the UI thread)
- // since this thread may hold locks and
- // running a CVS operation in the UI thread could try to obtain the
- // same locks, resulting in a deadlock.
- runnable.run(new NullProgressMonitor());
+ // We can't show a busy cursor (i.e., run in the UI thread)
+ // since this thread may hold locks and
+ // running a CVS operation in the UI thread could try to obtain the
+ // same locks, resulting in a deadlock.
+ runnable.run(new NullProgressMonitor());
}
return editors;
}
@@ -241,51 +241,51 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator
private boolean isAlwaysPrompt() {
return ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT));
}
-
- private boolean needsUpdate(IFile[] files, IProgressMonitor monitor) {
- try {
- CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
- subscriber.refresh(files, IResource.DEPTH_ZERO, monitor);
- for (int i = 0; i < files.length; i++) {
- IFile file = files[i];
- SyncInfo info = subscriber.getSyncInfo(file);
- int direction = info.getKind() & SyncInfo.DIRECTION_MASK;
- if (direction == SyncInfo.CONFLICTING || direction == SyncInfo.INCOMING) {
- return true;
- }
- }
- } catch (TeamException e) {
- // Log the exception and assume we don't need to update it
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
- private void performUpdate(IFile[] files, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- // TODO: This obtains the project rule which can cause a rule violation
- new UpdateOperation(null /* no target part */, files, Command.NO_LOCAL_OPTIONS, null /* no tag */).run(monitor);
- }
-
- private boolean isPromptUpdate() {
- return ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT));
- }
-
- private boolean isNeverUpdate() {
- return ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT));
- }
-
- @Override
+
+ private boolean needsUpdate(IFile[] files, IProgressMonitor monitor) {
+ try {
+ CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
+ subscriber.refresh(files, IResource.DEPTH_ZERO, monitor);
+ for (int i = 0; i < files.length; i++) {
+ IFile file = files[i];
+ SyncInfo info = subscriber.getSyncInfo(file);
+ int direction = info.getKind() & SyncInfo.DIRECTION_MASK;
+ if (direction == SyncInfo.CONFLICTING || direction == SyncInfo.INCOMING) {
+ return true;
+ }
+ }
+ } catch (TeamException e) {
+ // Log the exception and assume we don't need to update it
+ CVSProviderPlugin.log(e);
+ }
+ return false;
+ }
+
+ private void performUpdate(IFile[] files, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ // TODO: This obtains the project rule which can cause a rule violation
+ new UpdateOperation(null /* no target part */, files, Command.NO_LOCAL_OPTIONS, null /* no tag */).run(monitor);
+ }
+
+ private boolean isPromptUpdate() {
+ return ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT));
+ }
+
+ private boolean isNeverUpdate() {
+ return ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT));
+ }
+
+ @Override
public ISchedulingRule validateEditRule(CVSResourceRuleFactory factory, IResource[] resources) {
- if (!isNeverUpdate()) {
- // We may need to perform an update so we need to obtain the lock on each project
- Set projects = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (isReadOnly(resource))
- projects.add(resource.getProject());
- }
- return createSchedulingRule(projects);
- }
- return internalValidateEditRule(factory, resources);
- }
+ if (!isNeverUpdate()) {
+ // We may need to perform an update so we need to obtain the lock on each project
+ Set projects = new HashSet();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (isReadOnly(resource))
+ projects.add(resource.getProject());
+ }
+ return createSchedulingRule(projects);
+ }
+ return internalValidateEditRule(factory, resources);
+ }
}

Back to the top