NPE on adding a widget

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

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

NPE on adding a widget

Postby ashouric » Wed Oct 25, 2006 9:42 pm

Dear All,

For the following case, an exception is thrown:


Code: Select all
public class MyTest extends Composite {

   public MyTest() {
      final FlexTable flexTable = new FlexTable();
      initWidget(flexTable);

      final Image image = new Image();
      flexTable.setWidget(0, 0, image);
      image.setUrl("home.gif");
   }

}


Code: Select all
public class ImageViewer implements EntryPoint {

   public void onModuleLoad() {
      RootPanel.get().add( new MyTest() );
   }

}


    1 - Open ImageViewer in design mode
    2 - Remove 'MyTest' widget
    3 - Add FlexTable to ImageViewer

The following is logged:
Code: Select all
!ENTRY com.swtdesigner 4 4 2006-10-26 09:03:11.700
!MESSAGE Designer internal error [6.0.0.20061025161957]: java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
   at com.swtdesigner.model.JavaInfo.getParentStatementToInsertAfter(JavaInfo.java:3073)
   at com.swtdesigner.model.JavaInfo.getParentStatementToInsertAfter(JavaInfo.java:3052)
   at com.swtdesigner.model.JavaInfo.getParentStatementToInsertAfter(JavaInfo.java:3036)
   at com.swtdesigner.model.swing.JavaBeanInfo.getParentStatementToInsertAfter(JavaBeanInfo.java:1300)
   at com.swtdesigner.model.JavaInfo.addToParentBlockOrPlain(JavaInfo.java:2887)
   at com.swtdesigner.model.JavaInfo.addToParent(JavaInfo.java:2863)
   at com.swtdesigner.model.swing.JavaBeanInfo.addToParent(JavaBeanInfo.java:729)
   at com.swtdesigner.model.JavaInfo.addToParent(JavaInfo.java:2842)
   at com.swtdesigner.model.JavaInfo.addToParent(JavaInfo.java:2839)
   at com.swtdesigner.gwt.gef.policy.absolute.AbsoluteLayoutEditPolicy$CreateCommand.executeEdit(AbsoluteLayoutEditPolicy.java:131)
   at com.swtdesigner.gef.command.common.EditCommand.execute(EditCommand.java:32)
   at org.eclipse.gef.commands.CommandStack.execute(CommandStack.java:78)
   at com.swtdesigner.gef.domain.DesignerEditDomain$1.execute(DesignerEditDomain.java:54)
   at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:416)
   at org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:198)
   at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:122)
   at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1006)
   at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:229)
   at com.swtdesigner.gef.domain.DesignerEditDomain.mouseUp(DesignerEditDomain.java:262)
   at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:346)
   at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:511)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:137)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
   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:336)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
   at org.eclipse.core.launcher.Main.run(Main.java:977)
   at org.eclipse.core.launcher.Main.main(Main.java:952)
ashouric
 
Posts: 75
Joined: Sat Sep 30, 2006 9:13 pm

Re: NPE on adding a widget

Postby Eric Clayberg » Fri Oct 27, 2006 5:48 am

ashouric wrote:
    1 - Open ImageViewer in design mode
    2 - Remove 'MyTest' widget
    3 - Add FlexTable to ImageViewer

In your example, removing MyTest also removes the entire statement containing the rootpanel. Without the rootpanel, there is no place to put the flextable.

The solution is to add the rootpanel code back to the class before adding the flextable.
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: NPE on adding a widget

Postby Eric Clayberg » Sat Oct 28, 2006 4:49 am

In the latest build will now separate the rootpanel creation statement from the adding of the widget, so that deleting the widget will not remove the rootpanel.

In addition, if the rootpanel is somehow deleted, Designer will add it back in.
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 GWT Designer

Who is online

Users browsing this forum: No registered users and 3 guests