Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-05-12 18:47:34 +0000
committerJean Michel-Lemieux2004-05-12 18:47:34 +0000
commit0982eb5a4011ff0fe6c027173dde856c44a0eefb (patch)
tree833ad8fddb5571710a9d20b32424f7dd2b058c3a
parent37fc2a0eb31f23f439fea7f217c94bc664417cdf (diff)
downloadeclipse.platform.team-0982eb5a4011ff0fe6c027173dde856c44a0eefb.tar.gz
eclipse.platform.team-0982eb5a4011ff0fe6c027173dde856c44a0eefb.tar.xz
eclipse.platform.team-0982eb5a4011ff0fe6c027173dde856c44a0eefb.zip
change log sorting supported.
-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/subscriber/ChangeLogDiffNode.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java76
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelSorter.java75
4 files changed, 143 insertions, 17 deletions
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 fff22b012..55c865d93 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
@@ -999,6 +999,12 @@ CheckoutIntoWizard.title=Checkout Into
CheckoutIntoWizard.projectSelectionPageTitle=Select local folder
CheckoutIntoWizard.projectSelectionPageDescription=Select the local folder that is the target of the checkout operation.
CheckoutIntoWizard.error=Checkout Error
+ChangeLogModelProvider.0=Sort By
+ChangeLogModelProvider.1=Comment
+ChangeLogModelProvider.2=Date
+ChangeLogModelProvider.3=User
+ChangeLogModelProvider.4=Retrieving revision histories
+ChangeLogModelProvider.5=Grouped By Comment (useful for browsing incoming changes)
CheckoutIntoWizard.thisResourceExists=The resource ''{0}'' already exists in the workspace. Overwrite?
CheckoutIntoWizard.confirmOverwrite=Confirm Overwrite
CheckoutIntoWizard.mappingAlreadyExists=Cannot add remote folder ''{0}'' to project ''{1}'' as ''{2}'' because local folder ''{3}'' is already mapped to that folder.
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 3e2de95e3..3ebd5fa06 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,8 @@ public class ChangeLogDiffNode extends SynchronizeModelElement {
*/
public String getName() {
String date = DateFormat.getDateTimeInstance().format(logEntry.getDate());
- return logEntry.getComment() + " (" + logEntry.getAuthor() + " on "+ date +")";
+ //return logEntry.getComment() + " (" + logEntry.getAuthor() + " on "+ date +")";
+ return "["+logEntry.getAuthor()+"] " +logEntry.getComment() + " (" + date +")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
/* (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 055d9aca9..f0cb900ce 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
@@ -17,6 +17,8 @@ import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.*;
import org.eclipse.team.core.synchronize.*;
@@ -24,8 +26,8 @@ import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
+import org.eclipse.team.internal.ccvs.ui.*;
+import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
@@ -52,6 +54,61 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
private Map commentRoots = new HashMap();
private boolean shutdown = false;
private FetchLogEntriesJob fetchLogEntriesJob;
+ private ChangeLogActionGroup sortGroup;
+ private final static String SORT_ORDER_GROUP = "changelog_sort"; //$NON-NLS-1$
+
+ /**
+ * Action that allows changing the model providers sort order.
+ */
+ private class ToggleModelProviderAction extends Action {
+ private int criteria;
+ protected ToggleModelProviderAction(String name, int criteria) {
+ super(name, Action.AS_RADIO_BUTTON);
+ this.criteria = criteria;
+ update();
+ }
+
+ public void run() {
+ StructuredViewer viewer = getViewer();
+ if (viewer != null && !viewer.getControl().isDisposed()) {
+ ChangeLogModelSorter sorter = (ChangeLogModelSorter) viewer.getSorter();
+ if (sorter != null && sorter.getCriteria() != criteria) {
+ viewer.setSorter(new ChangeLogModelSorter(criteria));
+ update();
+ }
+ }
+ }
+
+ public void update() {
+ StructuredViewer viewer = getViewer();
+ if (viewer != null && !viewer.getControl().isDisposed()) {
+ ChangeLogModelSorter sorter = (ChangeLogModelSorter) viewer.getSorter();
+ if (sorter != null) {
+ setChecked(sorter.getCriteria() == criteria);
+ }
+ }
+ }
+ }
+
+ /**
+ * Actions for the compare particpant's toolbar
+ */
+ public class ChangeLogActionGroup extends SynchronizePageActionGroup {
+ public void initialize(ISynchronizePageConfiguration configuration) {
+ super.initialize(configuration);
+ MenuManager sortBy = new MenuManager(Policy.bind("ChangeLogModelProvider.0")); //$NON-NLS-1$
+ appendToGroup(
+ ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ SORT_ORDER_GROUP,
+ sortBy);
+
+ sortBy.add(new ToggleModelProviderAction(Policy.bind("ChangeLogModelProvider.1"), ChangeLogModelSorter.COMMENT)); //$NON-NLS-1$
+ sortBy.add(new ToggleModelProviderAction(Policy.bind("ChangeLogModelProvider.2"), ChangeLogModelSorter.DATE)); //$NON-NLS-1$
+ Action a = new ToggleModelProviderAction(Policy.bind("ChangeLogModelProvider.3"), ChangeLogModelSorter.USER); //$NON-NLS-1$
+ a.setChecked(true);
+ sortBy.add(a);
+ }
+ }
public static class DateComment {
Date date;
@@ -95,14 +152,15 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
super(parent, info);
}
public String getName() {
- return getResource().getFullPath().toString();
+ IResource resource = getResource();
+ return resource.getName() + " - " + resource.getFullPath().toString(); //$NON-NLS-1$
}
}
private class FetchLogEntriesJob extends Job {
private Set syncSets = new HashSet();
public FetchLogEntriesJob() {
- super("Retrieving revision histories"); //$NON-NLS-1$;
+ super(Policy.bind("ChangeLogModelProvider.4")); //$NON-NLS-1$
setUser(true);
}
public boolean belongsTo(Object family) {
@@ -149,12 +207,12 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
};
public static class ChangeLogModelProviderDescriptor implements ISynchronizeModelProviderDescriptor {
- public static final String ID = TeamUIPlugin.ID + ".modelprovider_cvs_changelog";
+ public static final String ID = TeamUIPlugin.ID + ".modelprovider_cvs_changelog"; //$NON-NLS-1$
public String getId() {
return ID;
}
public String getName() {
- return "Grouped By Comment (useful for browsing incoming changes)";
+ return Policy.bind("ChangeLogModelProvider.5"); //$NON-NLS-1$
}
public ImageDescriptor getImageDescriptor() {
return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATE);
@@ -164,6 +222,9 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
public ChangeLogModelProvider(ISynchronizePageConfiguration configuration, SyncInfoSet set) {
super(configuration, set);
+ configuration.addMenuGroup(ISynchronizePageConfiguration.P_CONTEXT_MENU, SORT_ORDER_GROUP);
+ this.sortGroup = new ChangeLogActionGroup();
+ configuration.addActionContribution(sortGroup);
}
/* (non-Javadoc)
@@ -314,6 +375,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
if(fetchLogEntriesJob != null && fetchLogEntriesJob.getState() != Job.NONE) {
fetchLogEntriesJob.cancel();
}
+ getConfiguration().removeActionContribution(sortGroup);
super.dispose();
}
@@ -321,7 +383,7 @@ public class ChangeLogModelProvider extends SynchronizeModelProvider {
* @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelProvider#getViewerSorter()
*/
public ViewerSorter getViewerSorter() {
- return new ChangeLogModelSorter();
+ return new ChangeLogModelSorter(ChangeLogModelSorter.USER);
}
/* (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
index 826f54005..19d08f257 100644
--- 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
@@ -10,7 +10,11 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.subscriber;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.team.internal.ccvs.core.ILogEntry;
+import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
+import org.eclipse.ui.views.navigator.ResourceSorter;
/**
* Sorter for the change log model provider.
@@ -19,18 +23,71 @@ import org.eclipse.jface.viewers.ViewerSorter;
*/
public class ChangeLogModelSorter extends ViewerSorter {
- private final int CHANGE_LOG = 0;
- private final int FILE = 1;
+ private int criteria;
+
+ public final static int DATE = 1;
+ public final static int COMMENT = 2;
+ public final static int USER = 3;
+ private ResourceSorter resourceSorter;
+
+ public ChangeLogModelSorter(int criteria) {
+ super();
+ this.criteria = criteria;
+ this.resourceSorter = new ResourceSorter(ResourceSorter.NAME);
+ }
+
+ protected int classComparison(Object element) {
+ if (element instanceof ChangeLogDiffNode) {
+ return 0;
+ }
+ return 1;
+ }
+
+ protected int compareClass(Object element1, Object element2) {
+ return classComparison(element1) - classComparison(element2);
+ }
+
+ protected int compareNames(String s1, String s2) {
+ return collator.compare(s1, s2);
+ }
/* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
+ * Method declared on ViewerSorter.
*/
- public int category(Object element) {
- if(element instanceof ChangeLogDiffNode) {
- return CHANGE_LOG;
- } else if(element instanceof ChangeLogModelProvider.FullPathSyncInfoElement) {
- return FILE;
+ public int compare(Viewer viewer, Object o1, Object o2) {
+ //have to deal with non-resources in navigator
+ //if one or both objects are not resources, returned a comparison
+ //based on class.
+ if (o1 instanceof ChangeLogDiffNode && o2 instanceof ChangeLogDiffNode) {
+ ILogEntry r1 = ((ChangeLogDiffNode) o1).getComment();
+ ILogEntry r2 = ((ChangeLogDiffNode) o2).getComment();
+
+
+ if (criteria == DATE)
+ return r1.getDate().compareTo(r2.getDate());
+ else if (criteria == COMMENT)
+ return compareNames(r1.getComment(), r2.getComment());
+ else if (criteria == USER)
+ return compareNames(r1.getAuthor(), r2.getAuthor());
+ else
+ return 0;
}
- return super.category(element);
+
+ if (o1 instanceof ISynchronizeModelElement && o2 instanceof ISynchronizeModelElement)
+ return resourceSorter.compare(viewer, ((ISynchronizeModelElement)o1).getResource(), ((ISynchronizeModelElement)o2).getResource());
+ else if (o1 instanceof ISynchronizeModelElement)
+ return -1;
+ else if (o2 instanceof ISynchronizeModelElement)
+ return 1;
+
+ return 0;
+ }
+
+ public int getCriteria() {
+ return criteria;
+ }
+
+ public void setCriteria(int criteria) {
+ this.criteria = criteria;
}
}

Back to the top