summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-14 21:04:09 (EDT)
committer Chris Aniszczyk2011-04-15 11:12:24 (EDT)
commit7e9d5098ab828621d0b9eefb62e930fdbd2ca426 (patch)
tree95aa067defc482c6c638d63873b3002027a2f093
parent23fc43bc827c21cc96b2aca0f242f3de4e1d2a63 (diff)
downloadegit-github-7e9d5098ab828621d0b9eefb62e930fdbd2ca426.zip
egit-github-7e9d5098ab828621d0b9eefb62e930fdbd2ca426.tar.gz
egit-github-7e9d5098ab828621d0b9eefb62e930fdbd2ca426.tar.bz2
Add gist attachment sorterrefs/changes/34/3134/2
Change-Id: If5b7e84daeb60a95a8099947bbf74983776e7b02 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentSorter.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentSorter.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentSorter.java
new file mode 100644
index 0000000..cd93321
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentSorter.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.internal.github.ui.gist;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.mylyn.internal.provisional.commons.ui.TableSorter;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+
+/**
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class GistAttachmentSorter extends TableSorter {
+
+ private TaskKeyComparator keyComparator = new TaskKeyComparator();
+
+ /**
+ * @see org.eclipse.mylyn.internal.provisional.commons.ui.AbstractColumnViewerSorter#compare(org.eclipse.jface.viewers.ColumnViewer,
+ * java.lang.Object, java.lang.Object, int)
+ */
+ public int compare(TableViewer viewer, Object e1, Object e2, int columnIndex) {
+ ITaskAttachment attachment1 = (ITaskAttachment) e1;
+ ITaskAttachment attachment2 = (ITaskAttachment) e2;
+ switch (columnIndex) {
+ case 0:
+ return compare(attachment1.getFileName(), attachment2.getFileName());
+ case 1:
+ return compare(attachment1.getLength(), attachment2.getLength());
+ case 2:
+ return compare(attachment1.getAuthor().toString(), attachment2
+ .getAuthor().toString());
+ default:
+ return super.compare(viewer, e1, e2, columnIndex);
+ }
+ }
+
+}