Bug 51541 NPE restoring scrapbook editor
build I20040210-0800 plus latest UI and Text from HEAD When running my target eclipse, I got an error restoring a scrapbook editor that had been saved during the previous session. The log has the following. The line in question is: StyledText styledText= fSourceViewer.getTextWidget(); *** int caret= widgetOffset2ModelOffset(fSourceViewer, styledText.getCaretOffset()); !ENTRY org.eclipse.core.runtime 4 2 Feb 10, 2004 15:49:26.780 !MESSAGE Problems occurred when invoking code from plug- in: "org.eclipse.core.runtime". !STACK 0 java.lang.NullPointerException at org.eclipse.ui.texteditor.AbstractTextEditor.getCursorPosition (AbstractTextEditor.java:4399) at org.eclipse.ui.texteditor.AbstractTextEditor.updateStatusField (AbstractTextEditor.java:4357) at org.eclipse.ui.texteditor.AbstractTextEditor.setStatusField (AbstractTextEditor.java:4104) at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.doSetActiveEditor (BasicTextEditorActionContributor.java:215) at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.setActiveEditor (BasicTextEditorActionContributor.java:229) at org.eclipse.jdt.internal.ui.javaeditor.BasicJavaEditorActionContributor.setActiv eEditor(BasicJavaEditorActionContributor.java:187) at org.eclipse.jdt.internal.ui.javaeditor.BasicEditorActionContributor.setActiveEdi tor(BasicEditorActionContributor.java:83) at org.eclipse.jdt.internal.debug.ui.snippeteditor.SnippetEditorActionContributor.s etActiveEditor(SnippetEditorActionContributor.java:74) at org.eclipse.ui.internal.EditorActionBars.partChanged (EditorActionBars.java:291) at org.eclipse.ui.internal.WorkbenchPage$2.run(WorkbenchPage.java:474) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:819) at org.eclipse.core.runtime.Platform.run(Platform.java:493) at org.eclipse.ui.internal.WorkbenchPage.activatePart (WorkbenchPage.java:466) at org.eclipse.ui.internal.WorkbenchPage.onActivate (WorkbenchPage.java:1953) at org.eclipse.ui.internal.WorkbenchWindow$6.run (WorkbenchWindow.java:1824) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:84) at org.eclipse.ui.internal.WorkbenchWindow.setActivePage (WorkbenchWindow.java:1811) at org.eclipse.ui.internal.WorkbenchWindow.restoreState (WorkbenchWindow.java:1406) at org.eclipse.ui.internal.Workbench.restoreState(Workbench.java:1369) at org.eclipse.ui.internal.Workbench.access$8(Workbench.java:1337) at org.eclipse.ui.internal.Workbench$11.run(Workbench.java:1259) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:819) at org.eclipse.core.runtime.Platform.run(Platform.java:493) at org.eclipse.ui.internal.Workbench.openPreviousWorkbenchState (Workbench.java:1215) at org.eclipse.ui.internal.Workbench.init(Workbench.java:894) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1503) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/SpellReconcileStrategy.java
fPartitioning= partitioning;
		fPreferences= store;
		final IAnnotationModel model= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
		Assert.isLegal(model instanceof IProblemRequestor);
		fRequestor= (IProblemRequestor)model;
	}
	/**
	 * Returns the current locale of the spell checking preferences.
	 * 
	 * @return The current locale of the spell checking preferences
	 */
	public Locale getLocale() {
		final String locale= fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_LOCALE);
		if (locale.equals(fLocale.toString()))
			return fLocale;
		if (locale.length() >= 5)
			return new Locale(locale.substring(0, 2), locale.substring(3, 5));
		return SpellCheckEngine.getDefaultLocale();
	}
	/*
	 * @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEventListener#handle(org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent)
	 */
	public void handle(final ISpellEvent event) {
		final SpellProblem problem= new SpellProblem(event.getWord());
		problem.setSourceStart(event.getBegin());
		problem.setSourceEnd(event.getEnd());
		problem.setSentenceStart(event.isStart());
		problem.setDictionaryMatch(event.isMatch());
		try {
			problem.setSourceLineNumber(fDocument.getLineOfOffset(event.getBegin()) + 1);