Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2016-02-26 15:27:12 +0000
committerMatthias Sohn2016-02-27 22:42:57 +0000
commit5121953b8bdd3adb554dd0bd67d55386e28053c6 (patch)
tree368bd484cb40ce83177c08382cae410435a0d461 /org.eclipse.egit.ui
parent5ea979ec26dbdd4165d564aadb77081adbcc4f25 (diff)
downloadegit-5121953b8bdd3adb554dd0bd67d55386e28053c6.tar.gz
egit-5121953b8bdd3adb554dd0bd67d55386e28053c6.tar.xz
egit-5121953b8bdd3adb554dd0bd67d55386e28053c6.zip
[staging view] Fixed sort order: added check for "names first" case
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java41
1 files changed, 31 insertions, 10 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 134be42932..ff669a8f57 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -703,8 +703,9 @@ public class StagingView extends ViewPart implements IShowInSource {
compareWith(event);
}
});
- unstagedViewer
- .setComparator(new UnstagedComparator(getSortCheckState()));
+ unstagedViewer.setComparator(
+ new UnstagedComparator(getSortCheckState(), getPreferenceStore()
+ .getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
enableAutoExpand(unstagedViewer);
addListenerToDisableAutoExpandOnCollapse(unstagedViewer);
@@ -1679,9 +1680,12 @@ public class StagingView extends ViewPart implements IShowInSource {
getLabelProvider(unstagedViewer).setFileNameMode(enable);
getContentProvider(stagedViewer).setFileNameMode(enable);
getContentProvider(unstagedViewer).setFileNameMode(enable);
- refreshViewersPreservingExpandedElements();
+ UnstagedComparator comparator = (UnstagedComparator) unstagedViewer
+ .getComparator();
+ comparator.setFileNamesFirst(enable);
getPreferenceStore().setValue(
UIPreferences.STAGING_VIEW_FILENAME_MODE, enable);
+ refreshViewersPreservingExpandedElements();
}
};
fileNameModeAction.setChecked(getPreferenceStore().getBoolean(
@@ -3322,11 +3326,23 @@ public class StagingView extends ViewPart implements IShowInSource {
private Comparator<String> comparator;
- private UnstagedComparator(boolean alphabeticSort) {
+ private boolean fileNamesFirst;
+
+ private UnstagedComparator(boolean alphabeticSort,
+ boolean fileNamesFirst) {
this.alphabeticSort = alphabeticSort;
+ this.setFileNamesFirst(fileNamesFirst);
comparator = CommonUtils.STRING_ASCENDING_COMPARATOR;
}
+ public boolean isFileNamesFirst() {
+ return fileNamesFirst;
+ }
+
+ public void setFileNamesFirst(boolean fileNamesFirst) {
+ this.fileNamesFirst = fileNamesFirst;
+ }
+
private void setAlphabeticSort(boolean sort) {
this.alphabeticSort = sort;
}
@@ -3355,19 +3371,23 @@ public class StagingView extends ViewPart implements IShowInSource {
return cat1 - cat2;
}
- String name1 = getStagingEntryName(e1);
- String name2 = getStagingEntryName(e2);
+ String name1 = getStagingEntryText(e1);
+ String name2 = getStagingEntryText(e2);
return comparator.compare(name1, name2);
}
- private String getStagingEntryName(Object element) {
- String name = ""; //$NON-NLS-1$
+ private String getStagingEntryText(Object element) {
+ String text = ""; //$NON-NLS-1$
StagingEntry stagingEntry = getStagingEntry(element);
if (stagingEntry != null) {
- name = stagingEntry.getName();
+ if (isFileNamesFirst()) {
+ text = stagingEntry.getName();
+ } else {
+ text = stagingEntry.getPath();
+ }
}
- return name;
+ return text;
}
@Nullable
@@ -3397,5 +3417,6 @@ public class StagingView extends ViewPart implements IShowInSource {
return super.category(entry);
}
}
+
}
}

Back to the top