| Summary: | [Preferences] PreferencePage contents cannot contain a Composite with a FormLayout | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Rod Bailey <rbailey> | ||||||
| Component: | UI | Assignee: | Platform UI Triaged <platform-ui-triaged> | ||||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P5 | Keywords: | helpwanted | ||||||
| Version: | 3.1 | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | stalebug | ||||||||
| Attachments: |
|
||||||||
Created attachment 18155 [details]
Error dialog produced by the test code below
Created attachment 18156 [details]
What it looks like when it works (with the problematic four lines commented out)
Is there anything of note in your log file? I can't see any log files in my eclipse installation directory or workspace. Where should the log file be, and is there something special I have to do to turn logging on? It is in the .metadata directory under your install Found it. There's nothing in the log file relating to this bug. Below is the stack trace, in case it helps: ----8<---- java.lang.ClassCastException at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:250) at org.eclipse.swt.layout.FormLayout.computeSize(FormLayout.java:198) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:110) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.jface.preference.PreferencePage.doComputeSize (PreferencePage.java:544) at org.eclipse.jface.preference.PreferencePage.computeSize (PreferencePage.java:332) at org.eclipse.jface.preference.PreferenceDialog$14.run (PreferenceDialog.java:1145) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:616) at org.eclipse.core.runtime.Platform.run(Platform.java:747) at org.eclipse.jface.preference.PreferenceDialog.showPage (PreferenceDialog.java:1139) at org.eclipse.jface.preference.PreferenceDialog$9.selectionChanged (PreferenceDialog.java:628) at org.eclipse.jface.viewers.StructuredViewer$3.run (StructuredViewer.java:681) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:616) at org.eclipse.core.runtime.Platform.run(Platform.java:747) at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged (StructuredViewer.java:679) at org.eclipse.jface.viewers.StructuredViewer.setSelection (StructuredViewer.java:1350) at org.eclipse.jface.preference.PreferenceDialog.selectSavedItem (PreferenceDialog.java:912) at org.eclipse.jface.preference.PreferenceDialog$3.run (PreferenceDialog.java:335) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:69) at org.eclipse.jface.preference.PreferenceDialog.createContents (PreferenceDialog.java:331) at org.eclipse.jface.window.Window.create(Window.java:375) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:983) at org.eclipse.jface.window.Window.open(Window.java:685) at test.PreferenceLayoutBugDemo.main(PreferenceLayoutBugDemo.java:32) java.lang.ClassCastException at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:250) at org.eclipse.swt.layout.FormLayout.computeSize(FormLayout.java:198) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:110) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.jface.preference.PreferenceDialog$PageLayout.computeSize (PreferenceDialog.java:95) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.swt.layout.GridData.computeSize(GridData.java:450) at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:197) at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:155) at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:207) at org.eclipse.jface.window.Window.getInitialSize(Window.java:532) at org.eclipse.jface.window.Window.initializeBounds(Window.java:660) at org.eclipse.jface.dialogs.Dialog.initializeBounds(Dialog.java:630) at org.eclipse.jface.window.Window.create(Window.java:379) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:983) at org.eclipse.jface.window.Window.open(Window.java:685) at test.PreferenceLayoutBugDemo.main(PreferenceLayoutBugDemo.java:32) -----8<----- There are currently no plans to work on this although we would be happy to review a patch This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
I'm writing a custom PreferencePage. Part of the PreferencePage is a Composite subclass that has a FormLayout. Opening a PreferenceDialog containing only this PreferencePage results in an error dialog saying "The currently displayed page contains invalid values" (see attachment #1 [details]). The code below demonstrates this happening. Note that if you comment out the four lines in the MyComposite constructor, it works OK. It seems that the PreferencePage is assuming that GridLayouts are used "all the way down" the widget containment hierarchy, which is not true in this case. Using SWT3.1M4 -----8<------ import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.PreferenceManager; import org.eclipse.jface.preference.PreferenceNode; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class PreferenceLayoutBugDemo { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); PreferenceLayoutBugDemo demo = new PreferenceLayoutBugDemo(); PreferenceNode node1 = new PreferenceNode("node1", demo.new PreferencePageOne()); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(node1); PreferenceDialog dlg = new PreferenceDialog(shell, mgr); dlg.setBlockOnOpen(true); shell.open(); dlg.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } public class PreferencePageOne extends PreferencePage { public PreferencePageOne() { super("Page One"); } protected Control createContents(Composite parent) { Composite contents = new Composite(parent, SWT.NONE); contents.setLayout(new FillLayout()); new MyComposite(contents, SWT.NONE); return contents; } public boolean isValid() { return true; } } public class MyComposite extends Composite { public MyComposite(Composite parent, int style) { super(parent, style); this.setLayout(new FormLayout()); Text dateText = new Text(this, SWT.BORDER); // Comment out the following four lines and it works. // Otherwise the error "The currently displayed page contains // invalid values" appears. FormData dateTextFD = new FormData(); dateTextFD.top = new FormAttachment(0); dateTextFD.left = new FormAttachment(0); dateText.setLayoutData(dateText); } } } ------8<-----