lighten the dependency of IVexHandler to the editor widget

Provide a reference to IDocumentEditor instead of a reference to the
widget type. Also provide the ExecutionEvent, which will contain more
information about the current state of the application.

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BaseVexWidget.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BaseVexWidget.java
index 90269d3..c6450d7 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BaseVexWidget.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BaseVexWidget.java
@@ -122,6 +122,7 @@
 	private IDocument document;
 	private StyleSheet styleSheet;
 	private IWhitespacePolicy whitespacePolicy = DEFAULT_POLICY;
+	private ITableModel tableModel;
 
 	private final BoxFactory boxFactory = new CssBoxFactory();
 
@@ -1779,6 +1780,16 @@
 	}
 
 	@Override
+	public ITableModel getTableModel() {
+		return tableModel;
+	}
+
+	@Override
+	public void setTableModel(final ITableModel tableModel) {
+		this.tableModel = tableModel;
+	}
+
+	@Override
 	public boolean canSplit() {
 		if (readOnly) {
 			return false;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/CssTableModel.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/CssTableModel.java
new file mode 100644
index 0000000..c09967a
--- /dev/null
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/CssTableModel.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Florian Thienel and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * 		Florian Thienel - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.core.internal.widget;
+
+import org.eclipse.vex.core.internal.css.StyleSheet;
+
+/**
+ * @author Florian Thienel
+ */
+public class CssTableModel implements ITableModel {
+
+	private final StyleSheet styleSheet;
+
+	public CssTableModel(final StyleSheet styleSheet) {
+		this.styleSheet = styleSheet;
+	}
+
+	@Override
+	public StyleSheet getStyleSheet() {
+		return styleSheet;
+	}
+
+}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DocumentEditor.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DocumentEditor.java
index fc65884..0c8524b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DocumentEditor.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DocumentEditor.java
@@ -82,6 +82,7 @@
 
 	private IDocument document;
 	private IWhitespacePolicy whitespacePolicy;
+	private ITableModel tableModel;
 	private boolean readOnly;
 
 	private INode currentNode;
@@ -144,6 +145,16 @@
 	}
 
 	@Override
+	public ITableModel getTableModel() {
+		return tableModel;
+	}
+
+	@Override
+	public void setTableModel(final ITableModel tableModel) {
+		this.tableModel = tableModel;
+	}
+
+	@Override
 	public boolean isReadOnly() {
 		return readOnly;
 	}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/IDocumentEditor.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/IDocumentEditor.java
index a095746..b95590a 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/IDocumentEditor.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/IDocumentEditor.java
@@ -49,6 +49,10 @@
 
 	void setWhitespacePolicy(IWhitespacePolicy policy);
 
+	ITableModel getTableModel();
+
+	void setTableModel(ITableModel tableModel);
+
 	/**
 	 * @return true if this editor is read-only
 	 */
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/ITableModel.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/ITableModel.java
new file mode 100644
index 0000000..1a0198f
--- /dev/null
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/ITableModel.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Florian Thienel and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * 		Florian Thienel - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.core.internal.widget;
+
+import org.eclipse.vex.core.internal.css.StyleSheet;
+
+/**
+ * TODO This is only an intermediate solution to provide the stylesheet to all table-related functions. We need an
+ * abstraction of the table model in order to remove the direct dependency to CSS.
+ *
+ * @author Florian Thienel
+ */
+public interface ITableModel {
+
+	@Deprecated
+	StyleSheet getStyleSheet();
+
+}
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 10beff3..17c550f 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
@@ -51,6 +51,7 @@
 import org.eclipse.vex.core.internal.widget.BalancingSelector;
 import org.eclipse.vex.core.internal.widget.DocumentEditor;
 import org.eclipse.vex.core.internal.widget.IDocumentEditor;
+import org.eclipse.vex.core.internal.widget.ITableModel;
 import org.eclipse.vex.core.internal.widget.IViewPort;
 import org.eclipse.vex.core.internal.widget.ReadOnlyException;
 import org.eclipse.vex.core.internal.widget.VisualizationController;
@@ -363,6 +364,16 @@
 		editor.setWhitespacePolicy(policy);
 	}
 
+	@Override
+	public ITableModel getTableModel() {
+		return editor.getTableModel();
+	}
+
+	@Override
+	public void setTableModel(final ITableModel tableModel) {
+		editor.setTableModel(tableModel);
+	}
+
 	public boolean isReadOnly() {
 		return editor.isReadOnly();
 	}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/IVexWidgetHandler.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/IVexWidgetHandler.java
index bf5c047..508003b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/IVexWidgetHandler.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/IVexWidgetHandler.java
@@ -10,7 +10,9 @@
  *******************************************************************************/
 package org.eclipse.vex.core.internal.widget.swt;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 
 /**
  * Interface implemented by handler objects that can act on a {@link VexWidget}.
@@ -19,12 +21,13 @@
 
 	/**
 	 * Executes handler at the specified {@link VexWidget}.
-	 *
+	 * @param event TODO
 	 * @param event
 	 *            the {@link VexWidget} at which to execute handler
+	 *
 	 * @throws ExecutionException
 	 *             if an exception occurred during execution
 	 */
-	void execute(VexWidget widget) throws ExecutionException;
+	void execute(ExecutionEvent event, IDocumentEditor editor) throws ExecutionException;
 
 }
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/VexWidget.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/VexWidget.java
index 3e59216..41c6e59 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/VexWidget.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/VexWidget.java
@@ -16,6 +16,7 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -23,6 +24,7 @@
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.jface.viewers.ISelection;
@@ -68,6 +70,7 @@
 import org.eclipse.vex.core.internal.widget.BaseVexWidget;
 import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.internal.widget.IHostComponent;
+import org.eclipse.vex.core.internal.widget.ITableModel;
 import org.eclipse.vex.core.internal.widget.IVexWidget;
 import org.eclipse.vex.core.internal.widget.ReadOnlyException;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
@@ -584,6 +587,16 @@
 	}
 
 	@Override
+	public void setTableModel(final ITableModel tableModel) {
+		impl.setTableModel(tableModel);
+	}
+
+	@Override
+	public ITableModel getTableModel() {
+		return impl.getTableModel();
+	}
+
+	@Override
 	public boolean canSplit() {
 		return impl.canSplit();
 	}
@@ -772,8 +785,8 @@
 	private static abstract class Action implements IVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			runEx(widget);
+		public void execute(final ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			runEx(editor);
 		}
 
 		public abstract void runEx(IDocumentEditor editor) throws ExecutionException;
@@ -788,7 +801,7 @@
 			final IVexWidgetHandler handler = keyMap.get(keyStroke);
 			if (handler != null) {
 				try {
-					handler.execute(VexWidget.this);
+					handler.execute(new ExecutionEvent(null, Collections.emptyMap(), event, null), VexWidget.this);
 				} catch (final ReadOnlyException e) {
 					// TODO give feedback: the editor is read-only
 				} catch (final Exception ex) {
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentContextSourceProvider.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentContextSourceProvider.java
index 4fd56ba..8ba251a 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentContextSourceProvider.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentContextSourceProvider.java
@@ -15,6 +15,7 @@
 
 import org.eclipse.ui.AbstractSourceProvider;
 import org.eclipse.ui.ISources;
+import org.eclipse.vex.core.internal.core.Rectangle;
 import org.eclipse.vex.core.internal.widget.swt.VexWidget;
 import org.eclipse.vex.core.provisional.dom.BaseNodeVisitorWithResult;
 import org.eclipse.vex.core.provisional.dom.IComment;
@@ -61,6 +62,10 @@
 	/** Variable ID of the <em>is-processing-instruction</em> flag. */
 	public static final String IS_PROCESSING_INSTRUCTION = "org.eclipse.vex.ui.isProcessingInstruction";
 
+	public static final String CARET_AREA = "org.eclipse.vex.ui.caretArea";
+
+	public static final String CURRENT_NODE = "org.eclipse.vex.ui.currentNode";
+
 	private boolean isColumn;
 	private boolean isFirstColumn;
 	private boolean isLastColumn;
@@ -71,6 +76,7 @@
 	private boolean isComment;
 	private boolean isProcessingInstruction;
 
+	private Rectangle caretArea;
 	private INode currentNode;
 
 	@Override
@@ -84,8 +90,8 @@
 	}
 
 	@Override
-	public Map<String, Boolean> getCurrentState() {
-		final Map<String, Boolean> currentState = new HashMap<String, Boolean>(6);
+	public Map<String, Object> getCurrentState() {
+		final Map<String, Object> currentState = new HashMap<String, Object>(20);
 		currentState.put(IS_COLUMN, Boolean.valueOf(isColumn));
 		currentState.put(IS_FIRST_COLUMN, Boolean.valueOf(isFirstColumn));
 		currentState.put(IS_LAST_COLUMN, Boolean.valueOf(isLastColumn));
@@ -95,6 +101,9 @@
 		currentState.put(IS_ELEMENT, Boolean.valueOf(isElement));
 		currentState.put(IS_COMMENT, Boolean.valueOf(isComment));
 		currentState.put(IS_PROCESSING_INSTRUCTION, Boolean.valueOf(isProcessingInstruction));
+		currentState.put(CARET_AREA, caretArea);
+		currentState.put(CURRENT_NODE, currentNode);
+
 		return currentState;
 	}
 
@@ -103,9 +112,11 @@
 	 *
 	 * @param widget
 	 *            the Vex widget containing the actual states
+	 * @param caretArea
+	 *            TODO
 	 */
-	public void fireUpdate(final VexWidget widget) {
-		final Map<String, Boolean> changes = new HashMap<String, Boolean>();
+	public void fireUpdate(final VexWidget widget, final Rectangle caretArea) {
+		final Map<String, Object> changes = new HashMap<String, Object>();
 		final RowColumnInfo rowColumnInfo = VexHandlerUtil.getRowColumnInfo(widget);
 
 		// column
@@ -128,6 +139,12 @@
 			// No need to evaluate if the node has not changed
 			currentNode = selectedNode;
 			changes.putAll(currentNode.accept(nodeTypeVisitor));
+			changes.put(CURRENT_NODE, currentNode);
+		}
+
+		if (!caretArea.equals(this.caretArea)) {
+			this.caretArea = caretArea;
+			changes.put(CARET_AREA, this.caretArea);
 		}
 
 		if (!changes.isEmpty()) {
@@ -135,7 +152,7 @@
 		}
 	}
 
-	private static boolean update(final Map<String, Boolean> changes, final boolean oldValue, final boolean newValue, final String valueName) {
+	private static boolean update(final Map<String, Object> changes, final boolean oldValue, final boolean newValue, final String valueName) {
 		if (newValue == oldValue) {
 			return oldValue;
 		}
@@ -144,10 +161,10 @@
 		return newValue;
 	}
 
-	private final INodeVisitorWithResult<Map<String, Boolean>> nodeTypeVisitor = new BaseNodeVisitorWithResult<Map<String, Boolean>>(new HashMap<String, Boolean>()) {
+	private final INodeVisitorWithResult<Map<String, Object>> nodeTypeVisitor = new BaseNodeVisitorWithResult<Map<String, Object>>(new HashMap<String, Object>()) {
 		@Override
-		public Map<String, Boolean> visit(final IElement element) {
-			final Map<String, Boolean> result = new HashMap<String, Boolean>(3);
+		public Map<String, Object> visit(final IElement element) {
+			final Map<String, Object> result = new HashMap<String, Object>(3);
 			result.put(IS_ELEMENT, true);
 			result.put(IS_COMMENT, false);
 			result.put(IS_PROCESSING_INSTRUCTION, false);
@@ -155,8 +172,8 @@
 		};
 
 		@Override
-		public Map<String, Boolean> visit(final IComment comment) {
-			final Map<String, Boolean> result = new HashMap<String, Boolean>(3);
+		public Map<String, Object> visit(final IComment comment) {
+			final Map<String, Object> result = new HashMap<String, Object>(3);
 			result.put(IS_ELEMENT, false);
 			result.put(IS_COMMENT, true);
 			result.put(IS_PROCESSING_INSTRUCTION, false);
@@ -164,8 +181,8 @@
 		};
 
 		@Override
-		public Map<String, Boolean> visit(final IProcessingInstruction pi) {
-			final Map<String, Boolean> result = new HashMap<String, Boolean>(3);
+		public Map<String, Object> visit(final IProcessingInstruction pi) {
+			final Map<String, Object> result = new HashMap<String, Object>(3);
 			result.put(IS_ELEMENT, false);
 			result.put(IS_COMMENT, false);
 			result.put(IS_PROCESSING_INSTRUCTION, true);
@@ -173,7 +190,7 @@
 		};
 
 		@Override
-		public Map<String, Boolean> visit(final IText text) {
+		public Map<String, Object> visit(final IText text) {
 			return text.getParent().accept(this);
 		}
 	};
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java
index a177786..c17fa10 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java
@@ -93,6 +93,7 @@
 import org.eclipse.ui.views.properties.IPropertySourceProvider;
 import org.eclipse.ui.views.properties.PropertySheetPage;
 import org.eclipse.vex.core.internal.core.ListenerList;
+import org.eclipse.vex.core.internal.core.Rectangle;
 import org.eclipse.vex.core.internal.css.CssWhitespacePolicy;
 import org.eclipse.vex.core.internal.dom.DocumentTextPosition;
 import org.eclipse.vex.core.internal.io.DocumentReader;
@@ -1041,7 +1042,8 @@
 			// update context service
 			final ISourceProviderService service = (ISourceProviderService) window.getService(ISourceProviderService.class);
 			final DocumentContextSourceProvider contextProvider = (DocumentContextSourceProvider) service.getSourceProvider(DocumentContextSourceProvider.IS_COLUMN);
-			contextProvider.fireUpdate(vexWidget);
+			final Rectangle caretArea = Rectangle.NULL; // TODO get the real caret area form the BoxWidget
+			contextProvider.fireUpdate(vexWidget, caretArea);
 		}
 	};
 
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractAddRowHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractAddRowHandler.java
index b57204e..93d2a6a 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractAddRowHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractAddRowHandler.java
@@ -12,8 +12,9 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.IElement;
 
 /**
@@ -26,11 +27,11 @@
 public abstract class AbstractAddRowHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		widget.doWork(new Runnable() {
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		editor.doWork(new Runnable() {
 			@Override
 			public void run() {
-				addRow(widget);
+				addRow(editor);
 			}
 		});
 	}
@@ -40,16 +41,16 @@
 	 */
 	protected abstract boolean addAbove();
 
-	private void addRow(final VexWidget widget) {
+	private void addRow(final IDocumentEditor editor) {
 		// Find the parent table row
-		final IElement currentRow = VexHandlerUtil.getCurrentTableRow(widget);
+		final IElement currentRow = VexHandlerUtil.getCurrentTableRow(editor);
 
 		// Do nothing is the caret is not inside a table row
-		if (currentRow == widget.getDocument().getRootElement()) {
+		if (currentRow == editor.getDocument().getRootElement()) {
 			return;
 		}
 
-		VexHandlerUtil.duplicateTableRow(widget, currentRow, addAbove());
+		VexHandlerUtil.duplicateTableRow(editor, currentRow, addAbove());
 
 	}
 }
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractMoveRowHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractMoveRowHandler.java
index 609c867..3b14921 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractMoveRowHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractMoveRowHandler.java
@@ -10,8 +10,9 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.ContentPositionRange;
 import org.eclipse.vex.ui.internal.handlers.VexHandlerUtil.SelectedRows;
@@ -25,23 +26,23 @@
 public abstract class AbstractMoveRowHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		final VexHandlerUtil.SelectedRows selected = VexHandlerUtil.getSelectedTableRows(widget);
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final VexHandlerUtil.SelectedRows selected = VexHandlerUtil.getSelectedTableRows(editor);
 
 		if (selected.getRows() == null || targetRow(selected) == null) {
 			return;
 		}
 
-		widget.doWork(new Runnable() {
+		editor.doWork(new Runnable() {
 			@Override
 			public void run() {
 				final ContentPositionRange range = VexHandlerUtil.getOuterRange(targetRow(selected));
-				widget.moveTo(range.getStartPosition());
-				widget.moveTo(range.getEndPosition(), true);
-				widget.cutSelection();
+				editor.moveTo(range.getStartPosition());
+				editor.moveTo(range.getEndPosition(), true);
+				editor.cutSelection();
 
-				widget.moveTo(target(selected));
-				widget.paste();
+				editor.moveTo(target(selected));
+				editor.paste();
 			}
 
 		}, true);
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractNavigateTableCellHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractNavigateTableCellHandler.java
index b575d72..0cd2566 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractNavigateTableCellHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractNavigateTableCellHandler.java
@@ -12,11 +12,12 @@
 
 import java.util.NoSuchElementException;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.vex.core.IFilter;
 import org.eclipse.vex.core.internal.css.CSS;
 import org.eclipse.vex.core.internal.css.StyleSheet;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.IAxis;
 import org.eclipse.vex.core.provisional.dom.IElement;
@@ -31,8 +32,8 @@
 public abstract class AbstractNavigateTableCellHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		final IAxis<? extends IParent> parentTableRows = widget.getCurrentElement().ancestors().matching(displayedAsTableRow(widget.getStyleSheet()));
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final IAxis<? extends IParent> parentTableRows = editor.getCurrentElement().ancestors().matching(displayedAsTableRow(editor.getTableModel().getStyleSheet()));
 		final IElement tableRow;
 		try {
 			tableRow = (IElement) parentTableRows.first();
@@ -40,21 +41,21 @@
 			return;
 		}
 
-		final ContentPosition position = widget.getCaretPosition();
-		navigate(widget, tableRow, position);
+		final ContentPosition position = editor.getCaretPosition();
+		navigate(editor, tableRow, position);
 	}
 
 	/**
 	 * Navigates either to the next or previous table cell.
 	 *
-	 * @param widget
+	 * @param editor
 	 *            the Vex widget containing the document
 	 * @param tableRow
 	 *            the current row
 	 * @param offset
 	 *            the current offset
 	 */
-	protected abstract void navigate(VexWidget widget, IElement tableRow, ContentPosition position);
+	protected abstract void navigate(IDocumentEditor editor, IElement tableRow, ContentPosition position);
 
 	private static IFilter<INode> displayedAsTableRow(final StyleSheet stylesheet) {
 		return new IFilter<INode>() {
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractRemoveTableCellsHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractRemoveTableCellsHandler.java
index 74f658a..f80166c 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractRemoveTableCellsHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractRemoveTableCellsHandler.java
@@ -12,13 +12,14 @@
 
 import java.util.List;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPositionRange;
 
 /**
  * Deletes a given list of table cells (see
- * {@link #collectCellsToDelete(VexWidget, org.eclipse.vex.ui.internal.handlers.VexHandlerUtil.RowColumnInfo)} ).
+ * {@link #collectCellsToDelete(IDocumentEditor, org.eclipse.vex.ui.internal.handlers.VexHandlerUtil.RowColumnInfo)} ).
  *
  * @see RemoveColumnHandler
  * @see RemoveRowHandler
@@ -26,41 +27,41 @@
 public abstract class AbstractRemoveTableCellsHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		widget.doWork(new Runnable() {
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		editor.doWork(new Runnable() {
 			@Override
 			public void run() {
 
-				final VexHandlerUtil.RowColumnInfo rcInfo = VexHandlerUtil.getRowColumnInfo(widget);
+				final VexHandlerUtil.RowColumnInfo rcInfo = VexHandlerUtil.getRowColumnInfo(editor);
 
 				if (rcInfo == null) {
 					return;
 				}
 
-				deleteCells(widget, collectCellsToDelete(widget, rcInfo));
+				deleteCells(editor, collectCellsToDelete(editor, rcInfo));
 			}
 
 		});
 	}
 
 	/**
-	 * @param widget
+	 * @param editor
 	 *            the Vex widget
 	 * @param rcInfo
 	 *            row/column info of the current table cell
 	 * @return list of elements to delete
 	 */
-	protected abstract List<Object> collectCellsToDelete(VexWidget widget, VexHandlerUtil.RowColumnInfo rcInfo);
+	protected abstract List<Object> collectCellsToDelete(IDocumentEditor editor, VexHandlerUtil.RowColumnInfo rcInfo);
 
-	private void deleteCells(final VexWidget widget, final List<Object> cellsToDelete) {
+	private void deleteCells(final IDocumentEditor editor, final List<Object> cellsToDelete) {
 		// Iterate the deletions in reverse, so that we don't mess up offsets
 		// that are in anonymous cells, which are not stored as Positions.
 		for (int i = cellsToDelete.size() - 1; i >= 0; i--) {
 			final Object cell = cellsToDelete.get(i);
 			final ContentPositionRange range = VexHandlerUtil.getOuterRange(cell);
-			widget.moveTo(range.getStartPosition());
-			widget.moveTo(range.getEndPosition(), true);
-			widget.deleteSelection();
+			editor.moveTo(range.getStartPosition());
+			editor.moveTo(range.getEndPosition(), true);
+			editor.deleteSelection();
 		}
 	}
 }
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractVexWidgetHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractVexWidgetHandler.java
index 21601ae..8a0f2fc 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractVexWidgetHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractVexWidgetHandler.java
@@ -19,6 +19,7 @@
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.menus.UIElement;
 import org.eclipse.ui.services.IServiceScopes;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.internal.widget.swt.IVexWidgetHandler;
 import org.eclipse.vex.core.internal.widget.swt.VexWidget;
 import org.eclipse.vex.core.provisional.dom.IElement;
@@ -33,12 +34,12 @@
 
 	@Override
 	public Object execute(final ExecutionEvent event) throws ExecutionException {
-		execute(VexHandlerUtil.computeWidget(event));
+		execute(event, VexHandlerUtil.computeWidget(event));
 		return null;
 	}
 
 	@Override
-	public abstract void execute(VexWidget widget) throws ExecutionException;
+	public abstract void execute(ExecutionEvent event, IDocumentEditor editor) throws ExecutionException;
 
 	/**
 	 * Helper method to implement {@link org.eclipse.ui.commands.IElementUpdater}: Updates the name of the UI element
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddCommentHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddCommentHandler.java
index e423744..bc5bd16 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddCommentHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddCommentHandler.java
@@ -1,28 +1,29 @@
-/*******************************************************************************

- * Copyright (c) 2012 Florian Thienel and others.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * which accompanies this distribution, and is available at

- * http://www.eclipse.org/legal/epl-v10.html

- *

- * Contributors:

- * 		Florian Thienel - initial API and implementation

- *******************************************************************************/

-package org.eclipse.vex.ui.internal.handlers;

-

-import org.eclipse.core.commands.ExecutionException;

-import org.eclipse.vex.core.internal.widget.swt.VexWidget;

-

-/**

- * @author Florian Thienel

- */

-public class AddCommentHandler extends AbstractVexWidgetHandler {

-

-	@Override

-	public void execute(final VexWidget widget) throws ExecutionException {

-		if (widget.canInsertComment()) {

-			widget.insertComment();

-		}

-	}

-

-}

+/*******************************************************************************
+ * Copyright (c) 2012 Florian Thienel and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * 		Florian Thienel - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.ui.internal.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
+
+/**
+ * @author Florian Thienel
+ */
+public class AddCommentHandler extends AbstractVexWidgetHandler {
+
+	@Override
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		if (editor.canInsertComment()) {
+			editor.insertComment();
+		}
+	}
+
+}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddElementHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddElementHandler.java
index 41ca65a..efd293d 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddElementHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddElementHandler.java
@@ -10,8 +10,13 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.vex.core.internal.core.Rectangle;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.ui.internal.swt.ContentAssist;
 
 /**
@@ -20,8 +25,11 @@
 public class AddElementHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		ContentAssist.openAddElementsContentAssist(widget);
+	public void execute(final ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final Shell shell = HandlerUtil.getActiveShell(event);
+		final Rectangle caretArea = VexHandlerUtil.getCaretArea(event);
+		final Point location = new Point(caretArea.getX(), caretArea.getY());
+		ContentAssist.openAddElementsContentAssist(shell, editor, location);
 	}
 
 }
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddProcessingInstructionHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddProcessingInstructionHandler.java
index f73e3f8..25ccd1d 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddProcessingInstructionHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddProcessingInstructionHandler.java
@@ -10,10 +10,11 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.DocumentValidationException;
 import org.eclipse.vex.ui.internal.VexPlugin;
 import org.eclipse.vex.ui.internal.swt.ProcessingInstrDialog;
@@ -21,15 +22,15 @@
 public class AddProcessingInstructionHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		if (widget.canInsertProcessingInstruction()) {
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		if (editor.canInsertProcessingInstruction()) {
 			final Shell shell = VexPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
 			final ProcessingInstrDialog dialog = new ProcessingInstrDialog(shell, "");
 			dialog.create();
 
-			if (dialog.open() == Window.OK && widget.canInsertProcessingInstruction()) {
+			if (dialog.open() == Window.OK && editor.canInsertProcessingInstruction()) {
 				try {
-					widget.insertProcessingInstruction(dialog.getTarget());
+					editor.insertProcessingInstruction(dialog.getTarget());
 				} catch (final DocumentValidationException e) {
 
 				}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/ConvertElementHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/ConvertElementHandler.java
index caffa5a..74a4401 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/ConvertElementHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/ConvertElementHandler.java
@@ -12,10 +12,15 @@
 
 import java.util.Map;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.commands.IElementUpdater;
+import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.menus.UIElement;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.core.Rectangle;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.ui.internal.swt.ContentAssist;
 
 /**
@@ -29,8 +34,11 @@
 	private static final String LABEL_ID = "command.convertElement.dynamicName"; //$NON-NLS-1$
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		ContentAssist.openQuickFixContentAssist(widget);
+	public void execute(final ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final Shell shell = HandlerUtil.getActiveShell(event);
+		final Rectangle caretArea = VexHandlerUtil.getCaretArea(event);
+		final Point location = new Point(caretArea.getX(), caretArea.getY());
+		ContentAssist.openQuickFixContentAssist(shell, editor, location);
 	}
 
 	@Override
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/DuplicateSelectionHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/DuplicateSelectionHandler.java
index 3e08714..0fc601b 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/DuplicateSelectionHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/DuplicateSelectionHandler.java
@@ -10,8 +10,9 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.INode;
 
@@ -21,29 +22,29 @@
 public class DuplicateSelectionHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		widget.doWork(new Runnable() {
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		editor.doWork(new Runnable() {
 			@Override
 			public void run() {
-				if (!widget.hasSelection()) {
-					final INode node = widget.getCurrentNode();
+				if (!editor.hasSelection()) {
+					final INode node = editor.getCurrentNode();
 
 					// Can't duplicate the document
 					if (node.getParent() == null) {
 						return;
 					}
 
-					widget.moveTo(node.getStartPosition());
-					widget.moveTo(node.getEndPosition().moveBy(+1), true);
+					editor.moveTo(node.getStartPosition());
+					editor.moveTo(node.getEndPosition().moveBy(+1), true);
 				}
 
-				widget.copySelection();
-				final ContentPosition startPosition = widget.getSelectedPositionRange().getEndPosition().moveBy(1);
-				widget.moveTo(startPosition);
-				widget.paste();
-				final ContentPosition endPosition = widget.getCaretPosition();
-				widget.moveTo(startPosition);
-				widget.moveTo(endPosition, true);
+				editor.copySelection();
+				final ContentPosition startPosition = editor.getSelectedPositionRange().getEndPosition().moveBy(1);
+				editor.moveTo(startPosition);
+				editor.paste();
+				final ContentPosition endPosition = editor.getCaretPosition();
+				editor.moveTo(startPosition);
+				editor.moveTo(endPosition, true);
 			}
 		});
 	}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/JoinHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/JoinHandler.java
index cf2c25f..60e2d01 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/JoinHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/JoinHandler.java
@@ -10,8 +10,9 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 
 /**
  * @author Florian Thienel
@@ -19,9 +20,9 @@
 public class JoinHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		if (widget.canJoin()) {
-			widget.join();
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		if (editor.canJoin()) {
+			editor.join();
 		}
 	}
 
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveSelectionUpHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveSelectionUpHandler.java
index f3df30e..5bb1741 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveSelectionUpHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveSelectionUpHandler.java
@@ -10,10 +10,11 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.vex.core.IFilter;
 import org.eclipse.vex.core.internal.css.IWhitespacePolicy;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentRange;
 import org.eclipse.vex.core.provisional.dom.IAxis;
 import org.eclipse.vex.core.provisional.dom.INode;
@@ -27,17 +28,17 @@
 public class MoveSelectionUpHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		final ContentRange selectedRange = widget.getSelectedRange();
-		final IAxis<? extends IParent> parentsContainingSelection = widget.getCurrentElement().ancestors().matching(containingRange(selectedRange));
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final ContentRange selectedRange = editor.getSelectedRange();
+		final IAxis<? extends IParent> parentsContainingSelection = editor.getCurrentElement().ancestors().matching(containingRange(selectedRange));
 
 		// expand the selection until a parent has other block-children
-		final IWhitespacePolicy policy = widget.getWhitespacePolicy();
+		final IWhitespacePolicy policy = editor.getWhitespacePolicy();
 		for (final IParent parent : parentsContainingSelection) {
 			final IAxis<? extends INode> blockChildren = parent.children().matching(displayedAsBlock(policy));
 			if (blockChildren.isEmpty()) {
-				widget.moveTo(parent.getStartPosition(), false);
-				widget.moveTo(parent.getEndPosition(), true);
+				editor.moveTo(parent.getStartPosition(), false);
+				editor.moveTo(parent.getEndPosition(), true);
 			} else {
 				break;
 			}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/NextTableCellHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/NextTableCellHandler.java
index 618c5ee..fe98183 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/NextTableCellHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/NextTableCellHandler.java
@@ -13,7 +13,7 @@
 
 import java.util.NoSuchElementException;
 
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.IElement;
 
@@ -25,11 +25,11 @@
 public class NextTableCellHandler extends AbstractNavigateTableCellHandler {
 
 	@Override
-	protected void navigate(final VexWidget widget, final IElement tableRow, final ContentPosition position) {
+	protected void navigate(final IDocumentEditor editor, final IElement tableRow, final ContentPosition position) {
 		// in this row
 		for (final IElement cell : tableRow.childElements()) {
 			if (cell.getStartPosition().isAfter(position)) {
-				widget.moveTo(cell.getStartPosition().moveBy(1));
+				editor.moveTo(cell.getStartPosition().moveBy(1));
 				return;
 			}
 		}
@@ -40,7 +40,7 @@
 				final IElement firstCell = firstCellOf(siblingRow);
 
 				if (firstCell != null) {
-					widget.moveTo(firstCell.getStartPosition().moveBy(1));
+					editor.moveTo(firstCell.getStartPosition().moveBy(1));
 				} else {
 					System.out.println("TODO - dup row into new empty row");
 				}
@@ -49,7 +49,7 @@
 		}
 
 		// We didn't find a "next row", so let's dup the current one
-		VexHandlerUtil.duplicateTableRow(widget, tableRow, false);
+		VexHandlerUtil.duplicateTableRow(editor, tableRow, false);
 	}
 
 	private static IElement firstCellOf(final IElement tableRow) {
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/PreviousTableCellHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/PreviousTableCellHandler.java
index f42e19e..e2025a8 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/PreviousTableCellHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/PreviousTableCellHandler.java
@@ -12,7 +12,7 @@
 
 import java.util.NoSuchElementException;
 
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.IElement;
 
@@ -24,7 +24,7 @@
 public class PreviousTableCellHandler extends AbstractNavigateTableCellHandler {
 
 	@Override
-	protected void navigate(final VexWidget widget, final IElement tableRow, final ContentPosition position) {
+	protected void navigate(final IDocumentEditor editor, final IElement tableRow, final ContentPosition position) {
 		IElement siblingCell = null;
 		for (final IElement cell : tableRow.childElements()) {
 			if (cell.getEndPosition().isAfterOrEquals(position)) {
@@ -35,7 +35,7 @@
 
 		// in this row
 		if (siblingCell != null) {
-			widget.moveTo(siblingCell.getStartPosition().moveBy(1));
+			editor.moveTo(siblingCell.getStartPosition().moveBy(1));
 			return;
 		}
 
@@ -51,7 +51,7 @@
 		if (siblingRow != null) {
 			final IElement lastCell = lastCellOf(siblingRow);
 			if (lastCell != null) {
-				widget.moveTo(lastCell.getStartPosition().moveBy(1));
+				editor.moveTo(lastCell.getStartPosition().moveBy(1));
 			}
 		}
 	}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveColumnHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveColumnHandler.java
index e4e280d..755c0f0 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveColumnHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveColumnHandler.java
@@ -14,7 +14,7 @@
 import java.util.List;
 
 import org.eclipse.vex.core.internal.layout.LayoutUtils.ElementOrRange;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 
 /**
  * Deletes current column.
@@ -22,9 +22,9 @@
 public class RemoveColumnHandler extends AbstractRemoveTableCellsHandler {
 
 	@Override
-	protected List<Object> collectCellsToDelete(final VexWidget widget, final VexHandlerUtil.RowColumnInfo rcInfo) {
+	protected List<Object> collectCellsToDelete(final IDocumentEditor editor, final VexHandlerUtil.RowColumnInfo rcInfo) {
 		final List<Object> cellsToDelete = new ArrayList<Object>();
-		VexHandlerUtil.iterateTableCells(widget, new TableCellCallbackAdapter() {
+		VexHandlerUtil.iterateTableCells(editor, new TableCellCallbackAdapter() {
 			@Override
 			public void onCell(final ElementOrRange row, final ElementOrRange cell, final int rowIndex, final int cellIndex) {
 				if (cellIndex == rcInfo.cellIndex) {
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveRowHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveRowHandler.java
index 8d10f7c..0e28308 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveRowHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveRowHandler.java
@@ -12,7 +12,7 @@
 
 import java.util.List;
 
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 
 /**
  * Deletes selected row(s).
@@ -20,8 +20,8 @@
 public class RemoveRowHandler extends AbstractRemoveTableCellsHandler {
 
 	@Override
-	protected List<Object> collectCellsToDelete(final VexWidget widget, final VexHandlerUtil.RowColumnInfo rcInfo) {
-		return VexHandlerUtil.getSelectedTableRows(widget).getRows();
+	protected List<Object> collectCellsToDelete(final IDocumentEditor editor, final VexHandlerUtil.RowColumnInfo rcInfo) {
+		return VexHandlerUtil.getSelectedTableRows(editor).getRows();
 	}
 
 }
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveTagHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveTagHandler.java
index 57cade6..50770e7 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveTagHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveTagHandler.java
@@ -13,10 +13,11 @@
 
 import java.util.Map;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.ui.commands.IElementUpdater;
 import org.eclipse.ui.menus.UIElement;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 
 /**
  * Removes the current tag: deletes the element but adds its content to the parent element.
@@ -30,9 +31,9 @@
 	private static final String PARTSITE_SCOPE_DYNAMIC_LABEL_ID = "command.removeTag.dynamicName"; //$NON-NLS-1$
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		if (widget.canUnwrap()) {
-			widget.unwrap();
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		if (editor.canUnwrap()) {
+			editor.unwrap();
 		}
 	}
 
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SetProcessingInstructionTargetHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SetProcessingInstructionTargetHandler.java
index 1d4c304..310d060 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SetProcessingInstructionTargetHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SetProcessingInstructionTargetHandler.java
@@ -10,10 +10,11 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.DocumentValidationException;
 import org.eclipse.vex.core.provisional.dom.IProcessingInstruction;
 import org.eclipse.vex.ui.internal.VexPlugin;
@@ -22,16 +23,16 @@
 public class SetProcessingInstructionTargetHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		if (widget.getCurrentNode() instanceof IProcessingInstruction) {
-			final IProcessingInstruction pi = (IProcessingInstruction) widget.getCurrentNode();
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		if (editor.getCurrentNode() instanceof IProcessingInstruction) {
+			final IProcessingInstruction pi = (IProcessingInstruction) editor.getCurrentNode();
 			final Shell shell = VexPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
 			final ProcessingInstrDialog dialog = new ProcessingInstrDialog(shell, pi.getTarget());
 			dialog.create();
 
 			if (dialog.open() == Window.OK) {
 				try {
-					widget.editProcessingInstruction(dialog.getTarget(), null);
+					editor.editProcessingInstruction(dialog.getTarget(), null);
 				} catch (final DocumentValidationException e) {
 
 				}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitBlockElementHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitBlockElementHandler.java
index 7371509..e8727f4 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitBlockElementHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitBlockElementHandler.java
@@ -11,9 +11,13 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.vex.core.internal.widget.IVexWidget;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.vex.core.internal.core.Rectangle;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.INode;
 import org.eclipse.vex.ui.internal.swt.ContentAssist;
@@ -27,19 +31,22 @@
 public class SplitBlockElementHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		if (widget.isReadOnly()) {
+	public void execute(final ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		if (editor.isReadOnly()) {
 			return;
 		}
 
-		final INode currentNode = widget.getCurrentNode();
-		if (widget.canSplit()) {
-			splitElement(widget, currentNode);
+		final INode currentNode = editor.getCurrentNode();
+		if (editor.canSplit()) {
+			splitElement(editor, currentNode);
 		} else {
 			final ContentPosition targetPosition = currentNode.getEndPosition().moveBy(1);
-			if (widget.getDocument().getRootElement().containsPosition(targetPosition)) {
-				widget.moveTo(targetPosition);
-				ContentAssist.openAddElementsContentAssist(widget);
+			if (editor.getDocument().getRootElement().containsPosition(targetPosition)) {
+				editor.moveTo(targetPosition);
+				final Shell shell = HandlerUtil.getActiveShell(event);
+				final Rectangle caretArea = VexHandlerUtil.getCaretArea(event);
+				final Point location = new Point(caretArea.getX(), caretArea.getY());
+				ContentAssist.openAddElementsContentAssist(shell, editor, location);
 			}
 		}
 	}
@@ -47,20 +54,20 @@
 	/**
 	 * Splits the given element.
 	 *
-	 * @param vexWidget
+	 * @param editor
 	 *            IVexWidget containing the document.
 	 * @param node
 	 *            Node to be split.
 	 */
-	protected void splitElement(final IVexWidget vexWidget, final INode node) {
-		vexWidget.doWork(new Runnable() {
+	protected void splitElement(final IDocumentEditor editor, final INode node) {
+		editor.doWork(new Runnable() {
 			@Override
 			public void run() {
-				final boolean isPreformatted = vexWidget.getWhitespacePolicy().isPre(node);
+				final boolean isPreformatted = editor.getWhitespacePolicy().isPre(node);
 				if (isPreformatted) {
-					vexWidget.insertText("\n");
+					editor.insertText("\n");
 				} else {
-					vexWidget.split();
+					editor.split();
 				}
 			}
 		});
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitItemHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitItemHandler.java
index 8f05ca3..469355c 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitItemHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitItemHandler.java
@@ -12,11 +12,12 @@
 
 import java.util.NoSuchElementException;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.vex.core.IFilter;
 import org.eclipse.vex.core.internal.css.CSS;
 import org.eclipse.vex.core.internal.css.StyleSheet;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.IAxis;
 import org.eclipse.vex.core.provisional.dom.INode;
 import org.eclipse.vex.core.provisional.dom.IParent;
@@ -30,9 +31,9 @@
 public class SplitItemHandler extends SplitBlockElementHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		final StyleSheet stylesheet = widget.getStyleSheet();
-		final IAxis<? extends IParent> parentTableRowOrListItems = widget.getCurrentElement().ancestors().matching(displayedAsTableRowOrListItem(stylesheet));
+	public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final StyleSheet stylesheet = editor.getTableModel().getStyleSheet();
+		final IAxis<? extends IParent> parentTableRowOrListItems = editor.getCurrentElement().ancestors().matching(displayedAsTableRowOrListItem(stylesheet));
 
 		final IParent firstTableRowOrListItem;
 		try {
@@ -43,9 +44,9 @@
 
 		final String displayStyle = stylesheet.getStyles(firstTableRowOrListItem).getDisplay();
 		if (displayStyle.equals(CSS.TABLE_ROW)) {
-			new AddRowBelowHandler().execute(widget);
+			new AddRowBelowHandler().execute(event, editor);
 		} else if (displayStyle.equals(CSS.LIST_ITEM)) {
-			splitElement(widget, firstTableRowOrListItem);
+			splitElement(editor, firstTableRowOrListItem);
 		}
 	}
 
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/TextEditingHandlerFactory.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/TextEditingHandlerFactory.java
index a936025..4a9da57 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/TextEditingHandlerFactory.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/TextEditingHandlerFactory.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.handlers;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
@@ -17,7 +18,7 @@
 import org.eclipse.core.runtime.IExecutableExtensionFactory;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.ui.internal.VexPlugin;
 
@@ -183,8 +184,8 @@
 	private static class PreviousColumn extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveBy(-1);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveBy(-1);
 		}
 
 	}
@@ -192,8 +193,8 @@
 	private static class NextColumn extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveBy(1);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveBy(1);
 		}
 
 	}
@@ -201,8 +202,8 @@
 	private static class LineUp extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousLine(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousLine(false);
 		}
 
 	}
@@ -210,8 +211,8 @@
 	private static class LineDown extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextLine(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextLine(false);
 		}
 
 	}
@@ -219,8 +220,8 @@
 	private static class PreviousWord extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousWord(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousWord(false);
 		}
 
 	}
@@ -228,8 +229,8 @@
 	private static class NextWord extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextWord(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextWord(false);
 		}
 
 	}
@@ -237,8 +238,8 @@
 	private static class LineStart extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToLineStart(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToLineStart(false);
 		}
 
 	}
@@ -246,8 +247,8 @@
 	private static class LineEnd extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToLineEnd(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToLineEnd(false);
 		}
 
 	}
@@ -255,8 +256,8 @@
 	private static class PageUp extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousPage(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousPage(false);
 		}
 
 	}
@@ -264,8 +265,8 @@
 	private static class PageDown extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextPage(false);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextPage(false);
 		}
 
 	}
@@ -273,8 +274,8 @@
 	private static class TextStart extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveTo(widget.getDocument().getStartPosition());
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveTo(editor.getDocument().getStartPosition());
 		}
 
 	}
@@ -282,8 +283,8 @@
 	private static class TextEnd extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveTo(widget.getDocument().getEndPosition().moveBy(-1));
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveTo(editor.getDocument().getEndPosition().moveBy(-1));
 		}
 
 	}
@@ -291,8 +292,8 @@
 	private static class SelectPreviousColumn extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveBy(-1, true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveBy(-1, true);
 		}
 
 	}
@@ -300,8 +301,8 @@
 	private static class SelectNextColumn extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveBy(1, true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveBy(1, true);
 		}
 
 	}
@@ -309,8 +310,8 @@
 	private static class SelectLineUp extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousLine(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousLine(true);
 		}
 
 	}
@@ -318,8 +319,8 @@
 	private static class SelectLineDown extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextLine(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextLine(true);
 		}
 
 	}
@@ -327,8 +328,8 @@
 	private static class SelectPreviousWord extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousWord(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousWord(true);
 		}
 
 	}
@@ -336,8 +337,8 @@
 	private static class SelectNextWord extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextWord(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextWord(true);
 		}
 
 	}
@@ -345,8 +346,8 @@
 	private static class SelectLineStart extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToLineStart(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToLineStart(true);
 		}
 
 	}
@@ -354,8 +355,8 @@
 	private static class SelectLineEnd extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToLineEnd(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToLineEnd(true);
 		}
 
 	}
@@ -363,8 +364,8 @@
 	private static class SelectPageUp extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousPage(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousPage(true);
 		}
 
 	}
@@ -372,8 +373,8 @@
 	private static class SelectPageDown extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextPage(true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextPage(true);
 		}
 
 	}
@@ -381,8 +382,8 @@
 	private static class SelectTextStart extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveTo(widget.getDocument().getStartPosition(), true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveTo(editor.getDocument().getStartPosition(), true);
 		}
 
 	}
@@ -390,8 +391,8 @@
 	private static class SelectTextEnd extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveTo(widget.getDocument().getEndPosition().moveBy(-1), true);
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveTo(editor.getDocument().getEndPosition().moveBy(-1), true);
 		}
 
 	}
@@ -399,16 +400,16 @@
 	private static class DeletePrevious extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.deleteBackward();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.deleteBackward();
 		}
 	}
 
 	private static class DeleteNext extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.deleteForward();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.deleteForward();
 		}
 
 	}
@@ -416,9 +417,9 @@
 	private static class DeletePreviousWord extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToPreviousWord(true);
-			widget.deleteSelection();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToPreviousWord(true);
+			editor.deleteSelection();
 		}
 
 	}
@@ -426,9 +427,9 @@
 	private static class DeleteNextWord extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			widget.moveToNextWord(true);
-			widget.deleteSelection();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			editor.moveToNextWord(true);
+			editor.deleteSelection();
 		}
 
 	}
@@ -436,9 +437,9 @@
 	private static class DeleteLine extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			selectWholeLines(widget);
-			widget.deleteSelection();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			selectWholeLines(editor);
+			editor.deleteSelection();
 
 		}
 
@@ -447,15 +448,15 @@
 	private static class DeleteToBeginningOfLine extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			final int selectionLength = widget.getSelectedRange().length();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			final int selectionLength = editor.getSelectedRange().length();
 			if (selectionLength > 1) {
-				widget.moveTo(widget.getSelectedPositionRange().getStartPosition());
+				editor.moveTo(editor.getSelectedPositionRange().getStartPosition());
 			}
-			widget.moveToLineStart(true);
-			widget.deleteSelection();
+			editor.moveToLineStart(true);
+			editor.deleteSelection();
 			if (selectionLength > 1) {
-				widget.moveBy(selectionLength, true);
+				editor.moveBy(selectionLength, true);
 			}
 		}
 
@@ -464,12 +465,12 @@
 	private static class DeleteToEndOfLine extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			if (widget.hasSelection()) {
-				widget.moveTo(widget.getSelectedPositionRange().getStartPosition());
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			if (editor.hasSelection()) {
+				editor.moveTo(editor.getSelectedPositionRange().getStartPosition());
 			}
-			widget.moveToLineEnd(true);
-			widget.deleteSelection();
+			editor.moveToLineEnd(true);
+			editor.deleteSelection();
 		}
 
 	}
@@ -477,9 +478,9 @@
 	private static class CutLine extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			selectWholeLines(widget);
-			widget.cutSelection();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			selectWholeLines(editor);
+			editor.cutSelection();
 		}
 
 	}
@@ -487,15 +488,15 @@
 	private static class CutLineToBeginning extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			final int selectionLength = widget.getSelectedRange().length();
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			final int selectionLength = editor.getSelectedRange().length();
 			if (selectionLength > 1) {
-				widget.moveTo(widget.getSelectedPositionRange().getStartPosition());
+				editor.moveTo(editor.getSelectedPositionRange().getStartPosition());
 			}
-			widget.moveToLineStart(true);
-			widget.cutSelection();
+			editor.moveToLineStart(true);
+			editor.cutSelection();
 			if (selectionLength > 1) {
-				widget.moveBy(selectionLength, true);
+				editor.moveBy(selectionLength, true);
 			}
 		}
 
@@ -504,40 +505,40 @@
 	private static class CutLineToEnd extends AbstractVexWidgetHandler {
 
 		@Override
-		public void execute(final VexWidget widget) throws ExecutionException {
-			if (widget.hasSelection()) {
-				widget.moveTo(widget.getSelectedPositionRange().getStartPosition());
+		public void execute(ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+			if (editor.hasSelection()) {
+				editor.moveTo(editor.getSelectedPositionRange().getStartPosition());
 			}
-			widget.moveToLineEnd(true);
-			widget.cutSelection();
+			editor.moveToLineEnd(true);
+			editor.cutSelection();
 		}
 
 	}
 
-	private static void selectWholeLines(final VexWidget widget) {
+	private static void selectWholeLines(final IDocumentEditor editor) {
 
 		// no selection?
-		if (!widget.hasSelection()) {
-			widget.moveToLineStart(false);
-			widget.moveToLineEnd(true);
+		if (!editor.hasSelection()) {
+			editor.moveToLineStart(false);
+			editor.moveToLineEnd(true);
 			return;
 		}
 
 		// remember start
-		final ContentPosition start = widget.getSelectedPositionRange().getStartPosition();
+		final ContentPosition start = editor.getSelectedPositionRange().getStartPosition();
 
 		// calculate end of deletion
-		ContentPosition end = widget.getSelectedPositionRange().getEndPosition();
-		widget.moveTo(end);
-		widget.moveToLineEnd(false);
-		end = widget.getCaretPosition();
+		ContentPosition end = editor.getSelectedPositionRange().getEndPosition();
+		editor.moveTo(end);
+		editor.moveToLineEnd(false);
+		end = editor.getCaretPosition();
 
 		// go to start of deletion
-		widget.moveTo(start);
-		widget.moveToLineStart(false);
+		editor.moveTo(start);
+		editor.moveToLineStart(false);
 
 		// select and delete
-		widget.moveTo(end, true);
+		editor.moveTo(end, true);
 
 	}
 
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/VexHandlerUtil.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/VexHandlerUtil.java
index 43bb7c4..d92c8d7 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/VexHandlerUtil.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/VexHandlerUtil.java
@@ -22,13 +22,14 @@
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.vex.core.internal.core.Rectangle;
 import org.eclipse.vex.core.internal.css.CSS;
 import org.eclipse.vex.core.internal.css.StyleSheet;
 import org.eclipse.vex.core.internal.layout.ElementOrPositionRangeCallback;
 import org.eclipse.vex.core.internal.layout.ElementOrRangeCallback;
 import org.eclipse.vex.core.internal.layout.LayoutUtils;
 import org.eclipse.vex.core.internal.layout.LayoutUtils.ElementOrRange;
-import org.eclipse.vex.core.internal.widget.IVexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.internal.widget.swt.VexWidget;
 import org.eclipse.vex.core.provisional.dom.BaseNodeVisitor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
@@ -41,6 +42,7 @@
 import org.eclipse.vex.core.provisional.dom.INode;
 import org.eclipse.vex.core.provisional.dom.IParent;
 import org.eclipse.vex.core.provisional.dom.IProcessingInstruction;
+import org.eclipse.vex.ui.internal.editor.DocumentContextSourceProvider;
 import org.eclipse.vex.ui.internal.editor.VexEditor;
 
 /**
@@ -49,15 +51,12 @@
 public final class VexHandlerUtil {
 
 	public static VexWidget computeWidget(final ExecutionEvent event) throws ExecutionException {
-
 		final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
-		assertNotNull(activeEditor);
-
 		VexWidget widget = null;
 		if (activeEditor instanceof VexEditor) {
 			widget = ((VexEditor) activeEditor).getVexWidget();
 		}
-		assertNotNull(widget);
+		assertNotNull(widget, "Can not compute VexWidget.");
 		return widget;
 	}
 
@@ -69,6 +68,15 @@
 		return editor.getVexWidget();
 	}
 
+	public static VexEditor computeVexEditor(final ExecutionEvent event) throws ExecutionException {
+		final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
+
+		if (activeEditor instanceof VexEditor) {
+			return (VexEditor) activeEditor;
+		}
+		return null;
+	}
+
 	public static VexEditor computeVexEditor(final IWorkbenchWindow window) {
 		final IEditorPart activeEditor = window.getActivePage().getActiveEditor();
 		if (activeEditor == null) {
@@ -81,9 +89,22 @@
 		return null;
 	}
 
-	private static void assertNotNull(final Object object) throws ExecutionException {
+	public static Rectangle getCaretArea(final ExecutionEvent event) throws ExecutionException {
+		return getVariable(event, DocumentContextSourceProvider.CARET_AREA);
+	}
+
+	public static INode getCurrentNode(final ExecutionEvent event) throws ExecutionException {
+		return getVariable(event, DocumentContextSourceProvider.CURRENT_NODE);
+	}
+
+	@SuppressWarnings("unchecked")
+	private static <T> T getVariable(final ExecutionEvent event, final String name) {
+		return (T) HandlerUtil.getVariable(event, DocumentContextSourceProvider.CARET_AREA);
+	}
+
+	private static void assertNotNull(final Object object, final String message) throws ExecutionException {
 		if (object == null) {
-			throw new ExecutionException("Can not compute VexWidget.");
+			throw new ExecutionException(message);
 		}
 	}
 
@@ -101,27 +122,27 @@
 	 * Duplicate the given table row, inserting a new empty one aove or below it. The new row contains empty children
 	 * corresponding to the given row's children.
 	 *
-	 * @param vexWidget
+	 * @param editor
 	 *            IVexWidget with which we're working
 	 * @param tableRow
 	 *            TableRowBox to be duplicated.
 	 * @param addAbove
 	 *            <code>true</code> to add the new row above the current one
 	 */
-	public static void duplicateTableRow(final IVexWidget vexWidget, final IElement tableRow, final boolean addAbove) {
-		final StyleSheet styleSheet = vexWidget.getStyleSheet();
+	public static void duplicateTableRow(final IDocumentEditor editor, final IElement tableRow, final boolean addAbove) {
+		final StyleSheet styleSheet = editor.getTableModel().getStyleSheet();
 		if (!styleSheet.getStyles(tableRow).getDisplay().equals(CSS.TABLE_ROW)) {
 			return;
 		}
 
 		if (addAbove) {
-			vexWidget.moveTo(tableRow.getStartPosition());
+			editor.moveTo(tableRow.getStartPosition());
 		} else {
-			vexWidget.moveTo(tableRow.getEndPosition().moveBy(1));
+			editor.moveTo(tableRow.getEndPosition().moveBy(1));
 		}
 
 		// Create a new table row
-		final IElement newRow = vexWidget.insertElement(tableRow.getQualifiedName());
+		final IElement newRow = editor.insertElement(tableRow.getQualifiedName());
 
 		// Iterate all direct children and add them to the new row
 		final Iterator<? extends INode> childIterator = tableRow.children().withoutText().iterator();
@@ -129,49 +150,49 @@
 			childIterator.next().accept(new BaseNodeVisitor() {
 				@Override
 				public void visit(final IElement element) {
-					final IElement newElement = vexWidget.insertElement(element.getQualifiedName());
+					final IElement newElement = editor.insertElement(element.getQualifiedName());
 					for (final IAttribute attr : element.getAttributes()) {
 						newElement.setAttribute(attr.getQualifiedName(), attr.getValue());
 					}
-					vexWidget.moveBy(1);
+					editor.moveBy(1);
 				}
 
 				@Override
 				public void visit(final IComment comment) {
 					// Comments are copied with content
-					vexWidget.insertComment();
-					vexWidget.insertText(comment.getText());
-					vexWidget.moveBy(1);
+					editor.insertComment();
+					editor.insertText(comment.getText());
+					editor.moveBy(1);
 				}
 
 				@Override
 				public void visit(final IProcessingInstruction pi) {
 					// Processing instructions are copied with target and  content
-					vexWidget.insertProcessingInstruction(pi.getTarget());
-					vexWidget.insertText(pi.getText());
-					vexWidget.moveBy(1);
+					editor.insertProcessingInstruction(pi.getTarget());
+					editor.insertText(pi.getText());
+					editor.moveBy(1);
 				}
 			});
 		}
 		try {
 			final INode firstTextChild = newRow.childElements().first();
-			vexWidget.moveTo(firstTextChild.getStartPosition());
+			editor.moveTo(firstTextChild.getStartPosition());
 		} catch (final NoSuchElementException ex) {
-			vexWidget.moveTo(newRow.getStartPosition().moveBy(1));
+			editor.moveTo(newRow.getStartPosition().moveBy(1));
 		}
 	}
 
 	/**
 	 * Returns true if the given element or range is at least partially selected.
 	 *
-	 * @param widget
+	 * @param editor
 	 *            IVexWidget being tested.
 	 * @param elementOrRange
 	 *            Element or IntRange being tested.
 	 */
-	public static boolean elementOrRangeIsPartiallySelected(final IVexWidget widget, final Object elementOrRange) {
+	public static boolean elementOrRangeIsPartiallySelected(final IDocumentEditor editor, final Object elementOrRange) {
 		final ContentRange elementContentRange = getInnerRange(elementOrRange);
-		final ContentRange selectedRange = widget.getSelectedRange();
+		final ContentRange selectedRange = editor.getSelectedRange();
 		return elementContentRange.intersects(selectedRange);
 	}
 
@@ -179,17 +200,17 @@
 	 * Returns the zero-based index of the table column containing the current offset. Returns -1 if we are not inside a
 	 * table.
 	 */
-	public static int getCurrentColumnIndex(final IVexWidget vexWidget) {
+	public static int getCurrentColumnIndex(final IDocumentEditor editor) {
 
-		final IElement row = getCurrentTableRow(vexWidget);
+		final IElement row = getCurrentTableRow(editor);
 
 		if (row == null) {
 			return -1;
 		}
 
-		final ContentPosition offset = vexWidget.getCaretPosition();
+		final ContentPosition offset = editor.getCaretPosition();
 		final int[] column = new int[] { -1 };
-		LayoutUtils.iterateTableCells(vexWidget.getStyleSheet(), row, new ElementOrRangeCallback() {
+		LayoutUtils.iterateTableCells(editor.getTableModel().getStyleSheet(), row, new ElementOrRangeCallback() {
 			private int i = 0;
 
 			@Override
@@ -212,12 +233,12 @@
 	/**
 	 * Returns the innermost Element with style table-row containing the caret, or null if no such element exists.
 	 *
-	 * @param vexWidget
+	 * @param editor
 	 *            IVexWidget to use.
 	 */
-	public static IElement getCurrentTableRow(final IVexWidget vexWidget) {
-		final StyleSheet styleSheet = vexWidget.getStyleSheet();
-		IElement element = vexWidget.getCurrentElement();
+	public static IElement getCurrentTableRow(final IDocumentEditor editor) {
+		final StyleSheet styleSheet = editor.getTableModel().getStyleSheet();
+		IElement element = editor.getCurrentElement();
 
 		while (element != null) {
 			if (styleSheet.getStyles(element).getDisplay().equals(CSS.TABLE_ROW)) {
@@ -233,16 +254,16 @@
 	 * Returns the currently selected table rows, or the current row if ther is no selection. If no row can be found,
 	 * returns an empty array.
 	 *
-	 * @param vexWidget
+	 * @param editor
 	 *            IVexWidget to use.
 	 */
-	public static SelectedRows getSelectedTableRows(final IVexWidget vexWidget) {
+	public static SelectedRows getSelectedTableRows(final IDocumentEditor editor) {
 		final SelectedRows selected = new SelectedRows();
 
-		VexHandlerUtil.iterateTableCells(vexWidget, new TableCellCallbackAdapter() {
+		VexHandlerUtil.iterateTableCells(editor, new TableCellCallbackAdapter() {
 			@Override
 			public void startRow(final Object row, final int rowIndex) {
-				if (VexHandlerUtil.elementOrRangeIsPartiallySelected(vexWidget, row)) {
+				if (VexHandlerUtil.elementOrRangeIsPartiallySelected(editor, row)) {
 					if (selected.rows == null) {
 						selected.rows = new ArrayList<Object>();
 					}
@@ -262,11 +283,11 @@
 		return selected;
 	}
 
-	public static void iterateTableCells(final IVexWidget vexWidget, final ITableCellCallback callback) {
+	public static void iterateTableCells(final IDocumentEditor editor, final ITableCellCallback callback) {
 
-		final StyleSheet ss = vexWidget.getStyleSheet();
+		final StyleSheet ss = editor.getTableModel().getStyleSheet();
 
-		iterateTableRows(vexWidget, new ElementOrPositionRangeCallback() {
+		iterateTableRows(editor, new ElementOrPositionRangeCallback() {
 
 			final private int[] rowIndex = { 0 };
 
@@ -331,19 +352,19 @@
 	 * Returns a RowColumnInfo structure containing information about the table containing the caret. Returns null if
 	 * the caret is not currently inside a table.
 	 *
-	 * @param vexWidget
+	 * @param editor
 	 *            IVexWidget to inspect.
 	 */
-	public static RowColumnInfo getRowColumnInfo(final IVexWidget vexWidget) {
+	public static RowColumnInfo getRowColumnInfo(final IDocumentEditor editor) {
 
 		final boolean[] found = new boolean[1];
 		final RowColumnInfo[] rcInfo = new RowColumnInfo[] { new RowColumnInfo() };
-		final ContentPosition position = vexWidget.getCaretPosition();
+		final ContentPosition position = editor.getCaretPosition();
 
 		rcInfo[0].cellIndex = -1;
 		rcInfo[0].rowIndex = -1;
 
-		iterateTableCells(vexWidget, new ITableCellCallback() {
+		iterateTableCells(editor, new ITableCellCallback() {
 
 			private int rowColumnCount;
 
@@ -386,16 +407,16 @@
 	/**
 	 * Iterate over all rows in the table containing the caret.
 	 *
-	 * @param vexWidget
+	 * @param editor
 	 *            IVexWidget to iterate over.
 	 * @param callback
 	 *            Caller-provided callback that this method calls for each row in the current table.
 	 */
-	public static void iterateTableRows(final IVexWidget vexWidget, final ElementOrPositionRangeCallback callback) {
+	public static void iterateTableRows(final IDocumentEditor editor, final ElementOrPositionRangeCallback callback) {
 
-		final StyleSheet ss = vexWidget.getStyleSheet();
-		final IDocument doc = vexWidget.getDocument();
-		final ContentPosition position = vexWidget.getCaretPosition();
+		final StyleSheet ss = editor.getTableModel().getStyleSheet();
+		final IDocument doc = editor.getDocument();
+		final ContentPosition position = editor.getCaretPosition();
 
 		// This may or may not be a table
 		// In any case, it's the element that contains the top-level table
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditNamespacesHandler.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditNamespacesHandler.java
index 2af777c..77c0f0f 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditNamespacesHandler.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditNamespacesHandler.java
@@ -10,9 +10,12 @@
  *******************************************************************************/
 package org.eclipse.vex.ui.internal.namespace;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.window.Window;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.ui.internal.handlers.AbstractVexWidgetHandler;
 
 /**
@@ -21,11 +24,12 @@
 public class EditNamespacesHandler extends AbstractVexWidgetHandler {
 
 	@Override
-	public void execute(final VexWidget widget) throws ExecutionException {
-		final EditNamespacesController controller = new EditNamespacesController(widget);
-		final EditNamespacesDialog dialog = new EditNamespacesDialog(widget.getShell(), controller);
+	public void execute(final ExecutionEvent event, final IDocumentEditor editor) throws ExecutionException {
+		final Shell shell = HandlerUtil.getActiveShell(event);
+		final EditNamespacesController controller = new EditNamespacesController(editor);
+		final EditNamespacesDialog dialog = new EditNamespacesDialog(shell, controller);
 		if (dialog.open() == Window.OK) {
-			widget.doWork(new Runnable() {
+			editor.doWork(new Runnable() {
 				@Override
 				public void run() {
 					controller.applyToElement();
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/ContentAssist.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/ContentAssist.java
index 6760b94..2923496 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/ContentAssist.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/ContentAssist.java
@@ -52,9 +52,10 @@
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.vex.core.internal.core.ElementName;
-import org.eclipse.vex.core.internal.widget.swt.VexWidget;
+import org.eclipse.vex.core.internal.widget.IDocumentEditor;
 import org.eclipse.vex.core.provisional.dom.ContentPosition;
 import org.eclipse.vex.core.provisional.dom.IElement;
 import org.eclipse.vex.ui.internal.Icon;
@@ -69,7 +70,7 @@
 
 	private static final String SETTINGS_SECTION = "contentAssistant"; //$NON-NLS-1$
 
-	private final VexWidget vexWidget;
+	private final IDocumentEditor editor;
 	private final AbstractVexAction[] actions;
 	private final boolean autoExecute;
 	private final Point location;
@@ -80,32 +81,36 @@
 	/**
 	 * Constructs a new content assist dialog which can be opened by {@link #open()}.
 	 *
-	 * @param vexWidget
+	 * @param parentShell
+	 *            TODO
+	 * @param editor
 	 *            the vex widget this content assist belongs to
 	 * @param actions
 	 *            list of actions to select from
 	 * @param autoExecute
 	 *            if {@code true} and if there is only one action then {@link #open()} does not show dialog but executes
 	 *            the only action
+	 * @param location
+	 *            TODO
 	 */
-	private ContentAssist(final VexWidget vexWidget, final AbstractVexAction[] actions, final boolean autoExecute) {
-		super(vexWidget.getShell(), SWT.RESIZE, true, // take focus on open
+	private ContentAssist(final Shell parentShell, final IDocumentEditor editor, final AbstractVexAction[] actions, final boolean autoExecute, final Point location) {
+		super(parentShell, SWT.RESIZE, true, // take focus on open
 				false, // persist size
 				false, // persist location
 				false, // show dialog menu
 				false, // show persist actions
 				null, // title
 				null); // footer line
-		this.vexWidget = vexWidget;
+		this.editor = editor;
 		this.actions = actions;
 		this.autoExecute = autoExecute;
-		location = vexWidget.toDisplay(vexWidget.getLocationForContentAssist());
+		this.location = location;
 	}
 
 	@Override
 	public int open() {
 		if (autoExecute && actions.length == 1) {
-			actions[0].execute(vexWidget);
+			actions[0].execute(editor);
 			return Window.OK;
 		}
 		return super.open();
@@ -212,7 +217,7 @@
 		if (selection instanceof StructuredSelection) {
 			final Object first = ((StructuredSelection) selection).getFirstElement();
 			if (first instanceof AbstractVexAction) {
-				((AbstractVexAction) first).execute(vexWidget);
+				((AbstractVexAction) first).execute(editor);
 			}
 		}
 		close();
@@ -283,22 +288,22 @@
 
 	private static abstract class AbstractVexAction {
 
-		private final VexWidget widget;
+		private final IDocumentEditor editor;
 		private final ElementName elementName;
 		private final String text;
 		private final Icon image;
 
-		public AbstractVexAction(final VexWidget widget, final ElementName elementName, final String text, final Icon image) {
-			this.widget = widget;
+		public AbstractVexAction(final IDocumentEditor editor, final ElementName elementName, final String text, final Icon image) {
+			this.editor = editor;
 			this.elementName = elementName;
 			this.text = text;
 			this.image = image;
 		}
 
-		abstract void execute(VexWidget vexWidget);
+		abstract void execute(IDocumentEditor editor);
 
-		public VexWidget getWidget() {
-			return widget;
+		public IDocumentEditor getEditor() {
+			return editor;
 		}
 
 		public ElementName getElementName() {
@@ -318,57 +323,65 @@
 	/**
 	 * Shows the content assist to add a new element.
 	 *
-	 * @param widget
+	 * @param parentShell
+	 *            TODO
+	 * @param editor
 	 *            the VexWidget which hosts the content assist
+	 * @param location
+	 *            TODO
 	 */
-	public static void openAddElementsContentAssist(final VexWidget widget) {
-		final AbstractVexAction[] addActions = computeAddElementsActions(widget);
-		final ContentAssist assist = new ContentAssist(widget, addActions, true);
+	public static void openAddElementsContentAssist(final Shell parentShell, final IDocumentEditor editor, final Point location) {
+		final AbstractVexAction[] addActions = computeAddElementsActions(editor);
+		final ContentAssist assist = new ContentAssist(parentShell, editor, addActions, true, location);
 		assist.open();
 	}
 
 	/**
 	 * Shows the content assist to convert current element.
-	 *
-	 * @param widget
+	 * 
+	 * @param parentShell
+	 *            TODO
+	 * @param editor
 	 *            the VexWidget which hosts the content assist
+	 * @param location
+	 *            TODO
 	 */
-	public static void openQuickFixContentAssist(final VexWidget widget) {
-		final AbstractVexAction[] quickFixActions = computeQuickFixActions(widget);
-		final ContentAssist assist = new ContentAssist(widget, quickFixActions, true);
+	public static void openQuickFixContentAssist(final Shell parentShell, final IDocumentEditor editor, final Point location) {
+		final AbstractVexAction[] quickFixActions = computeQuickFixActions(editor);
+		final ContentAssist assist = new ContentAssist(parentShell, editor, quickFixActions, true, location);
 		assist.open();
 	}
 
-	private static AbstractVexAction[] computeAddElementsActions(final VexWidget widget) {
-		final ElementName[] names = widget.getValidInsertElements();
+	private static AbstractVexAction[] computeAddElementsActions(final IDocumentEditor editor) {
+		final ElementName[] names = editor.getValidInsertElements();
 		final AbstractVexAction[] actions = new AbstractVexAction[names.length];
 		for (int i = 0; i < names.length; i++) {
 			final QualifiedName qualifiedName = names[i].getQualifiedName();
-			actions[i] = new AbstractVexAction(widget, names[i], names[i].toString(), Icon.ELEMENT) {
+			actions[i] = new AbstractVexAction(editor, names[i], names[i].toString(), Icon.ELEMENT) {
 				@Override
-				public void execute(final VexWidget vexWidget) {
-					getWidget().insertElement(qualifiedName);
+				public void execute(final IDocumentEditor editor) {
+					getEditor().insertElement(qualifiedName);
 				}
 			};
 		}
 		return actions;
 	}
 
-	private static AbstractVexAction[] computeQuickFixActions(final VexWidget widget) {
-		final ElementName[] names = widget.getValidMorphElements();
+	private static AbstractVexAction[] computeQuickFixActions(final IDocumentEditor editor) {
+		final ElementName[] names = editor.getValidMorphElements();
 		final AbstractVexAction[] actions = new AbstractVexAction[names.length];
-		final ContentPosition caretPosition = widget.getCaretPosition();
-		final IElement element = widget.getDocument().getElementForInsertionAt(caretPosition.getOffset());
+		final ContentPosition caretPosition = editor.getCaretPosition();
+		final IElement element = editor.getDocument().getElementForInsertionAt(caretPosition.getOffset());
 		final String sourceName = element.getPrefixedName();
 		for (int i = 0; i < names.length; i++) {
 			final QualifiedName qualifiedName = names[i].getQualifiedName();
 			final String message = Messages.getString("command.convertElement.dynamicCommandName"); //$NON-NLS-1$
 			final String text = MessageFormat.format(message, sourceName, names[i]);
 			final Icon icon = Icon.CONVERT;
-			actions[i] = new AbstractVexAction(widget, names[i], text, icon) {
+			actions[i] = new AbstractVexAction(editor, names[i], text, icon) {
 				@Override
-				public void execute(final VexWidget vexWidget) {
-					getWidget().morph(qualifiedName);
+				public void execute(final IDocumentEditor editor) {
+					getEditor().morph(qualifiedName);
 				}
 			};
 		}