Bug 82394 [preferences][templates] NPE trying to edit code templates
build i0104-1600 I went into my preferences and tried to change my code template for a new Java file (change the copyright to be 2005 now) but clicking on the Edit button did nothing. When I checked my log file, I found the following exception: !ENTRY org.eclipse.ui 4 0 2005-01-07 13:36:38.677 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog.getPrefix(Unknown Source) at org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog.createEditor(Unknown Source) at org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog.createDialogArea(Unknown Source) at org.eclipse.jface.dialogs.Dialog.createContents(Unknown Source) at org.eclipse.jface.window.Window.create(Unknown Source) at org.eclipse.jface.dialogs.Dialog.create(Unknown Source) at org.eclipse.jdt.internal.ui.dialogs.StatusDialog.create(Unknown Source) at org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog.create(Unknown Source) at org.eclipse.jface.window.Window.open(Unknown Source) at org.eclipse.jdt.internal.ui.preferences.CodeTemplateBlock.edit(Unknown Source) at org.eclipse.jdt.internal.ui.preferences.CodeTemplateBlock.doButtonPressed(Unknown Source) at org.eclipse.jdt.internal.ui.preferences.CodeTemplateBlock$CodeTemplateAdapter.customButtonPressed(Unknown Source) at org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField.buttonPressed(Unknown Source) at org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField.doButtonSelected(Unknown Source) at org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField.access$2(Unknown Source) at org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField$2.widgetSelected(Unknown Source) at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source) at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at org.eclipse.jface.window.Window.runEventLoop(Unknown Source) at org.eclipse.jface.window.Window.open(Unknown Source) at org.eclipse.ui.internal.OpenPreferencesAction.run(Unknown Source) at org.eclipse.jface.action.Action.runWithEvent(Unknown Source) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(Unknown Source) at org.eclipse.jface.action.ActionContributionItem.access$2(Unknown Source) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(Unknown Source) at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source) at org.eclipse.ui.internal.Workbench.runUI(Unknown Source) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Unknown Source) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Unknown Source) at org.eclipse.ui.internal.ide.IDEApplication.run(Unknown Source) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Unknown Source) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:684)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/EditTemplateDialog.java
private static Text createText(Composite parent) {
		Text text= new Text(parent, SWT.BORDER);
		text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));		
		
		return text;
	}
	private SourceViewer createEditor(Composite parent) {
		String prefix= getPrefix();
		IDocument document= new Document(prefix + fTemplate.getPattern());
		JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
		tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
		IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
		SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
		TemplateEditorSourceViewerConfiguration configuration= new TemplateEditorSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
		viewer.configure(configuration);
		viewer.setEditable(true);
		viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length());
		
		Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
		viewer.getTextWidget().setFont(font);
		new JavaSourcePreviewerUpdater(viewer, configuration, store);
		
		int nLines= document.getNumberOfLines();
		if (nLines < 5) {
			nLines= 5;
		} else if (nLines > 12) {
			nLines= 12;	
		}
				
		Control control= viewer.getControl();