Bug 47971 java formatter preferences: IllegalArgumentException when opening new formatter page
I20031202 0. Have old formatter preferences specifying to use spaces instead of tabs 1. Create a new formatting style based on "Java Conventions" 2. Set Indentation -> Use Tab character 3. Format some code so its indentation gets changed -> Note that spaces get inserted instead of tabs 4. Go to the Preferences, Java->Code Formatter -> IllegalArgumentException, stack trace below !ENTRY org.eclipse.jface 4 2 Dec 03, 2003 11:53:48.224 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface". !STACK 0 java.lang.IllegalArgumentException at org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock$ControlData.getSelection(OptionsConfigurationBlock.java:83) at org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.addCheckBox(OptionsConfigurationBlock.java:172) at org.eclipse.jdt.internal.ui.preferences.CodeFormatterConfigurationBlock.createContents(CodeFormatterConfigurationBlock.java:210) at org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage.createContents(CodeFormatterPreferencePage.java:96) at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:217) at org.eclipse.jdt.internal.ui.preferences.CodeFormatterPreferencePage.createControl(CodeFormatterPreferencePage.java:84) at org.eclipse.jface.preference.PreferenceDialog$12.run(PreferenceDialog.java:986) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:824) at org.eclipse.core.runtime.Platform.run(Platform.java:479) at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:984) at org.eclipse.jface.preference.PreferenceDialog.selectSavedItem(PreferenceDialog.java:670) at org.eclipse.jface.preference.PreferenceDialog$3.run(PreferenceDialog.java:297) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:84) at org.eclipse.jface.preference.PreferenceDialog.createContents(PreferenceDialog.java:292) at org.eclipse.jface.window.Window.create(Window.java:305) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:883) at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:70) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:535) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:487) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:459) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:967) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1839) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1619) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1486) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1462) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:242) 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.applicationrunner.ApplicationRunnerActivator$1.run(ApplicationRunnerActivator.java:85) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:87) 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.internal.boot.OSGiBootLoader.basicRun(OSGiBootLoader.java:239) at org.eclipse.core.internal.boot.OSGiBootLoader.run(OSGiBootLoader.java:665) at org.eclipse.core.internal.boot.OSGiBootLoader.run(OSGiBootLoader.java:652) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java
private final int numColumns= 4; 
	
	public IndentationTabPage(Map workingValues) {
		super(workingValues);
		fJavaPreview.setPreviewText(PREVIEW);
	}
	protected Composite doCreatePreferences(Composite parent) {
		final Composite composite= new Composite(parent, SWT.NONE);
		composite.setLayout(createGridLayout(numColumns, false));
		final Group generalGroup= createGroup(numColumns, composite, "General settings");
		createNumberPref(generalGroup, numColumns, "Tab si&ze:", DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, Integer.MAX_VALUE);
		createNumberPref(generalGroup, numColumns, "Initi&al indentation level:", DefaultCodeFormatterConstants.FORMATTER_INITIAL_INDENTATION_LEVEL, 0, Integer.MAX_VALUE);
		createNumberPref(generalGroup, numColumns, "De&fault indentation for wrapped lines:", DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, Integer.MAX_VALUE);
		createCheckboxPref(generalGroup, numColumns, "U&se tab character", DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, falseTrue);
		
		final Group classGroup = createGroup(numColumns, composite, "Class body");
		createCheckboxPref(classGroup, numColumns, "Indent de&clarations within class body", DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, falseTrue);
		final Group blockGroup= createGroup(numColumns, composite, "Block body");
		createCheckboxPref(blockGroup, numColumns, "Indent statements wit&hin blocks and methods", DefaultCodeFormatterConstants.FORMATTER_INDENT_BLOCK_STATEMENTS, falseTrue);
		
		final Group switchGroup= createGroup(numColumns, composite, "Switch statement");
		createCheckboxPref(switchGroup, numColumns, "Indent statements within 's&witch' body", DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, falseTrue);
		createCheckboxPref(switchGroup, numColumns, "Indent statements within 'case' bod&y", DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, falseTrue);
		createCheckboxPref(switchGroup, numColumns, "Indent 'brea&k' statements", DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, falseTrue);
		
		return composite;
	}
}