Bidirectionality

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

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

Bidirectionality

Postby waimea » Fri Jun 05, 2009 7:33 am

Hi,

Is Swing Designer fully bidirectional?
I find Swing Designer great for building GUI components.
But I'm finding it very fragile when I need to manually tweak the code generated.
When I want to go back into Design mode after tweaking the code I often get an Exception and then an Error window saying:

No GUI roots detected.
Designer was unable to find any GUI elements in your source


In one example when this happended, the tweaking I did was quite minimal: I just added a few lines to the constructor of the frame that I had created with Designer to get the values of a jcombo box from a database. The program compiled and run perfectly. The problem was when I wanted to get back to the Design mode to add a component.
The exact error message I got was:

Code: Select all
Stack trace:
java.lang.NullPointerException
   at com.swtdesigner.model.swing.layouts.managers.group.layout.GroupLayoutHelper.convertAlignment(GroupLayoutHelper.java:27)
   at com.swtdesigner.model.swing.layouts.managers.group.GroupLayoutInfo$GroupLayoutParserVisitor.endVisit(GroupLayoutInfo.java:1496)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:246)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:239)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:244)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
   at com.swtdesigner.model.swing.layouts.managers.group.GroupLayoutInfo.treeBuildingComplete(GroupLayoutInfo.java:1181)
   at com.swtdesigner.model.JavaInfo.treeBuildingComplete(JavaInfo.java:877)
   at com.swtdesigner.model.swing.JavaBeanInfo.treeBuildingComplete(JavaBeanInfo.java:820)
   at com.swtdesigner.model.swing.component.ContainerBeanInfo.treeBuildingComplete(ContainerBeanInfo.java:196)
   at com.swtdesigner.model.JavaInfo.treeBuildingComplete(JavaInfo.java:877)
   at com.swtdesigner.model.swing.JavaBeanInfo.treeBuildingComplete(JavaBeanInfo.java:820)
   at com.swtdesigner.model.swing.component.ContainerBeanInfo.treeBuildingComplete(ContainerBeanInfo.java:196)
   at com.swtdesigner.model.JavaInfo.doAcceptAsRoot(JavaInfo.java:846)
   at com.swtdesigner.model.swing.component.ContainerBeanInfo.doAcceptAsRoot(ContainerBeanInfo.java:876)
   at com.swtdesigner.model.parser.JavaInfoParser.getRootNodes(JavaInfoParser.java:606)
   at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:1141)
   at com.swtdesigner.gef.DesignerEditor$17.execute(DesignerEditor.java:1072)
   at com.swtdesigner.model.swing.properties.custom.DesignTimeHelper.execute(DesignTimeHelper.java:54)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:1066)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:1059)
   at com.swtdesigner.editors.MultiPageEditor.showDesignEditor(MultiPageEditor.java:426)
   at com.swtdesigner.editors.MultiPageEditor$2.widgetSelected(MultiPageEditor.java:196)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
   at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:706)
   at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3227)
   at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2005)
   at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:316)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
   at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   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.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)

Full stack trace (to see full context):
java.lang.NullPointerException
   at com.swtdesigner.model.swing.layouts.managers.group.layout.GroupLayoutHelper.convertAlignment(GroupLayoutHelper.java:27)
   at com.swtdesigner.model.swing.layouts.managers.group.GroupLayoutInfo$GroupLayoutParserVisitor.endVisit(GroupLayoutInfo.java:1496)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:246)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2523)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:239)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:244)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
   at com.swtdesigner.model.swing.layouts.managers.group.GroupLayoutInfo.treeBuildingComplete(GroupLayoutInfo.java:1181)
   at com.swtdesigner.model.JavaInfo.treeBuildingComplete(JavaInfo.java:877)
   at com.swtdesigner.model.swing.JavaBeanInfo.treeBuildingComplete(JavaBeanInfo.java:820)
   at com.swtdesigner.model.swing.component.ContainerBeanInfo.treeBuildingComplete(ContainerBeanInfo.java:196)
   at com.swtdesigner.model.JavaInfo.treeBuildingComplete(JavaInfo.java:877)
   at com.swtdesigner.model.swing.JavaBeanInfo.treeBuildingComplete(JavaBeanInfo.java:820)
   at com.swtdesigner.model.swing.component.ContainerBeanInfo.treeBuildingComplete(ContainerBeanInfo.java:196)
   at com.swtdesigner.model.JavaInfo.doAcceptAsRoot(JavaInfo.java:846)
   at com.swtdesigner.model.swing.component.ContainerBeanInfo.doAcceptAsRoot(ContainerBeanInfo.java:876)
   at com.swtdesigner.model.parser.JavaInfoParser.getRootNodes(JavaInfoParser.java:606)
   at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:1141)
   at com.swtdesigner.gef.DesignerEditor$17.execute(DesignerEditor.java:1072)
   at com.swtdesigner.model.swing.properties.custom.DesignTimeHelper.execute(DesignTimeHelper.java:54)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:1066)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:1059)
   at com.swtdesigner.editors.MultiPageEditor.showDesignEditor(MultiPageEditor.java:426)
   at com.swtdesigner.editors.MultiPageEditor$2.widgetSelected(MultiPageEditor.java:196)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
   at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:706)
   at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3227)
   at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2005)
   at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:316)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
   at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   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.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)



Is this a known shortcoming of Swing Designer or am I maybe doing something wrong?

Thanks very much.
waimea
 
Posts: 4
Joined: Sat May 30, 2009 10:10 am

Re: Bidirectionality

Postby Eric Clayberg » Fri Jun 05, 2009 7:54 am

waimea wrote:Is Swing Designer fully bidirectional?

Depends on what you mean by "fully". The tool can reverse engineer 100% of code generated by itself or other tools and generaly 80-90% of hand written code.

Is it possible to make a change that will prevent parsing or instantiating a custom widget? Sure. Is that likely? Usually not. Is it easily fixable? Most of the time, yes.

waimea wrote:Is this a known shortcoming of Swing Designer or am I maybe doing something wrong?

Without seeing an actual test case and your complete Eclipse ".log" file, it is hard to say.

You should review the FAQ entry on custom widgets and the use of Beans.isDesignTime().
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

Re: Bidirectionality

Postby waimea » Fri Jun 05, 2009 9:47 am

Thanks very much for your reply.
The link in the faq you gave is very helpful. I understand that Swing Designer cannot guess data that is generated at runtime (like from a database) and that is associated to GUI components.
So, I wrapped all my code into the following kind of condition:

Code: Select all
      if (!Beans.isDesignTime()) {
         
      }


However, I still get the same kind of error when I try to get back to design view.
I ended up stripping the class of all code that I had added manually, so the file is in the same state as it was generated by Swing Designer.
But I still cannot toggle back to design view.
Is this a common problem with Designer and is there any solution?
Thanks very much.
waimea
 
Posts: 4
Joined: Sat May 30, 2009 10:10 am

Re: Bidirectionality

Postby Eric Clayberg » Fri Jun 05, 2009 5:21 pm

waimea wrote:Is this a common problem with Designer and is there any solution?

It certainly isn't a commo problem as I am not familiar with that exception.

Again, without seeing an actual test case and your complete Eclipse ".log" file, it is hard to say what the solution would be.
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 Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest