Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-05-05 14:27:08 -0400
committerJean Michel-Lemieux2004-05-05 14:27:08 -0400
commitf5ab5ab19f3a212828858ec567fa73ad835c8fab (patch)
tree13e8dd4c748e55f3f3f506e9529ffa378d557c23
parentb8f82667902095f851f20e03ac3b07a144c0cf2c (diff)
downloadeclipse.platform.team-f5ab5ab19f3a212828858ec567fa73ad835c8fab.tar.gz
eclipse.platform.team-f5ab5ab19f3a212828858ec567fa73ad835c8fab.tar.xz
eclipse.platform.team-f5ab5ab19f3a212828858ec567fa73ad835c8fab.zip
More work on change log model provider. Still not in a complete working state.
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java54
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelSorter.java36
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java14
4 files changed, 81 insertions, 25 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java
index 0fe4fe0b2..27c4e5498 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogDiffNode.java
@@ -51,7 +51,7 @@ public class ChangeLogDiffNode extends SynchronizeModelElement {
*/
public String getName() {
String date = DateFormat.getDateTimeInstance().format(logEntry.getDate());
- return date + ": " + logEntry.getComment() + " (" + logEntry.getAuthor() +")";
+ return logEntry.getComment() + " (" + logEntry.getAuthor() + " on "+ date +")";
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
index 722a62528..354e1bf10 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
@@ -35,6 +35,8 @@ import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.ui.progress.UIJob;
/**
+ * This is a prototype model provider using *internal* team classes. It is not meant
+ * to be an example or sanctioned use of team. This provider groups changes
* It would be very useful to support showing changes grouped logically
* instead of grouped physically. This could be used for showing incoming
* changes and also for showing the results of comparisons.
@@ -56,6 +58,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
Date date;
String comment;
private String user;
+
DateComment(Date date, String comment, String user) {
this.date = date;
this.comment = comment;
@@ -77,16 +80,14 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
int yearOther = c2.get(Calendar.YEAR);
int dayOther = c2.get(Calendar.DAY_OF_YEAR);
- return year == yearOther && day == dayOther && comment.equals(other.comment) &&
- user.equals(other.user);
+ return comment.equals(other.comment) && user.equals(other.user);
}
-
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return date.hashCode() + comment.hashCode() + user.hashCode();
+ return comment.hashCode() + user.hashCode();
}
}
@@ -102,7 +103,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
private class FetchLogEntriesJob extends Job {
private SyncInfoSet set;
public FetchLogEntriesJob() {
- super("Fetching CVS logs"); //$NON-NLS-1$;
+ super("Retrieving revision histories"); //$NON-NLS-1$;
setUser(true);
}
public void setSyncInfoSet(SyncInfoSet set) {
@@ -114,7 +115,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
public IStatus run(IProgressMonitor monitor) {
if (set != null && !shutdown) {
final ISynchronizeModelElement[] nodes = calculateRoots(getSyncInfoSet(), monitor);
- UIJob updateUI = new UIJob("updating change log viewers") {
+ UIJob updateUI = new UIJob("") { //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
StructuredViewer tree = getViewer();
tree.refresh();
@@ -170,7 +171,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
}
}
fetchLogEntriesJob.setSyncInfoSet(getSyncInfoSet());
- fetchLogEntriesJob.schedule();
+ fetchLogEntriesJob.schedule();
}
return new IDiffElement[0];
}
@@ -180,24 +181,37 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
commentRoots.clear();
SyncInfo[] infos = set.getSyncInfos();
RemoteLogOperation logs = getSyncInfoComment(infos, monitor);
- monitor.beginTask("fetching from server", set.size() * 100);
- for (int i = 0; i < infos.length; i++) {
- if(monitor.isCanceled()) {
- break;
- }
- // TODO: handle outgoing additions that don't have log entries!!
- ILogEntry logEntry = logs.getLogEntry(getRemoteResource((CVSSyncInfo)infos[i]));
- if(logEntry != null) {
+ for (int i = 0; i < infos.length; i++) {
+ ICVSRemoteResource remoteResource = getRemoteResource((CVSSyncInfo)infos[i]);
+ ILogEntry logEntry = logs.getLogEntry(remoteResource);
+ ISynchronizeModelElement element;
+
+ // If the element has a comment then group with common comment
+ if(remoteResource != null) {
DateComment dateComment = new DateComment(logEntry.getDate(), logEntry.getComment(), logEntry.getAuthor());
ChangeLogDiffNode changeRoot = (ChangeLogDiffNode) commentRoots.get(dateComment);
if (changeRoot == null) {
changeRoot = new ChangeLogDiffNode(getModelRoot(), logEntry);
commentRoots.put(dateComment, changeRoot);
+ try {
+ setAllowRefreshViewer(false);
+ addToViewer(changeRoot);
+ } finally {
+ setAllowRefreshViewer(true);
+ }
}
- ISynchronizeModelElement element = new FullPathSyncInfoElement(changeRoot, infos[i]);
- associateDiffNode(element);
+ element = new FullPathSyncInfoElement(changeRoot, infos[i]);
+ } else {
+ // For nodes without comments, simply parent with the root. These will be outgoing
+ // additions.
+ element = new FullPathSyncInfoElement(getModelRoot(), infos[i]);
+ }
+ try {
+ setAllowRefreshViewer(false);
+ addToViewer(element);
+ } finally {
+ setAllowRefreshViewer(true);
}
- monitor.worked(100);
}
return (ChangeLogDiffNode[]) commentRoots.values().toArray(new ChangeLogDiffNode[commentRoots.size()]);
} catch (CVSException e) {
@@ -235,10 +249,8 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
private ICVSRemoteResource getRemoteResource(CVSSyncInfo info) {
try {
ICVSRemoteResource remote = (ICVSRemoteResource) info.getRemote();
- ICVSRemoteResource base = (ICVSRemoteResource) info.getBase();
ICVSRemoteResource local = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(info.getLocal());
- String baseRevision = getRevisionString(base);
String remoteRevision = getRevisionString(remote);
String localRevision = getRevisionString(local);
@@ -282,7 +294,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
* @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#getViewerSorter()
*/
public ViewerSorter getViewerSorter() {
- return new SynchronizeModelElementSorter();
+ return new ChangeLogModelSorter();
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelSorter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelSorter.java
new file mode 100644
index 000000000..826f54005
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelSorter.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.subscriber;
+
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * Sorter for the change log model provider.
+ *
+ * @since 3.0
+ */
+public class ChangeLogModelSorter extends ViewerSorter {
+
+ private final int CHANGE_LOG = 0;
+ private final int FILE = 1;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
+ */
+ public int category(Object element) {
+ if(element instanceof ChangeLogDiffNode) {
+ return CHANGE_LOG;
+ } else if(element instanceof ChangeLogModelProvider.FullPathSyncInfoElement) {
+ return FILE;
+ }
+ return super.category(element);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java
index c298b77e2..29c98a8be 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelProvider.java
@@ -308,7 +308,7 @@ public abstract class SynchronizeModelProvider implements ISyncInfoSetChangeList
protected void reset() {
try {
- refreshViewer = false;
+ setAllowRefreshViewer(false);
// Clear existing model, but keep the root node
resourceMap.clear();
@@ -329,7 +329,7 @@ public abstract class SynchronizeModelProvider implements ISyncInfoSetChangeList
((SynchronizeModelElement)root).fireChanges();
}
} finally {
- refreshViewer = true;
+ setAllowRefreshViewer(true);
}
TeamUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
public void run() {
@@ -423,7 +423,15 @@ public abstract class SynchronizeModelProvider implements ISyncInfoSetChangeList
*/
private boolean canUpdateViewer() {
StructuredViewer viewer = getViewer();
- return refreshViewer && viewer != null && ! viewer.getControl().isDisposed();
+ return getAllowRefreshViewer() && viewer != null && ! viewer.getControl().isDisposed();
+ }
+
+ protected void setAllowRefreshViewer(boolean allowRefresh) {
+ this.refreshViewer = allowRefresh;
+ }
+
+ protected boolean getAllowRefreshViewer() {
+ return this.refreshViewer;
}
/**

Back to the top