Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2018-07-24 15:04:06 -0400
committerTill Brychcy2018-07-24 15:06:01 -0400
commitc57ecc40192949a008423009363558df39cf5452 (patch)
tree165e75dc50ddb3f12bf2489d432fe75484ae8d19 /org.eclipse.ui.workbench.texteditor
parent48b6ff06a9c54785da546d02846a8060337de7ee (diff)
downloadeclipse.platform.text-c57ecc40192949a008423009363558df39cf5452.tar.gz
eclipse.platform.text-c57ecc40192949a008423009363558df39cf5452.tar.xz
eclipse.platform.text-c57ecc40192949a008423009363558df39cf5452.zip
Bug 321410 - [EditorMgmt][navigation] Provide Mini-map of text in editorY20180725-2200I20180725-2000
Change-Id: Ieebad527d54f73ba7d61fe0754d14158f1ace8a3 Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapPage.java32
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapView.java5
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MultiPageMinimapPage.java5
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java5
4 files changed, 40 insertions, 7 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapPage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapPage.java
index 68a7a193d..dbb12ca1b 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapPage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapPage.java
@@ -14,7 +14,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.ITextViewer;
import org.eclipse.ui.part.Page;
@@ -26,11 +26,35 @@ import org.eclipse.ui.texteditor.ITextEditor;
*/
public class MinimapPage extends Page {
- private final ISourceViewer fEditorViewer;
+ /**
+ * Try to create a MinimapPage for a text editor. Only succeeds if the
+ * {@link ITextViewer} for the editor can be determined.
+ *
+ * @param textEditor
+ * the {@link ITextEditor} for which the page should be created.
+ * @return the created MinimapPage or <code>null</code>
+ */
+ public static MinimapPage createMinimapPage(ITextEditor textEditor) {
+ ITextViewer textViewer = textEditor.getAdapter(ITextViewer.class);
+ if (textViewer == null) {
+ // try fallback that sometimes works (TextViewer implements
+ // ITextOperationTarget)
+ ITextOperationTarget textOperationTarget = textEditor.getAdapter(ITextOperationTarget.class);
+ if (textOperationTarget instanceof ITextViewer) {
+ textViewer = (ITextViewer) textOperationTarget;
+ }
+ }
+ if (textViewer == null) {
+ return null;
+ }
+ return new MinimapPage(textViewer);
+ }
+
+ private final ITextViewer fEditorViewer;
private MinimapWidget fMinimapWidget;
- public MinimapPage(ITextEditor textEditor) {
- fEditorViewer = (ISourceViewer) textEditor.getAdapter(ITextOperationTarget.class);
+ private MinimapPage(ITextViewer textViewer) {
+ fEditorViewer = textViewer;
}
@Override
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapView.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapView.java
index 4b1ebe54a..cd2e24456 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapView.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapView.java
@@ -46,6 +46,9 @@ public class MinimapView extends PageBookView {
@Override
protected PageRec doCreatePage(IWorkbenchPart part) {
Page page = createMinimapPage(part);
+ if (page == null) {
+ return null;
+ }
PageSite site = new PageSite(this.getViewSite());
page.init(site);
page.createControl(this.getPageBook());
@@ -56,7 +59,7 @@ public class MinimapView extends PageBookView {
if (part instanceof MultiPageEditorPart) {
return new MultiPageMinimapPage((MultiPageEditorPart) part);
}
- return new MinimapPage((ITextEditor) part);
+ return MinimapPage.createMinimapPage((ITextEditor) part);
}
@Override
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 6fc5febc3..0d3e90bdb 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
@@ -51,10 +51,13 @@ public class MultiPageMinimapPage extends Page {
return;
}
+ MinimapPage minimapPage = null;
if (selectedPage instanceof ITextEditor) {
// Create and show a minimap page for the given text editor page
ITextEditor textEditor = (ITextEditor) selectedPage;
- MinimapPage minimapPage = new MinimapPage(textEditor);
+ minimapPage = MinimapPage.createMinimapPage(textEditor);
+ }
+ if (minimapPage != null) {
minimapPage.createControl(fPageBook);
textWidget = minimapPage.getControl();
fTextWidgetMap.put(selectedPage, textWidget);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index e04180eb6..b9de286d8 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -596,7 +596,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
/**
* The editor's last edit position
- *
+ *
* @since 3.0
*/
private Position fLocalLastEditPosition;
@@ -6172,6 +6172,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
return (T) fColumnSupport;
}
+ if (ITextViewer.class.equals(required))
+ return (fSourceViewer == null ? null : (T) fSourceViewer);
+
return super.getAdapter(required);
}

Back to the top