private Map<Object, Point> restoreLocations = new HashMap<Object, Point>();
@Override
public void partClosed(IWorkbenchPart part) {
if (part instanceof ITextEditor && part instanceof IEditorPart) {
IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
if (editorInput instanceof IURIEditorInput) {
ITextSelection selection = (ITextSelection) ((ITextEditor)part).getSelectionProvider().getSelection();
restoreLocations.put(((IURIEditorInput) editorInput).getURI(), new Point(selection.getOffset(), selection.getLength()));
}
}
}
@Override
public void partOpened(IWorkbenchPart part) {
if (part instanceof ITextEditor && part instanceof IEditorPart) {
IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
if (editorInput instanceof IURIEditorInput) {
ITextEditor textEditor = (ITextEditor)part;
Point point = restoreLocations.get(((IURIEditorInput) editorInput).getURI());
if (point != null) {
textEditor.selectAndReveal(point.x, point.y);
}
}
}
}