Bug adding JFace dialog button

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Bug adding JFace dialog button

Postby jnorris » Tue Aug 23, 2005 5:47 am

I've had some problems when trying to add a JFace button to a dialog. The button is added as 'x = createButton(...)' in the 'createButtonsForButtonBar()' method. In some cases, switching to design view does not show the button. After deleting the 'Button x =' the button appears in the design view as expected. This is an inconsistent problem. In all cases when adding the text for the button in the important properties dialog, the text shown on the button in the design view is always still 'OK'. Changing the text for the button in the properties editor causes the text in the button to change. However, switching to source view shows that the text is incorrectly inserted. The resulting code looks like this:
Code: Select all
Button myButton = createButton(parent, Idialo"My Button"Constants.OK_LABEL,false);

Now if I use undo to go back to the original code, the button will no longer be visible in the design view and does not show up in the property editor unless the 'Button x =' part of the statement is deleted.

After playing around a bit, it appears that the problem occurs unless the id is changed in the property editor before changing the text for the button. Once that is done, changing the text doesn't mess up the code. The important properties dialog when creating the button does not include the ID. Changing the text in this dialog results in 'myButton.setText ("...");' after the line where the button is created instead of in the 'createButton()' method.
jnorris
 
Posts: 17
Joined: Tue Jul 27, 2004 5:10 am

Re: Bug adding JFace dialog button

Postby Eric Clayberg » Wed Aug 24, 2005 1:33 pm

jnorris wrote:After playing around a bit, it appears that the problem occurs unless the id is changed in the property editor before changing the text for the button. Once that is done, changing the text doesn't mess up the code. The important properties dialog when creating the button does not include the ID. Changing the text in this dialog results in 'myButton.setText ("...");' after the line where the button is created instead of in the 'createButton()' method.

The problem was that the important properties dialog was not supposed to appear when creating dialog buttons. Dialog buttons have their own special code generation requirements that aren't compatible with that dialog.

This problem has been fixed in the latest v4.1.1 build.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

similar problem with 4.2.1

Postby elz_dad » Mon Feb 27, 2006 3:54 am

I created a "new JFace Dialog" using the wizard. At the top of the resulting class, I added:

Code: Select all
    private org.eclipse.swt.widgets.Button okButton;


then in the "createButtonsForButtonBar(Composite parent)" method I changed the statement to read:
Code: Select all
   okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
      true);


Now when I click on the "Design" tab, I only see the "Cancel" button. If remove the "okButton =" bit from the function, then go back to "Design", I see the OK button again.

I have WindowBuilder Pro
Version: 4.2.1
Build id: 2006.01.05
elz_dad
 
Posts: 11
Joined: Fri May 06, 2005 2:40 am

Re: similar problem with 4.2.1

Postby Eric Clayberg » Mon Feb 27, 2006 7:49 pm

elz_dad wrote:I have WindowBuilder Pro
Version: 4.2.1
Build id: 2006.01.05

Try this again with the latest v4.2.1 build.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby elz_dad » Tue Feb 28, 2006 7:06 am

Hi,

Thanks - downloading 4.2.1 has fixed the problem. I think it may still have some debugging code in there though: I see the following output on my console (a new line every time I open a dialog box and click on the "Design" tab):

parse time: 762
parse time: 80
parse time: 206
parse time: 160

nick
elz_dad
 
Posts: 11
Joined: Fri May 06, 2005 2:40 am

Postby Eric Clayberg » Tue Feb 28, 2006 8:20 pm

elz_dad wrote:downloading 4.2.1 has fixed the problem. I think it may still have some debugging code in there though

That has been in the product for a long time (intentionally).

If you want to turn it off, the latest v4.2.1 build includes a Designer > General > Show Debug Info in Console preference.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby Branden_Moore » Mon Jul 10, 2006 11:16 am

There appears to be another bug with Buttons and JFace dialogs.

I'm running WB Pro 5.0.0 on Eclipse 3.1.2.

When I create a JFace TitleAreaDialog, and create a button via code such as:
Code: Select all
createButton(container, 900, "Hello, World", false);

The 'Design' view will show the button in the Button Bar at the bottom, rather than as a part of the 'container' composite. When running the dialog normally, the button will appear in the correct location.

I have a feeling that there is a slightly deeper problem here as well. On one of my dialogs that I have been working on, SWT Designer will throw an NPE when I attempt to switch to the 'Design' view. Below is the Stacktrace of the NPE:

Code: Select all
Message: Designer internal error [5.0.0.2006.06.12]: java.lang.NullPointerException
java.lang.NullPointerException
   at com.swtdesigner.model.JavaInfo.doAcceptAsParent(JavaInfo.java:970)
   at com.swtdesigner.model.swt.jface.AbstractDialogInfo.acceptAsChild(AbstractDialogInfo.java:111)
   at com.swtdesigner.model.parser.JavaInfoParser.isParentAndChild(JavaInfoParser.java:935)
   at com.swtdesigner.model.parser.JavaInfoParser.findParentFor(JavaInfoParser.java:847)
   at com.swtdesigner.model.parser.JavaInfoParser.getRootNodes(JavaInfoParser.java:410)
   at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:992)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:927)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:910)
   at com.swtdesigner.editors.MultiPageEditor.showDesignEditor(MultiPageEditor.java:388)
   at com.swtdesigner.editors.MultiPageEditor$2.widgetSelected(MultiPageEditor.java:174)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
   at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:660)
   at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3138)
   at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1922)
   at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:288)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
   at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
   at org.eclipse.core.launcher.Main.run(Main.java:973)
   at org.eclipse.core.launcher.Main.main(Main.java:948)
Branden_Moore
 
Posts: 2
Joined: Mon Jul 10, 2006 11:03 am

Postby Eric Clayberg » Mon Jul 10, 2006 2:22 pm

Branden_Moore wrote:There appears to be another bug with Buttons and JFace dialogs.

This is more of a missing feature than a bug. Currently, Designer only supports adding dialog buttons to a dialog's button bar.

We will investigate whether we can support adding dialog buttons elsewhere in the window.

In the mean time, you can always add a regular button in the dialog's client area.

Branden_Moore wrote:I have a feeling that there is a slightly deeper problem here as well.

From our POV, it isn't a deep problem at all. ;-) Designer simply does not support dialog buttons anywhere other than the button bar.

Branden_Moore wrote:On one of my dialogs that I have been working on, SWT Designer will throw an NPE when I attempt to switch to the 'Design' view. Below is the Stacktrace of the NPE

In order to help, we need to see a test case (ideally the dialog you are editing) and your complete Eclipse ".log" file.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby Branden_Moore » Wed Jul 12, 2006 4:25 am

So I take it then that Designer does not bother digging into source beyond the initial CompilationUnit? The 'createButton()' method in org.eclipse.jface.Dialog does nothing fancy. I suppose this would explain also why you override createButtonsForButtonBar() with a method that is exactly the same as that which it is overriding.

As for the code associated with the Designer NPE, I do not have the authority to hand that code out, sorry. I'm not too worried about that though. If Designer cannot lay out the dialog that I am working on correctly, then it has lost 99% of its usefulness for that dialog. I feel that for my use, calling 'createButton()' to create a button that is the "right size" and uses the correct font, etc, along with hooking in to a consistent mechanism for feedback is more important that being able to WYSIWYG the dialog that is almost complete.

But thanks, anyway.
Branden_Moore
 
Posts: 2
Joined: Mon Jul 10, 2006 11:03 am

Postby Eric Clayberg » Wed Jul 12, 2006 8:11 am

Branden_Moore wrote:So I take it then that Designer does not bother digging into source beyond the initial CompilationUnit?

I'm not sure what you mean here. If you are refering to parsing, Designer generally only parses the current class your are editing (it will also parse NLS helper classes). Information about superclasses, custom widget, etc. is derived from bean info and reflection. Designer also has built-in knowledge about various Eclipse framework classes (like JFace Dialogs, ViewParts, EditorParts, ActionBarAdvisors, Perspectives, etc.) to allow it to create and display subclasses.

Branden_Moore wrote:The 'createButton()' method in org.eclipse.jface.Dialog does nothing fancy.

From a GUI builders POV, it is quite "fancy" as it is a specialized factory method only used in the context of JFace dialogs. It does not follow the normal pattern for SWT widget creation, so Designer builds in special knowledge about how to use it in the context of creating buttons for the Dialog's button bar.

You are the first person in three years who has asked for support for Dialog Buttons outside of the context of the dialog button bar. As I said earlier, we are looking into adding support for this.

Branden_Moore wrote:I suppose this would explain also why you override createButtonsForButtonBar() with a method that is exactly the same as that which it is overriding.

We create a createButtonsForButtonBar() in order to make it easy to add new dialog buttons into the list and to make it easy to override the default values in the superclass. If you don't intend to modify the button bar, you can remove that method and Designer won't care.

Branden_Moore wrote:As for the code associated with the Designer NPE, I do not have the authority to hand that code out, sorry.

If not that code, a reasonable approximation that exhibits the same problem would be fine as well. If we can reproduce the problem, we can probably do something about it.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest