move ownership of BoxView into VisualizationController

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VisualizationController.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VisualizationController.java
index 36e8f06..373b199 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VisualizationController.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VisualizationController.java
@@ -76,12 +76,16 @@
 		}
 	};
 
-	public VisualizationController(final Cursor cursor, final BoxView view) {
+	public VisualizationController(final IRenderer renderer, final IViewPort viewPort, final Cursor cursor) {
 		cursor.addPositionListener(cursorListener);
-		this.view = view;
+		view = new BoxView(renderer, viewPort, cursor);
 		visualization = new DOMVisualization(cursor, view);
 	}
 
+	public void dispose() {
+		view.dispose();
+	}
+
 	public void setDocument(final IDocument document) {
 		disconnectDocumentListener();
 		this.document = document;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/BoxWidget.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/BoxWidget.java
index 9d4cabd..0f8426e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/BoxWidget.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/BoxWidget.java
@@ -56,8 +56,6 @@
 import org.eclipse.vex.core.internal.undo.JoinElementsAtOffsetEdit;
 import org.eclipse.vex.core.internal.visualization.IBoxModelBuilder;
 import org.eclipse.vex.core.internal.widget.BalancingSelector;
-import org.eclipse.vex.core.internal.widget.BoxView;
-import org.eclipse.vex.core.internal.widget.IRenderer;
 import org.eclipse.vex.core.internal.widget.IViewPort;
 import org.eclipse.vex.core.internal.widget.ReadOnlyException;
 import org.eclipse.vex.core.internal.widget.VisualizationController;
@@ -83,7 +81,6 @@
 
 	private IDocument document;
 
-	private final BoxView view;
 	private final Cursor cursor;
 	private final BalancingSelector selector;
 	private final VisualizationController controller;
@@ -108,14 +105,11 @@
 		connectKeyboard();
 		connectMouse();
 
-		final IRenderer renderer = new DoubleBufferedRenderer(this);
-		final IViewPort viewPort = new ViewPort();
 		selector = new BalancingSelector();
 		cursor = new Cursor(selector);
 		connectCursor();
 
-		view = new BoxView(renderer, viewPort, cursor);
-		controller = new VisualizationController(cursor, view);
+		controller = new VisualizationController(new DoubleBufferedRenderer(this), new ViewPort(), cursor);
 
 		editStack = new EditStack();
 	}
@@ -200,7 +194,7 @@
 	}
 
 	private void widgetDisposed() {
-		view.dispose();
+		controller.dispose();
 		mouseCursor.dispose();
 	}