final int caret= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
final int caret, length; Point selection= viewer.getSelectedRange(); if (selection.y != 0) { caret= selection.x; length= selection.y; } else { caret= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()); length= position - caret; }
		protected void setCaretPosition(final int position) {			if (!validateEditorInputState())				return;						final ISourceViewer viewer= getSourceViewer();			final int caret= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());			try {				viewer.getDocument().replace(caret, position - caret, ""); //$NON-NLS-1$			} catch (BadLocationException exception) {				// Should not happen			}		}