Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-10 17:15:06 -0400
committerMichael Valenta2002-05-10 17:15:06 -0400
commit6a06d166017343297508c806502a65307ff51a8c (patch)
tree5f0e665fabf6841aef2a92ae485e060436cc3391 /bundles/org.eclipse.team.cvs.ui
parent7ee91957bc30af6ee11335742172498a3aa8a82a (diff)
downloadeclipse.platform.team-6a06d166017343297508c806502a65307ff51a8c.tar.gz
eclipse.platform.team-6a06d166017343297508c806502a65307ff51a8c.tar.xz
eclipse.platform.team-6a06d166017343297508c806502a65307ff51a8c.zip
13971: Need to refresh not obvious from errors in log
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java78
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java58
3 files changed, 125 insertions, 14 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index 8bd5a8351..ee44b691f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -11,16 +11,20 @@
package org.eclipse.team.internal.ccvs.ui;
+import java.util.Hashtable;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Hashtable;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
@@ -33,19 +37,17 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.core.util.AddDeleteMoveListener;
+import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.ui.model.CVSAdapterFactory;
import org.eclipse.team.ui.TeamUIPlugin;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AddMarkerAction;
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* UI Plugin for CVS provider-specific workbench functionality.
@@ -125,6 +127,72 @@ public class CVSUIPlugin extends AbstractUIPlugin implements IPropertyChangeList
}
/**
+ * Run an operation involving the given resource. If an exception is thrown
+ * and the code on the status is IResourceStatus.OUT_OF_SYNC_LOCAL then
+ * the user will be prompted to refresh and try again. If they agree, then the
+ * supplied operation will be run again.
+ */
+ public static void runWithRefresh(Shell parent, IResource resource,
+ IRunnableWithProgress runnable, IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ boolean firstTime = true;
+ while(true) {
+ try {
+ runnable.run(monitor);
+ return;
+ } catch (InvocationTargetException e) {
+ if (! firstTime) throw e;
+ IStatus status = null;
+ if (e.getTargetException() instanceof CoreException) {
+ status = ((CoreException)e.getTargetException()).getStatus();
+ } else if (e.getTargetException() instanceof TeamException) {
+ status = ((TeamException)e.getTargetException()).getStatus();
+ } else {
+ throw e;
+ }
+ if (status.getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) {
+ if (promptToRefresh(parent, resource, status)) {
+ try {
+ resource.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException coreEx) {
+ // Throw the original exception to the caller
+ log(coreEx.getStatus());
+ throw e;
+ }
+ firstTime = false;
+ // Fall through and the operation will be tried again
+ } else {
+ // User chose not to continue. Treat it as a cancel.
+ throw new InterruptedException();
+ }
+ } else {
+ throw e;
+ }
+ }
+ }
+ }
+
+ private static boolean promptToRefresh(final Shell shell, final IResource resource, final IStatus status) {
+ final boolean[] result = new boolean[] { false};
+ Runnable runnable = new Runnable() {
+ public void run() {
+ Shell shellToUse = shell;
+ if (shell == null) {
+ shellToUse = new Shell(Display.getCurrent());
+ }
+ result[0] = MessageDialog.openQuestion(shellToUse, Policy.bind("CVSUIPlugin.refreshTitle"),
+ Policy.bind("CVSUIPlugin.refreshQuestion", status.getMessage(), resource.getFullPath().toString()));
+ }
+ };
+ if (shell == null) {
+ Display.getDefault().syncExec(runnable);
+ } else {
+ runnable.run();
+ }
+ return result[0];
+ }
+
+ /**
* Creates a progress monitor and runs the specified runnable.
* May be called from a non-UI thread.
*
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 90e0b8341..e87deb0d0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -199,6 +199,9 @@ CVSSyncCompareInput.confirmMergeMessage=Your changes have been saved. You can co
select it from the Structure Compare and select 'Confirm Merge' to make this \
file an outgoing change.
+CVSUIPlugin.refreshTitle=Refresh Resource?
+CVSUIPlugin.refreshQuestion={0} Would you like to refresh resource ''{1}''?
+
CheckoutAsAction.checkoutFailed=Problems encountered performing checkout
CheckoutAsAction.enterProjectTitle=Check Out {0} As...
CheckoutAsAction.taskname=Checking out "{0}" from CVS as "{1}"
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
index d9b3e79f8..e1049c652 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
@@ -5,13 +5,16 @@ package org.eclipse.team.internal.ccvs.ui.wizards;
* All Rights Reserved.
*/
-import java.lang.reflect.InvocationTargetException;
import java.util.Properties;
+import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
@@ -21,6 +24,8 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
@@ -33,12 +38,12 @@ import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
-import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
-import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareUnsharedInput;
import org.eclipse.team.internal.ui.sync.SyncView;
import org.eclipse.team.ui.IConfigurationWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PartInitException;
+import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
+import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareUnsharedInput;
/**
* This wizard helps the user to import a new project in their workspace
@@ -315,13 +320,48 @@ public class SharingWizard extends Wizard implements IConfigurationWizard {
private boolean doesCVSDirectoryExist() {
// Determine if there is an existing CVS/ directory from which configuration
// information can be retrieved.
+ Shell shell = null;
+ if (getContainer() != null) {
+ shell = getContainer().getShell();
+ }
+ final boolean[] isCVSFolder = new boolean[] { false };
try {
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- return info != null;
- } catch (TeamException e) {
- ErrorDialog.openError(getContainer().getShell(), null, null, e.getStatus());
- return false;
+ CVSUIPlugin.runWithRefresh(shell, project, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
+ FolderSyncInfo info = folder.getFolderSyncInfo();
+ isCVSFolder[0] = info != null;
+ } catch (final TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ }, null);
+ } catch (InvocationTargetException e) {
+ final IStatus[] status = new IStatus[] { null };
+ if (e.getTargetException() instanceof CoreException) {
+ status[0] = ((CoreException)e.getTargetException()).getStatus();
+ } else if (e.getTargetException() instanceof TeamException) {
+ status[0] = ((TeamException)e.getTargetException()).getStatus();
+ } else {
+ status[0] = new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, e.getTargetException().getMessage(), e.getTargetException());
+ }
+ Runnable runnable = new Runnable() {
+ public void run() {
+ Shell shell = null;
+ if (getContainer() != null) {
+ shell = getContainer().getShell();
+ }
+ ErrorDialog.openError(shell, null, null, status[0]);
+ }
+ };
+ if (shell == null) {
+ Display.getDefault().syncExec(runnable);
+ } else {
+ runnable.run();
+ }
+ } catch (InterruptedException e) {
}
+ return isCVSFolder[0];
}
}

Back to the top