Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java45
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java32
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java17
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileStorage.java38
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java19
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java91
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java68
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java88
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchTag.java31
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSFolderElement.java46
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java39
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java30
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java43
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java40
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java33
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java83
19 files changed, 519 insertions, 254 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 ab933300a..07eeb7109 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,6 +11,7 @@
package org.eclipse.team.internal.ccvs.ui;
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Hashtable;
@@ -18,7 +19,10 @@ import java.util.Hashtable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -26,6 +30,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.RGB;
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;
@@ -61,6 +66,10 @@ public class CVSUIPlugin extends AbstractUIPlugin {
}
}
+ // timeout in milliseconds before displaying a progress monitor dialog
+ // (used for normally short-running interactive operations)
+ private static final int TIMEOUT = 2000;
+
/**
* The singleton plug-in instance
*/
@@ -106,6 +115,42 @@ public class CVSUIPlugin extends AbstractUIPlugin {
}
/**
+ * Creates a progress monitor and runs the specified runnable.
+ * May be called from a non-UI thread.
+ *
+ * @param parent the parent Shell for the dialog
+ * @param cancelable if true, the dialog will support cancelation
+ * @param runnable the runnable
+ *
+ * @exception InvocationTargetException when an exception is thrown from the runnable
+ * @exception InterruptedException when the progress monitor is cancelled
+ */
+ public static void runWithProgress(Shell parent, boolean cancelable,
+ IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
+ boolean createdShell = false;
+ try {
+ if (parent == null || parent.isDisposed()) {
+ Display display = Display.getCurrent();
+ if (display == null) {
+ // cannot provide progress (not in UI thread)
+ runnable.run(new NullProgressMonitor());
+ return;
+ }
+ // get the active shell or a suitable top-level shell
+ parent = display.getActiveShell();
+ if (parent == null) {
+ parent = new Shell(display);
+ createdShell = true;
+ }
+ }
+ // pop up progress dialog after a short delay
+ new TimeoutProgressMonitorDialog(parent, TIMEOUT).run(true /*fork*/, cancelable, runnable);
+ } finally {
+ if (createdShell) parent.dispose();
+ }
+ }
+
+ /**
* Returns the image descriptor for the given image ID.
* Returns null if there is no such image.
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java
index 179d43231..505660ca0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java
@@ -16,7 +16,6 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
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.SubProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -71,7 +70,6 @@ import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ILogEntry;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
@@ -409,20 +407,26 @@ public class HistoryView extends ViewPart implements ISelectionListener {
if (!(inputElement instanceof ICVSRemoteFile)) return null;
final ICVSRemoteFile remoteFile = (ICVSRemoteFile)inputElement;
final Object[][] result = new Object[1][];
- final TeamException[] ex = new TeamException[1];
- BusyIndicator.showWhile(getViewSite().getShell().getDisplay(), new Runnable() {
- public void run() {
- try {
- entries = remoteFile.getLogEntries(new NullProgressMonitor());
- result[0] = entries;
- } catch (TeamException e) {
- ex[0] = e;
+ try {
+ CVSUIPlugin.runWithProgress(getViewer().getTable().getShell(), true /*cancelable*/,
+ new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ entries = remoteFile.getLogEntries(monitor);
+ result[0] = entries;
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
}
+ });
+ } catch (InterruptedException e) { // ignore cancellation
+ result[0] = new Object[0];
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ ErrorDialog.openError(getViewSite().getShell(), null, null, ((TeamException) t).getStatus());
}
- });
- if (ex[0] != null) {
- ErrorDialog.openError(getViewSite().getShell(), null, null, ex[0].getStatus());
- return new Object[0];
+ result[0] = new Object[0];
}
return result[0];
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java
index b1dcb211d..d1a93b04d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileEditorInput.java
@@ -5,11 +5,8 @@ package org.eclipse.team.internal.ccvs.ui;
* All Rights Reserved.
*/
-import java.io.InputStream;
-
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
@@ -77,20 +74,6 @@ public class RemoteFileEditorInput implements IWorkbenchAdapter, IStorageEditorI
return new Object[0];
}
/**
- * Returns an open input stream on the contents of this file.
- * The client is responsible for closing the stream when finished.
- *
- * @return an input stream containing the contents of the file
- * @exception CoreException if this method fails.
- */
- public InputStream getContents() throws CoreException {
- try {
- return file.getContents(new NullProgressMonitor());
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
- }
- }
- /**
* Returns the content type of the input. For instance, if the input
* wraps an <code>IFile</code> the content type would be derived from
* the extension or mime type. If the input wraps another object it
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileStorage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileStorage.java
index 731b7a899..a3f7a3860 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileStorage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteFileStorage.java
@@ -5,14 +5,19 @@ package org.eclipse.team.internal.ccvs.ui;
* All Rights Reserved.
*/
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
@@ -21,12 +26,37 @@ public class RemoteFileStorage extends PlatformObject implements IStorage {
public RemoteFileStorage(ICVSRemoteFile file) {
this.file = file;
}
+
+ /**
+ * Returns an open input stream on the contents of this file.
+ * The client is responsible for closing the stream when finished.
+ *
+ * @return an input stream containing the contents of the file
+ * @exception CoreException if this method fails.
+ */
public InputStream getContents() throws CoreException {
try {
- return file.getContents(new NullProgressMonitor());
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
+ final InputStream[] holder = new InputStream[1];
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ holder[0] = file.getContents(monitor);
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ return holder[0];
+ } catch (InterruptedException e) {
+ // operation canceled
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ throw new CoreException(((TeamException) t).getStatus());
+ }
+ // should not get here
}
+ return new ByteArrayInputStream(new byte[0]);
}
public IPath getFullPath() {
return new Path(file.getName());
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java
index 1dd9745f0..2f2ccd625 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java
@@ -125,11 +125,12 @@ public class RepositoryManager {
* Fetches tags from .project and .vcm_meta if they exist. Then fetches tags from the user defined auto-refresh file
* list. The fetched tags are cached in the CVS ui plugin's tag cache.
*/
- public void refreshDefinedTags(ICVSFolder project, boolean notify) throws TeamException {
+ public void refreshDefinedTags(ICVSFolder project, boolean notify, IProgressMonitor monitor) throws TeamException {
+ List filesToRefresh = new ArrayList(Arrays.asList(getAutoRefreshFiles(project)));
+ monitor.beginTask(Policy.bind("RepositoryManager.refreshDefinedTags"), filesToRefresh.size() * 10); //$NON-NLS-1$
try {
ICVSRepositoryLocation location = CVSProvider.getInstance().getRepository(project.getFolderSyncInfo().getRoot());
List tags = new ArrayList();
- List filesToRefresh = new ArrayList(Arrays.asList(getAutoRefreshFiles(project)));
filesToRefresh.add(".project"); //$NON-NLS-1$
filesToRefresh.add(".vcm_meta"); //$NON-NLS-1$
for (Iterator it = filesToRefresh.iterator(); it.hasNext();) {
@@ -138,7 +139,7 @@ public class RepositoryManager {
if (project instanceof ICVSRemoteFolder) {
// There should be a better way of doing this.
ICVSRemoteFolder parentFolder = location.getRemoteFolder(new Path(project.getName()).append(relativePath).removeLastSegments(1).toString(), CVSTag.DEFAULT);
- ICVSResource[] resources = parentFolder.fetchChildren(null);
+ ICVSResource[] resources = parentFolder.fetchChildren(Policy.subMonitorFor(monitor, 5));
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof ICVSRemoteFile && resources[i].getName().equals(new Path(relativePath).lastSegment())) {
file = (ICVSFile)resources[i];
@@ -148,7 +149,10 @@ public class RepositoryManager {
file = project.getFile(relativePath);
}
if (file != null) {
- tags.addAll(Arrays.asList(fetchDefinedTagsFor(file, project, location)));
+ tags.addAll(Arrays.asList(fetchDefinedTagsFor(file, project, location,
+ Policy.subMonitorFor(monitor, 5))));
+ } else {
+ monitor.worked(5);
}
}
// add all tags in one pass so that the listeners only get one notification for
@@ -174,6 +178,8 @@ public class RepositoryManager {
notifyRepoView = true;
} catch (CVSException e) {
throw new TeamException(e.getStatus());
+ } finally {
+ monitor.done();
}
}
@@ -747,9 +753,10 @@ public class RepositoryManager {
/*
* Fetches and caches the tags found on the provided remote file.
*/
- private CVSTag[] fetchDefinedTagsFor(ICVSFile file, ICVSFolder project, ICVSRepositoryLocation location) throws TeamException {
+ private CVSTag[] fetchDefinedTagsFor(ICVSFile file, ICVSFolder project,
+ ICVSRepositoryLocation location, IProgressMonitor monitor) throws TeamException {
if (file != null && file.exists()) {
- return getTags(file, null);
+ return getTags(file, monitor);
}
return new CVSTag[0];
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java
index de6c3849e..5dcc2e5fb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java
@@ -5,19 +5,18 @@ package org.eclipse.team.internal.ccvs.ui;
* All Rights Reserved.
*/
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.BufferedContent;
import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
@@ -25,7 +24,7 @@ import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
/**
* A class for comparing ICVSRemoteResource objects
*/
-public class ResourceEditionNode extends BufferedContent implements IStructureComparator, ITypedElement {
+public class ResourceEditionNode implements IStructureComparator, ITypedElement, IStreamContentAccessor {
private ICVSRemoteResource resource;
private ResourceEditionNode[] children;
@@ -37,20 +36,6 @@ public class ResourceEditionNode extends BufferedContent implements IStructureCo
}
/**
- * @see BufferedContent#createStream
- */
- public InputStream createStream() throws CoreException {
- if (resource == null) {
- return null;
- }
- try {
- return resource.getContents(new NullProgressMonitor());
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
- }
- }
-
- /**
* Returns true if both resources names are identical.
* The content is not considered.
* @see IComparator#equals
@@ -68,17 +53,29 @@ public class ResourceEditionNode extends BufferedContent implements IStructureCo
*/
public Object[] getChildren() {
if (children == null) {
- if (resource == null) {
- children = new ResourceEditionNode[0];
- } else {
+ children = new ResourceEditionNode[0];
+ if (resource != null) {
try {
- IRemoteResource[] members = resource.members(new NullProgressMonitor());
- children = new ResourceEditionNode[members.length];
- for (int i = 0; i < members.length; i++) {
- children[i] = new ResourceEditionNode((ICVSRemoteResource)members[i]);
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ IRemoteResource[] members = resource.members(monitor);
+ children = new ResourceEditionNode[members.length];
+ for (int i = 0; i < members.length; i++) {
+ children[i] = new ResourceEditionNode((ICVSRemoteResource)members[i]);
+ }
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ // operation canceled
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ CVSUIPlugin.log(((TeamException) t).getStatus());
}
- } catch (TeamException e) {
- CVSUIPlugin.log(e.getStatus());
}
}
}
@@ -92,32 +89,28 @@ public class ResourceEditionNode extends BufferedContent implements IStructureCo
if (resource == null) {
return null;
}
- //show busy cursor if this is happening in the UI thread
- Display display = Display.getCurrent();
- if (display != null) {
- final InputStream[] stream = new InputStream[1];
- final TeamException[] exception = new TeamException[1];
- BusyIndicator.showWhile(display, new Runnable() {
- public void run() {
+ try {
+ final InputStream[] holder = new InputStream[1];
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- stream[0] = resource.getContents(new NullProgressMonitor());
+ holder[0] = resource.getContents(monitor);
} catch (TeamException e) {
- exception[0] = e;
+ throw new InvocationTargetException(e);
}
}
});
- if (exception[0] != null) {
- throw new CoreException(exception[0].getStatus());
- }
- return stream[0];
- } else {
- //we're not in the UI thread, just get the contents.
- try {
- return resource.getContents(new NullProgressMonitor());
- } catch (TeamException e) {
- throw new CoreException(e.getStatus());
+ return holder[0];
+ } catch (InterruptedException e) {
+ // operation canceled
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ throw new CoreException(((TeamException) t).getStatus());
}
+ // should not get here
}
+ return new ByteArrayInputStream(new byte[0]);
}
public Image getImage() {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java
index 2be3a5e4f..2faf92d93 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java
@@ -10,6 +10,7 @@
******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -19,11 +20,11 @@ import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -34,7 +35,6 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
@@ -44,7 +44,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
@@ -386,25 +385,32 @@ public class TagConfigurationDialog extends Dialog {
private void updateShownTags() {
final CVSFileElement[] filesSelection = getSelectedFiles();
- final CVSTag[][] elements = new CVSTag[1][];
+ final Set tags = new HashSet();
if(filesSelection.length!=0) {
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- try {
- Set tags = new HashSet();
- for (int i = 0; i < filesSelection.length; i++) {
- ICVSFile file = filesSelection[i].getCVSFile();
- tags.addAll(Arrays.asList(getTagsFor(file, new NullProgressMonitor())));
+ try {
+ CVSUIPlugin.runWithProgress(getShell(), true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(Policy.bind("Updating tags"), filesSelection.length);
+ try {
+ for (int i = 0; i < filesSelection.length; i++) {
+ ICVSFile file = filesSelection[i].getCVSFile();
+ tags.addAll(Arrays.asList(getTagsFor(file, Policy.subMonitorFor(monitor, 1))));
+ }
+ } catch (TeamException e) {
+ // ignore the exception
+ } finally {
+ monitor.done();
}
- elements[0] = (CVSTag[]) tags.toArray(new CVSTag[tags.size()]);
- } catch (TeamException e) {
}
- }
- });
+ });
+ } catch (InterruptedException e) {
+ // operation cancelled
+ } catch (InvocationTargetException e) {
+ // can't happen since we're ignoring all possible exceptions
+ }
cvsTagTree.getTable().removeAll();
-
- for (int i = 0; i < elements[0].length; i++) {
- CVSTag tag = elements[0][i];
+ for (Iterator it = tags.iterator(); it.hasNext();) {
+ CVSTag tag = (CVSTag) it.next();
List knownTags = new ArrayList();
knownTags.addAll(Arrays.asList(cvsDefinedTagsRootElement.getBranches().getTags()));
knownTags.addAll(Arrays.asList(cvsDefinedTagsRootElement.getVersions().getTags()));
@@ -594,16 +600,26 @@ public class TagConfigurationDialog extends Dialog {
updateToolTipHelpForRefreshButton(refreshButton, project);
refreshButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
- BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
- public void run() {
- try {
- CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(CVSWorkspaceRoot.getCVSFolderFor((project)), true);
- runnable.run();
- } catch(TeamException e) {
- ErrorDialog.openError(shell, Policy.bind("TagConfigurationDialog.14"), e.getMessage(), e.getStatus()); //$NON-NLS-1$
+ try {
+ CVSUIPlugin.runWithProgress(shell, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(
+ CVSWorkspaceRoot.getCVSFolderFor((project)), true, monitor);
+ runnable.run();
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
}
+ });
+ } catch (InterruptedException e) {
+ // operation cancelled
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ ErrorDialog.openError(shell, Policy.bind("TagConfigurationDialog.14"), t.getMessage(), ((TeamException) t).getStatus()); //$NON-NLS-1$
}
- });
+ }
}
});
return refreshButton;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java
index 54b76176c..a05d37a43 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java
@@ -129,13 +129,17 @@ public class TagSelectionDialog extends Dialog {
tagTree.setInput(new ProjectElement(CVSWorkspaceRoot.getCVSFolderFor(projects[0]), true /*show HEAD tag*/));
Runnable refresh = new Runnable() {
public void run() {
- tagTree.refresh();
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ tagTree.refresh();
+ }
+ });
}
};
TagConfigurationDialog.createTagDefinitionButtons(getShell(), top, projects,
- convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT),
- convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
- refresh, refresh);
+ convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT),
+ convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
+ refresh, refresh);
Label seperator = new Label(top, SWT.SEPARATOR | SWT.HORIZONTAL);
data = new GridData (GridData.FILL_BOTH);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java
new file mode 100644
index 000000000..99a5cbf90
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TimeoutProgressMonitorDialog.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.ModalContext;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class TimeoutProgressMonitorDialog extends ProgressMonitorDialog {
+ // the timeout
+ private int timeout;
+ // the number of currently running runnables.
+ private int runningRunnables = 0;
+
+ /**
+ * Creates a progress monitor dialog under the given shell.
+ * The dialog has a standard title and no image.
+ * <code>open</code> is non-blocking.
+ *
+ * @param parent the parent shell
+ * @param timeout the delay after which the dialog will be opened during a run()
+ */
+ public TimeoutProgressMonitorDialog(Shell parent, int timeout) {
+ super(parent);
+ this.timeout = timeout;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IRunnableContext.
+ * Runs the given <code>IRunnableWithProgress</code> with the progress monitor for this
+ * progress dialog. The dialog is opened before it is run, and closed after it completes.
+ */
+ public void run(final boolean fork, boolean cancelable, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
+ setCancelable(cancelable);
+ create(); // create the Shell but don't open it yet
+ try {
+ runningRunnables++;
+ final Display display = getShell().getDisplay();
+ display.timerExec(timeout, new Runnable() {
+ public void run() {
+ Shell shell = getShell();
+ if (shell != null && ! shell.isDisposed()) open();
+ }
+ });
+
+ final Exception[] holder = new Exception[1];
+ BusyIndicator.showWhile(display, new Runnable() {
+ public void run() {
+ try {
+ ModalContext.run(runnable, fork, getProgressMonitor(), display);
+ } catch (InvocationTargetException ite) {
+ holder[0] = ite;
+ } catch (InterruptedException ie) {
+ holder[0] = ie;
+ }
+ }
+ });
+ if (holder[0] != null) {
+ if (holder[0] instanceof InvocationTargetException) {
+ throw (InvocationTargetException) holder[0];
+ } else if (holder[0] instanceof InterruptedException) {
+ throw (InterruptedException) holder[0];
+ }
+ }
+ } finally {
+ runningRunnables--;
+ close();
+ }
+ }
+
+ public boolean close() {
+ if (runningRunnables <= 0) return super.close();
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java
index fdade93b9..b80a9e59d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java
@@ -103,13 +103,21 @@ public class MergeWizardStartPage extends CVSWizardPage {
Runnable afterRefresh = new Runnable() {
public void run() {
- table.refresh();
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ table.refresh();
+ }
+ });
}
};
Runnable afterConfigure = new Runnable() {
public void run() {
- initialize();
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ initialize();
+ }
+ });
}
};
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 49877be30..9d89539d7 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
@@ -392,7 +392,7 @@ RepositoriesView.refresh=&Refresh View
RepositoriesView.new=&CVS Repository Location...
RepositoriesView.newSubmenu=&New
RepositoriesView.Show_Folders_6=Show Folders
-RepositoriesView.Show_Modules_7=Show Modules
+RepositoriewView.Show_Modules_7=Show Modules
ResourcePropertiesPage.status=Status
ResourcePropertiesPage.notManaged=Not managed by CVS
@@ -666,8 +666,12 @@ BranchCategory.Branches_1=Branches
GroupedByVersionCategory.Versions_1=Versions
VersionCategory.Versions_1=Versions
HistoryView.[...]_4=[...]
+
+RepositoryManager.refreshDefinedTags=Refreshing defined tags
+
CVSProjectPropertiesPage.Select_a_Repository_1=Select a Repository
CVSProjectPropertiesPage.Select_a_CVS_repository_location_to_share_the_project_with__2=Select a CVS repository location to share the project with:
CVSProjectPropertiesPage.Change_Sharing_5=Change Sharing
CVSRepositoryPropertiesPage.Confirm_Project_Sharing_Changes_1=Confirm Project Sharing Changes
CVSRepositoryPropertiesPage.There_are_projects_in_the_workspace_shared_with_this_repository._The_projects_will_be_updated_with_the_new_information_that_you_have_entered_2=There are projects in the workspace shared with this repository. The projects will be updated with the new information that you have entered
+
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchTag.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchTag.java
index 2e39550dc..d9290538a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchTag.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/BranchTag.java
@@ -5,12 +5,13 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
@@ -54,16 +55,22 @@ public class BranchTag extends CVSModelElement implements IAdaptable {
public Object[] getChildren(Object o) {
// Return the remote elements for the tag
final Object[][] result = new Object[1][];
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- try {
- IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
- result[0] = root.members(tag, store.getBoolean(ICVSUIConstants.PREF_SHOW_MODULES), new NullProgressMonitor());
- } catch (TeamException e) {
- handle(e);
+ try {
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
+ result[0] = root.members(tag, store.getBoolean(ICVSUIConstants.PREF_SHOW_MODULES), monitor);
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
}
- }
- });
+ });
+ } catch (InterruptedException e) {
+ return new Object[0];
+ } catch (InvocationTargetException e) {
+ handle(e.getTargetException());
+ }
return result[0];
}
public ImageDescriptor getImageDescriptor(Object object) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSFolderElement.java
index ca732cca3..6ba3cb64a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSFolderElement.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSFolderElement.java
@@ -5,16 +5,16 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
-import java.util.ArrayList;
-import java.util.List;
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -33,25 +33,31 @@ public class CVSFolderElement extends CVSResourceElement {
*/
public Object[] getChildren(final Object o) {
final Object[][] result = new Object[1][];
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- try {
- ICVSResource[] children = folder.fetchChildren(null);
- CVSResourceElement[] elements = new CVSResourceElement[children.length];
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- if(resource.isFolder()) {
- elements[i] = new CVSFolderElement((ICVSFolder)resource, includeUnmanaged);
- } else {
- elements[i] = new CVSFileElement((ICVSFile)resource);
+ try {
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ ICVSResource[] children = folder.fetchChildren(monitor);
+ CVSResourceElement[] elements = new CVSResourceElement[children.length];
+ for (int i = 0; i < children.length; i++) {
+ ICVSResource resource = children[i];
+ if(resource.isFolder()) {
+ elements[i] = new CVSFolderElement((ICVSFolder)resource, includeUnmanaged);
+ } else {
+ elements[i] = new CVSFileElement((ICVSFile)resource);
+ }
}
+ result[0] = elements;
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
}
- result[0] = elements;
- } catch (TeamException e) {
- handle(e);
}
- }
- });
+ });
+ } catch (InterruptedException e) {
+ return new Object[0];
+ } catch (InvocationTargetException e) {
+ handle(e.getTargetException());
+ }
return result[0];
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java
index e40164c5a..ce2a98741 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java
@@ -5,11 +5,11 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ILogEntry;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
@@ -126,21 +126,26 @@ public class CVSRemoteFilePropertySource implements IPropertySource {
}
private void initialize() {
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- try {
- ILogEntry[] entries = file.getLogEntries(new NullProgressMonitor());
- String revision = file.getRevision();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getRevision().equals(revision)) {
- entry = entries[i];
- return;
+ try {
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ ILogEntry[] entries = file.getLogEntries(monitor);
+ String revision = file.getRevision();
+ for (int i = 0; i < entries.length; i++) {
+ if (entries[i].getRevision().equals(revision)) {
+ entry = entries[i];
+ return;
+ }
}
+ } catch (TeamException e) {
+ CVSUIPlugin.log(e.getStatus());
}
- } catch (TeamException e) {
- CVSUIPlugin.log(e.getStatus());
}
- }
- });
+ });
+ } catch (InterruptedException e) { // ignore cancellation
+ } catch (InvocationTargetException e) {
+ // FIXME
+ }
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java
index cca51ec0f..3ece5f021 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java
@@ -5,13 +5,15 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.NullProgressMonitor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -20,15 +22,21 @@ public class RemoteFolderElement extends RemoteResourceElement {
public Object[] getChildren(final Object o) {
if (!(o instanceof ICVSRemoteFolder)) return null;
final Object[][] result = new Object[1][];
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- try {
- result[0] = ((ICVSRemoteFolder)o).members(new NullProgressMonitor());
- } catch (TeamException e) {
- handle(e);
+ try {
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ result[0] = ((ICVSRemoteFolder)o).members(monitor);
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
}
- }
- });
+ });
+ } catch (InterruptedException e) {
+ return new Object[0];
+ } catch (InvocationTargetException e) {
+ handle(e.getTargetException());
+ }
return result[0];
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java
index 783e324a7..987a63c34 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java
@@ -5,11 +5,12 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
@@ -56,22 +57,28 @@ public class RemoteModule extends CVSModelElement implements IAdaptable {
*/
public Object[] getChildren(Object o) {
final Object[][] result = new Object[1][];
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- try {
- manager.refreshDefinedTags(folder, false);
- } catch(TeamException e) {
- // continue
- }
- CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownVersionTags(folder);
- Object[] versions = new Object[tags.length];
- for (int i = 0; i < versions.length; i++) {
- versions[i] = folder.getRepository().getRemoteFolder(folder.getRepositoryRelativePath(), tags[i]);
+ try {
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ try {
+ manager.refreshDefinedTags(folder, false, monitor);
+ } catch(TeamException e) {
+ // continue
+ }
+ CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownVersionTags(folder);
+ Object[] versions = new Object[tags.length];
+ for (int i = 0; i < versions.length; i++) {
+ versions[i] = folder.getRepository().getRemoteFolder(folder.getRepositoryRelativePath(), tags[i]);
+ }
+ result[0] = versions;
}
- result[0] = versions;
- }
- });
+ });
+ } catch (InterruptedException e) {
+ return new Object[0];
+ } catch (InvocationTargetException e) {
+ handle(e.getTargetException());
+ }
return result[0];
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java
index 114ce238a..d24419aac 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java
@@ -5,12 +5,13 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
@@ -50,21 +51,28 @@ public class VersionCategory extends CVSModelElement implements IAdaptable {
*/
public Object[] getChildren(Object o) {
final Object[][] result = new Object[1][];
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- public void run() {
- try {
- IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
- ICVSRemoteResource[] resources = repository.members(CVSTag.DEFAULT, store.getBoolean(ICVSUIConstants.PREF_SHOW_MODULES), new NullProgressMonitor());
- Object[] modules = new Object[resources.length];
- for (int i = 0; i < resources.length; i++) {
- modules[i] = new RemoteModule((ICVSRemoteFolder)resources[i], VersionCategory.this);
+ try {
+ CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
+ ICVSRemoteResource[] resources = repository.members(CVSTag.DEFAULT,
+ store.getBoolean(ICVSUIConstants.PREF_SHOW_MODULES), monitor);
+ Object[] modules = new Object[resources.length];
+ for (int i = 0; i < resources.length; i++) {
+ modules[i] = new RemoteModule((ICVSRemoteFolder)resources[i], VersionCategory.this);
+ }
+ result[0] = modules;
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
}
- result[0] = modules;
- } catch (TeamException e) {
- handle(e);
}
- }
- });
+ });
+ } catch (InterruptedException e) {
+ return new Object[0];
+ } catch (InvocationTargetException e) {
+ handle(e.getTargetException());
+ }
return result[0];
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
index 1d4c3bb81..e97816119 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
@@ -5,16 +5,18 @@ package org.eclipse.team.internal.ccvs.ui.sync;
* All Rights Reserved.
*/
+import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -29,7 +31,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ILogEntry;
@@ -270,12 +271,30 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
IRemoteResource remote = syncTree.getRemote();
if (remote != null) {
try {
- ICVSRemoteFile remoteFile = (ICVSRemoteFile)remote;
+ final ICVSRemoteFile remoteFile = (ICVSRemoteFile)remote;
String revision = remoteFile.getRevision();
- // XXX Should have real progress
- ILogEntry logEntry = remoteFile.getLogEntry(new NullProgressMonitor());
- String author = logEntry.getAuthor();
- config.setRightLabel(Policy.bind("CVSCatchupReleaseViewer.repositoryFileRevision", new Object[] {name, revision, author})); //$NON-NLS-1$
+ final String[] author = new String[] { "" }; //$NON-NLS-1$
+ try {
+ CVSUIPlugin.runWithProgress(getTree().getShell(), true /*cancelable*/,
+ new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ ILogEntry logEntry = remoteFile.getLogEntry(monitor);
+ author[0] = logEntry.getAuthor();
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch (InterruptedException e) { // ignore cancellation
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ throw (TeamException) t;
+ }
+ // should not get here
+ }
+ config.setRightLabel(Policy.bind("CVSCatchupReleaseViewer.repositoryFileRevision", new Object[] {name, revision, author[0]})); //$NON-NLS-1$
} catch (TeamException e) {
ErrorDialog.openError(getControl().getShell(), null, null, e.getStatus());
config.setRightLabel(Policy.bind("CVSCatchupReleaseViewer.repositoryFile", name)); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
index 226bad6d7..4e1f38051 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
@@ -5,15 +5,16 @@ package org.eclipse.team.internal.ccvs.ui.sync;
* All Rights Reserved.
*/
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
@@ -35,7 +36,8 @@ import org.eclipse.team.ui.sync.TeamFile;
public class CVSSyncCompareInput extends SyncCompareInput {
private boolean dirty = false;
private IResource[] resources;
-
+ TeamFile previousTeamFile = null;
+
/**
* Creates a new catchup or release operation.
*/
@@ -57,43 +59,64 @@ public class CVSSyncCompareInput extends SyncCompareInput {
* @see MouseMoveListener#mouseMove(MouseEvent)
*/
public void mouseMove(MouseEvent e) {
- Tree tree = (Tree)e.widget;
+ final Tree tree = (Tree)e.widget;
TreeItem item = tree.getItem(new Point(e.x, e.y));
+ final TeamFile file;
if (item != null) {
// Hack: this is the only way to get an item from the tree viewer
Object o = item.getData();
if (o instanceof TeamFile) {
- TeamFile file = (TeamFile)o;
- if (file.getChangeDirection() != ITeamNode.OUTGOING) {
- IRemoteSyncElement element = file.getMergeResource().getSyncElement();
- ICVSRemoteFile remoteFile = (ICVSRemoteFile)element.getRemote();
- ILogEntry logEntry;
- if (remoteFile != null) {
- try {
- // XXX Should have real progress here
- logEntry = remoteFile.getLogEntry(new NullProgressMonitor());
- } catch (TeamException ex) {
- tree.setToolTipText(null);
- return;
- }
- if (logEntry != null) {
- String newText = logEntry.getComment();
- String oldText = tree.getToolTipText();
- if (!newText.equals(oldText)) {
- tree.setToolTipText(logEntry.getComment());
- }
- return;
- }
- }
- }
+ file = (TeamFile)o;
+ } else file = null;
+ } else file = null;
+
+ // avoid redundant updates -- identity test is good enough here
+ if (file == previousTeamFile) return;
+ previousTeamFile = file;
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ updateToolTip(tree, file);
}
- }
- tree.setToolTipText(null);
+ });
}
});
return catchupReleaseViewer;
}
-
+
+ protected void updateToolTip(Tree tree, TeamFile file) {
+ String newText = null;
+ if (file != null && file.getChangeDirection() != ITeamNode.OUTGOING) {
+ IRemoteSyncElement element = file.getMergeResource().getSyncElement();
+ final ICVSRemoteFile remoteFile = (ICVSRemoteFile)element.getRemote();
+ final ILogEntry[] logEntry = new ILogEntry[1];
+ if (remoteFile != null) {
+ try {
+ CVSUIPlugin.runWithProgress(getViewer().getTree().getShell(), true /*cancelable*/,
+ new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ logEntry[0] = remoteFile.getLogEntry(monitor);
+ } catch (TeamException ex) {
+ throw new InvocationTargetException(ex);
+ }
+ }
+ });
+ } catch (InterruptedException ex) {
+ // ignore cancellation
+ } catch (InvocationTargetException ex) {
+ // ignore the exception
+ }
+ }
+ if (logEntry[0] != null) {
+ newText = logEntry[0].getComment();
+ }
+ }
+ if (tree.isDisposed()) return;
+ String oldText = tree.getToolTipText();
+ if (newText == oldText || newText != null && newText.equals(oldText)) return;
+ tree.setToolTipText(newText);
+ }
+
protected IRemoteSyncElement[] createSyncElements(IProgressMonitor monitor) throws TeamException {
IRemoteSyncElement[] trees = new IRemoteSyncElement[resources.length];
int work = 1000 * resources.length;

Back to the top