public class StructuredSelectHistoryHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
SelectionHistory history = (SelectionHistory) editor.getAdapter(SelectionHistory.class);
if (history != null) {
IRegion old = history.getLast();
if (old != null) {
try {
history.ignoreSelectionChanges();
ITextEditor textEditor = null;
if (editor instanceof ITextEditor)
textEditor = (ITextEditor) editor;
else {
Object o = editor.getAdapter(ITextEditor.class);
if (o != null)
textEditor = (ITextEditor) o;
}
if (textEditor != null)
textEditor.selectAndReveal(old.getOffset(), old.getLength());
}
finally {
history.listenToSelectionChanges();
}
}
}
return null;
}