Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2017-02-23 08:03:15 +0000
committerAndrey Loskutov2017-02-25 08:14:31 +0000
commitb9567d1714dc2dcc8e98dfc3a20cf37e30a683c9 (patch)
tree35826cbe02f412bbafbe15145eef7faadf354d64
parenta8d7ae3f66588ed9121fad876de2f04d464eff03 (diff)
downloadeclipse.platform.ui-b9567d1714dc2dcc8e98dfc3a20cf37e30a683c9.tar.gz
eclipse.platform.ui-b9567d1714dc2dcc8e98dfc3a20cf37e30a683c9.tar.xz
eclipse.platform.ui-b9567d1714dc2dcc8e98dfc3a20cf37e30a683c9.zip
Bug 512609 - [part list] Ctrl+E followed by <Enter> does not work if MRUI20170225-2000
is off Change-Id: I0640b39ca11eec7bf111f235c412fe4bc71e7f0e Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FilteredTableBaseHandler.java15
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java41
2 files changed, 50 insertions, 6 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FilteredTableBaseHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FilteredTableBaseHandler.java
index 39a54341701..9e248257e54 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FilteredTableBaseHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FilteredTableBaseHandler.java
@@ -218,14 +218,17 @@ public abstract class FilteredTableBaseHandler extends AbstractHandler implement
break;
default:
int i;
+ int currentItemIndex = getCurrentItemIndex();
if (gotoDirection) {
- i= getCurrentItemIndex() + 1;
- if (i >= tableItemCount)
- i= 0;
+ i= currentItemIndex + 1;
+ if (i >= tableItemCount) {
+ i = 0;
+ }
} else {
- i= getCurrentItemIndex() - 1;
- if (i < 0)
- i= tableItemCount - 1;
+ i= currentItemIndex - 1;
+ if (i < 0) {
+ i = tableItemCount - 1;
+ }
}
table.setSelection(i);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java
index e56d50e0df5..ae55882894b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java
@@ -76,6 +76,10 @@ public class WorkbookEditorsHandler extends FilteredTableBaseHandler {
@Override
protected Object getInput(WorkbenchPage page) {
+ return getParts(page);
+ }
+
+ private List<EditorReference> getParts(WorkbenchPage page) {
List<EditorReference> refs;
if (isMruEnabled()) {
// sorted, MRU order
@@ -217,4 +221,41 @@ public class WorkbookEditorsHandler extends FilteredTableBaseHandler {
return commandF;
}
+ @Override
+ protected int getCurrentItemIndex() {
+ if (isMruEnabled()) {
+ return 0;
+ }
+ // We need to find previously selected part and return the index of the
+ // part before this part in our list, which ordered not by use but by
+ // position
+
+ WorkbenchPage page = (WorkbenchPage) window.getActivePage();
+ List<EditorReference> sortedByUse = page.getSortedEditorReferences();
+ if (sortedByUse.size() < 2) {
+ return 0;
+ }
+
+ // this is the previously used editor
+ EditorReference next = sortedByUse.get(1);
+
+ // now let's find it position in our list
+ List<EditorReference> sortedByPosition = getParts(page);
+ for (int i = 0; i < sortedByPosition.size(); i++) {
+ EditorReference ref = sortedByPosition.get(i);
+ if (ref == next) {
+ if (i > 0) {
+ // return the position of the previous part in our list
+ gotoDirection = true;
+ return i - 1;
+ }
+ // if the previous part is the *first* one in our list,
+ // we should invert the traversal direction to "back".
+ gotoDirection = false;
+ return 1;
+ }
+ }
+ return super.getCurrentItemIndex();
+ }
+
}

Back to the top