Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-05-13 15:30:04 -0400
committerThomas Wolf2018-05-13 15:30:04 -0400
commit7fc2a098afdc40110c9606cc8d89c059e56f6f74 (patch)
treea761582ddf313ea7122f83614a86374cdd5f260c /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal
parent71cc0b751951f2532ef89a28de9a9f167d0014dd (diff)
downloadegit-7fc2a098afdc40110c9606cc8d89c059e56f6f74.tar.gz
egit-7fc2a098afdc40110c9606cc8d89c059e56f6f74.tar.xz
egit-7fc2a098afdc40110c9606cc8d89c059e56f6f74.zip
Natural sort for tags in CreateTagDialog
Give the tag viewer a comparator, and change the label provider from an ITableLabelProvider to a simple LabelProvider. The viewer has one column only anyway, and with the previous label provider implementation, the comparer wouldn't work. The viewer would use getColumnText(), but the ViewerComparator would use the inherited getText() from WorkbenchLabelProvider, which always returns the empty string since the elements don't adapt to IWorkbenchAdapter. Bug: 529449 Change-Id: Ib1371f13c80334a9f41246fc96134f3c99198fb4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CreateTagDialog.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CreateTagDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CreateTagDialog.java
index 5d8d9563e..c27d6e946 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CreateTagDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CreateTagDialog.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Comparator;
import java.util.List;
import java.util.regex.Pattern;
@@ -24,6 +25,7 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIUtils;
+import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.CompareUtils;
import org.eclipse.egit.ui.internal.UIIcons;
import org.eclipse.egit.ui.internal.UIText;
@@ -39,11 +41,12 @@ import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.AnyObjectId;
@@ -79,7 +82,6 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
* Dialog for creating and editing tags.
@@ -139,8 +141,7 @@ public class CreateTagDialog extends TitleAreaDialog {
private final RevWalk rw;
- private static class TagLabelProvider extends WorkbenchLabelProvider implements
- ITableLabelProvider {
+ private static class TagLabelProvider extends LabelProvider {
private final Image IMG_TAG;
private final Image IMG_LIGHTTAG;
@@ -151,7 +152,7 @@ public class CreateTagDialog extends TitleAreaDialog {
}
@Override
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getImage(Object element) {
// initially, we just display a single String ("Loading...")
if (element instanceof String)
return null;
@@ -162,7 +163,7 @@ public class CreateTagDialog extends TitleAreaDialog {
}
@Override
- public String getColumnText(Object element, int columnIndex) {
+ public String getText(Object element) {
// initially, we just display a single String ("Loading...")
if (element instanceof String)
return (String) element;
@@ -574,6 +575,12 @@ public class CreateTagDialog extends TitleAreaDialog {
fillTagDialog(event.getSelection());
}
});
+ tagViewer.setComparator(new ViewerComparator() {
+ @Override
+ protected Comparator<? super String> getComparator() {
+ return CommonUtils.STRING_ASCENDING_COMPARATOR;
+ }
+ });
tagViewer.addFilter(new ViewerFilter() {
@Override

Back to the top