Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ratz2020-11-16 17:22:19 +0000
committerSebastian Ratz2020-11-16 17:27:46 +0000
commit0b7d82ae44e87d3a18749663bbdd25a0e6642629 (patch)
treec28e19ece4265ac73bd3ae8672a60b88f6ac63a5
parent88182cb588e2a0d985b4dcaf1614f1e0fe7b068b (diff)
downloadeclipse.platform.text-I20201127-0630.tar.gz
eclipse.platform.text-I20201127-0630.tar.xz
eclipse.platform.text-I20201127-0630.zip
Change-Id: I883eb63870feee859364ab38f03d602a8c2f00cc Signed-off-by: Sebastian Ratz <sebastian.ratz@sap.com>
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MultiPageMinimapPage.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MultiPageMinimapPage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MultiPageMinimapPage.java
index 6f4d16d4e..e87f697d4 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MultiPageMinimapPage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MultiPageMinimapPage.java
@@ -14,7 +14,9 @@
package org.eclipse.ui.internal.views.minimap;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -37,24 +39,29 @@ import org.eclipse.ui.texteditor.ITextEditor;
public class MultiPageMinimapPage extends Page {
private final MultiPageEditorPart fMultiPageEditor;
- private final Map<Object, Control> fTextWidgetMap;
+ private final Map<Object, MinimapPage> fMinimapPageMap;
+ private final Set<Object> fUnsupportedEditorPages;
private final IPageChangedListener fPageChangedListener;
private PageBook fPageBook;
private Label fErrorLabel;
public MultiPageMinimapPage(MultiPageEditorPart multiPageEditor) {
this.fMultiPageEditor = multiPageEditor;
- this.fTextWidgetMap = new HashMap<>();
+ this.fMinimapPageMap = new HashMap<>();
+ this.fUnsupportedEditorPages = new HashSet<>();
this.fPageChangedListener = e -> {
Object selectedPage = multiPageEditor.getSelectedPage();
// Find from cache the minimap for the selected page
- Control textWidget = fTextWidgetMap.get(selectedPage);
- if (textWidget != null) {
- fPageBook.showPage(textWidget);
+ MinimapPage minimapPage = fMinimapPageMap.get(selectedPage);
+ if (minimapPage != null) {
+ fPageBook.showPage(minimapPage.getControl());
+ return;
+ }
+ if (fUnsupportedEditorPages.contains(selectedPage)) {
+ fPageBook.showPage(fErrorLabel);
return;
}
- MinimapPage minimapPage = null;
if (selectedPage instanceof ITextEditor) {
// Create and show a minimap page for the given text editor page
ITextEditor textEditor = (ITextEditor) selectedPage;
@@ -62,11 +69,10 @@ public class MultiPageMinimapPage extends Page {
}
if (minimapPage != null) {
minimapPage.createControl(fPageBook);
- textWidget = minimapPage.getControl();
- fTextWidgetMap.put(selectedPage, textWidget);
- fPageBook.showPage(textWidget);
+ fMinimapPageMap.put(selectedPage, minimapPage);
+ fPageBook.showPage(minimapPage.getControl());
} else {
- fTextWidgetMap.put(selectedPage, fErrorLabel);
+ fUnsupportedEditorPages.add(selectedPage);
fPageBook.showPage(fErrorLabel);
}
};
@@ -93,7 +99,10 @@ public class MultiPageMinimapPage extends Page {
@Override
public void dispose() {
- super.dispose();
fMultiPageEditor.removePageChangedListener(fPageChangedListener);
+ fMinimapPageMap.values().forEach(MinimapPage::dispose);
+ fMinimapPageMap.clear();
+ fUnsupportedEditorPages.clear();
+ super.dispose();
}
}

Back to the top