Bug 11833 NegativeArraySizeException in code formatter/style pref page
20020319 enter -1 as number of spaces representing a tab java.lang.NegativeArraySizeException at java.lang.StringBuffer.<init>(StringBuffer.java(Compiled Code)) at org.eclipse.swt.custom.StyledText.calculateTabWidth (StyledText.java:1386) at org.eclipse.swt.custom.StyledText.setTabs(StyledText.java:7293) at org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage.textChanged (CodeFormatterPreferencePage.java:408) at org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage.access$1 (CodeFormatterPreferencePage.java:400) at org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage$2.modifyText (CodeFormatterPreferencePage.java:218) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:179) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Text.wmCommandChild(Text.java:1751) at org.eclipse.swt.widgets.Control.WM_COMMAND(Control.java:2786) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java(Compiled Code)) at org.eclipse.swt.widgets.Text.callWindowProc(Text.java:85) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:525) at org.eclipse.ui.internal.OpenPreferencesAction.run (OpenPreferencesAction.java:47) at org.eclipse.jface.action.Action.runWithEvent(Action.java:473) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:698) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:196) at org.eclipse.core.launcher.Main.run(Main.java:555) at org.eclipse.core.launcher.Main.main(Main.java:396)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeFormatterPreferencePage.java
for (int i= 0; i < fValues.length; i++) {
				if (value.equals(fValues[i])) {
					return i;
				}
			}
			throw new IllegalArgumentException();
		}
	}
	
	private Hashtable fWorkingValues;
	private ArrayList fCheckBoxes;
	private ArrayList fTextBoxes;
	
	private SelectionListener fButtonSelectionListener;
	private ModifyListener fTextModifyListener;
	
	private String fPreviewText;
	private IDocument fPreviewDocument;
	
	private Text fTabSizeTextBox;
	private SourceViewer fSourceViewer;
	
	public CodeFormatterPreferencePage() {
		setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
		setDescription(JavaUIMessages.getString("CodeFormatterPreferencePage.description")); 
	
		fWorkingValues= JavaCore.getOptions();
		fCheckBoxes= new ArrayList();
		fTextBoxes= new ArrayList();