Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Piskarev2014-07-14 13:38:52 +0000
committerVladimir Piskarev2014-07-14 13:38:52 +0000
commitf73c458708cf6400ce8bbe56fa2223baa22ef3e3 (patch)
tree015b32f927d0df7f4da644f3576b3a638f80feab
parentc870a18b8293b823fd0d36b871bf42cae1e0d3ed (diff)
downloadorg.eclipse.handly-f73c458708cf6400ce8bbe56fa2223baa22ef3e3.tar.gz
org.eclipse.handly-f73c458708cf6400ce8bbe56fa2223baa22ef3e3.tar.xz
org.eclipse.handly-f73c458708cf6400ce8bbe56fa2223baa22ef3e3.zip
Bug 439536 - [Basic Example] Outline page should listen to editor input change
-rw-r--r--org.eclipse.handly.examples.basic.ui/src/org/eclipse/handly/internal/examples/basic/ui/outline/FooOutlinePage.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/org.eclipse.handly.examples.basic.ui/src/org/eclipse/handly/internal/examples/basic/ui/outline/FooOutlinePage.java b/org.eclipse.handly.examples.basic.ui/src/org/eclipse/handly/internal/examples/basic/ui/outline/FooOutlinePage.java
index 9cc095f8..f01c4a71 100644
--- a/org.eclipse.handly.examples.basic.ui/src/org/eclipse/handly/internal/examples/basic/ui/outline/FooOutlinePage.java
+++ b/org.eclipse.handly.examples.basic.ui/src/org/eclipse/handly/internal/examples/basic/ui/outline/FooOutlinePage.java
@@ -34,7 +34,9 @@ import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.OpenAndLinkWithEditorHelper;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.xtext.ui.editor.IXtextEditorAware;
@@ -55,6 +57,16 @@ public final class FooOutlinePage
{
private XtextEditor editor;
private LinkingHelper linkingHelper;
+ private IPropertyListener editorInputListener = new IPropertyListener()
+ {
+ public void propertyChanged(Object source, int propId)
+ {
+ if (propId == IEditorPart.PROP_INPUT)
+ {
+ getTreeViewer().setInput(computeInput());
+ }
+ }
+ };
@Inject
private FooContentProvider contentProvider;
@@ -75,6 +87,7 @@ public final class FooOutlinePage
getTreeViewer().setLabelProvider(labelProvider);
getTreeViewer().setInput(computeInput());
linkingHelper = new LinkingHelper();
+ editor.addPropertyListener(editorInputListener);
FooModelCore.getFooModel().addElementChangeListener(this);
}
@@ -82,7 +95,9 @@ public final class FooOutlinePage
public void dispose()
{
FooModelCore.getFooModel().removeElementChangeListener(this);
- linkingHelper.dispose();
+ editor.removePropertyListener(editorInputListener);
+ if (linkingHelper != null)
+ linkingHelper.dispose();
editor.outlinePageClosed();
super.dispose();
}

Back to the top