* @param input the input to be set
* @exception CoreException if input cannot be connected to the document
* provider
*/
protected void doSetInput(IEditorInput input) throws CoreException {
ISaveablesLifecycleListener listener= (ISaveablesLifecycleListener)getSite().getService(ISaveablesLifecycleListener.class);
if (listener == null)
fSavable= null;
if (input == null) {
close(isSaveOnCloseNeeded());
if (fSavable != null) {
listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, SaveablesLifecycleEvent.POST_CLOSE, getSaveables(), false));
fSavable.disconnectEditor();
fSavable= null;
}
} else {
boolean mustSendLifeCycleEvent= false;
if (fSavable != null) {
listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, SaveablesLifecycleEvent.POST_CLOSE, getSaveables(), false));
fSavable.disconnectEditor();
fSavable= null;
mustSendLifeCycleEvent= true;
}
IEditorInput oldInput= getEditorInput();
if (oldInput != null)
getDocumentProvider().disconnect(oldInput);
super.setInput(input);
updateDocumentProvider(input);
IDocumentProvider provider= getDocumentProvider();
if (provider == null) {
IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, EditorMessages.Editor_error_no_provider, null);
throw new CoreException(s);
}
provider.connect(input);
initializeTitle(input);
if (fSourceViewer != null) {
initializeSourceViewer(input);
// Reset the undo context for the undo and redo action handlers
IAction undoAction= getAction(ITextEditorActionConstants.UNDO);
IAction redoAction= getAction(ITextEditorActionConstants.REDO);
boolean areOperationActionHandlersInstalled= undoAction instanceof OperationHistoryActionHandler && redoAction instanceof OperationHistoryActionHandler;
IUndoContext undoContext= getUndoContext();
if (undoContext != null && areOperationActionHandlersInstalled) {
((OperationHistoryActionHandler)undoAction).setContext(undoContext);
((OperationHistoryActionHandler)redoAction).setContext(undoContext);
} else {
createUndoRedoActions();
}
}
if (fIsOverwriting)
toggleOverwriteMode();
setInsertMode((InsertMode) getLegalInsertModes().get(0));
updateCaret();
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
if (fSelectionListener != null)
fSelectionListener.setDocument(getDocumentProvider().getDocument(input));
IVerticalRuler ruler= getVerticalRuler();
if (ruler instanceof CompositeRuler)
updateContributedRulerColumns((CompositeRuler) ruler);
// Send savable life-cycle if needed.
if (mustSendLifeCycleEvent && listener != null)
listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, SaveablesLifecycleEvent.POST_OPEN, getSaveables(), false));
}
}