Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-02-27 01:07:11 +0000
committerMatthias Sohn2016-02-27 22:42:57 +0000
commit101ddf02ab1668b141848374ec57b9e8bd3ad28a (patch)
treedadf456607acc1c8ace7085c5ef457e8bc5f3ff8
parent5121953b8bdd3adb554dd0bd67d55386e28053c6 (diff)
downloadegit-101ddf02ab1668b141848374ec57b9e8bd3ad28a.tar.gz
egit-101ddf02ab1668b141848374ec57b9e8bd3ad28a.tar.xz
egit-101ddf02ab1668b141848374ec57b9e8bd3ad28a.zip
Fix sorting and grouping of staging entries by state
- group all states, states which require attention more frequently come first - also sort staged changes pane - alphabetic sorting is the natural order and doesn't need explanation, hence name the button to toggle sort order "Sort by state" and use a new icon depicting that - rename the comparator to StagingEntryComparator since it's now used for both unstaged and staged changes Bug: 473919 Change-Id: Ia6c165f252bb293d77251e4b5cf9dfb63c1c5d53 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/icons/obj16/state_sort_co.pngbin0 -> 219 bytes
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java48
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties2
4 files changed, 40 insertions, 14 deletions
diff --git a/org.eclipse.egit.ui/icons/obj16/state_sort_co.png b/org.eclipse.egit.ui/icons/obj16/state_sort_co.png
new file mode 100644
index 0000000000..8748ad15ff
--- /dev/null
+++ b/org.eclipse.egit.ui/icons/obj16/state_sort_co.png
Binary files differ
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
index 8d1902b8f5..c28e53290d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
@@ -313,6 +313,9 @@ public class UIIcons {
/** Sort alphabetically icon */
public final static ImageDescriptor ALPHABETICALLY_SORT;
+ /** Sort by state icon */
+ public final static ImageDescriptor STATE_SORT;
+
/** {@link #BRANCH} overlaid with {@link #OVR_CHECKEDOUT}. */
public final static ImageDescriptor CHECKED_OUT_BRANCH;
@@ -420,6 +423,7 @@ public class UIIcons {
DONE_STEP = map("obj16/done_step.gif"); //$NON-NLS-1$
CURRENT_STEP = map("obj16/current_step.gif"); //$NON-NLS-1$
ALPHABETICALLY_SORT = map("obj16/alphab_sort_co.gif"); //$NON-NLS-1$
+ STATE_SORT = map("obj16/state_sort_co.png"); //$NON-NLS-1$
CHECKED_OUT_BRANCH = new DecorationOverlayDescriptor(BRANCH,
OVR_CHECKEDOUT, IDecoration.TOP_LEFT);
}
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 ff669a8f57..08ddc09462 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
@@ -704,7 +704,7 @@ public class StagingView extends ViewPart implements IShowInSource {
}
});
unstagedViewer.setComparator(
- new UnstagedComparator(getSortCheckState(), getPreferenceStore()
+ new StagingEntryComparator(getSortCheckState(), getPreferenceStore()
.getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
enableAutoExpand(unstagedViewer);
addListenerToDisableAutoExpandOnCollapse(unstagedViewer);
@@ -1010,6 +1010,9 @@ public class StagingView extends ViewPart implements IShowInSource {
compareWith(event);
}
});
+ stagedViewer.setComparator(
+ new StagingEntryComparator(getSortCheckState(), getPreferenceStore()
+ .getBoolean(UIPreferences.STAGING_VIEW_FILENAME_MODE)));
enableAutoExpand(stagedViewer);
addListenerToDisableAutoExpandOnCollapse(stagedViewer);
@@ -1376,14 +1379,17 @@ public class StagingView extends ViewPart implements IShowInSource {
@Override
public void run() {
- UnstagedComparator comparator = (UnstagedComparator) unstagedViewer
+ StagingEntryComparator comparator = (StagingEntryComparator) unstagedViewer
.getComparator();
- comparator.setAlphabeticSort(isChecked());
+ comparator.setAlphabeticSort(!isChecked());
+ comparator = (StagingEntryComparator) stagedViewer.getComparator();
+ comparator.setAlphabeticSort(!isChecked());
unstagedViewer.refresh();
+ stagedViewer.refresh();
}
};
- sortAction.setImageDescriptor(UIIcons.ALPHABETICALLY_SORT);
+ sortAction.setImageDescriptor(UIIcons.STATE_SORT);
sortAction.setId(SORT_ITEM_TOOLBAR_ID);
sortAction.setChecked(getSortCheckState());
@@ -1680,9 +1686,11 @@ public class StagingView extends ViewPart implements IShowInSource {
getLabelProvider(unstagedViewer).setFileNameMode(enable);
getContentProvider(stagedViewer).setFileNameMode(enable);
getContentProvider(unstagedViewer).setFileNameMode(enable);
- UnstagedComparator comparator = (UnstagedComparator) unstagedViewer
+ StagingEntryComparator comparator = (StagingEntryComparator) unstagedViewer
.getComparator();
comparator.setFileNamesFirst(enable);
+ comparator = (StagingEntryComparator) stagedViewer.getComparator();
+ comparator.setFileNamesFirst(enable);
getPreferenceStore().setValue(
UIPreferences.STAGING_VIEW_FILENAME_MODE, enable);
refreshViewersPreservingExpandedElements();
@@ -3316,11 +3324,11 @@ public class StagingView extends ViewPart implements IShowInSource {
}
/**
- * This comparator sorts the {@link StagingEntry}s in a grouped or in a
- * alphabetically order. The grouped order is also in a alphabetically order
- * sorted.
+ * This comparator sorts the {@link StagingEntry}s alphabetically or groups
+ * them by state. If grouped by state the entries in the same group are also
+ * ordered alphabetically.
*/
- private static class UnstagedComparator extends ViewerComparator {
+ private static class StagingEntryComparator extends ViewerComparator {
private boolean alphabeticSort;
@@ -3328,7 +3336,7 @@ public class StagingView extends ViewPart implements IShowInSource {
private boolean fileNamesFirst;
- private UnstagedComparator(boolean alphabeticSort,
+ private StagingEntryComparator(boolean alphabeticSort,
boolean fileNamesFirst) {
this.alphabeticSort = alphabeticSort;
this.setFileNamesFirst(fileNamesFirst);
@@ -3407,12 +3415,26 @@ public class StagingView extends ViewPart implements IShowInSource {
private int getState(StagingEntry entry) {
switch (entry.getState()) {
- case UNTRACKED:
+ case CONFLICTING:
return 1;
- case MISSING:
- return 2;
case MODIFIED:
+ return 2;
+ case MODIFIED_AND_ADDED:
return 3;
+ case MODIFIED_AND_CHANGED:
+ return 4;
+ case ADDED:
+ return 5;
+ case CHANGED:
+ return 6;
+ case MISSING:
+ return 7;
+ case MISSING_AND_CHANGED:
+ return 8;
+ case REMOVED:
+ return 9;
+ case UNTRACKED:
+ return 10;
default:
return super.category(entry);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 363f21446a..b4f33e7d67 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -1805,7 +1805,7 @@ StagingView_LinkSelection=Link with Editor and Selection
StagingView_replaceWithFileInGitIndex=Replace with &Index
StagingView_replaceWithHeadRevision=Replace with &HEAD Revision
StagingView_UnstageItemMenuLabel=&Remove from Index
-StagingView_UnstagedSort=Sort alphabetically
+StagingView_UnstagedSort=Sort by state
StagingView_StageItemMenuLabel=&Add to Index
StagingView_IgnoreItemMenuLabel=&Ignore
StagingView_DeleteItemMenuLabel=&Delete

Back to the top