mardi 28 juin 2016

gwt: if/else NullPointerException

when i run the Code below, and connect shapeEnde with con_sequenz.startEndPoint, everthing works fine. But when i try to connect shapeStart with con_sequenz.startEndPoint, i get a NullPointerException:

Caused by: java.lang.NullPointerException: null
        at com.exa.projekt.client.Projekt$27.onElementConnect(Projekt.java:1237)
        at pl.tecna.gwt.connectors.client.Diagram.onElementConnect(Diagram.java:421)
        at pl.tecna.gwt.connectors.client.elements.EndPoint.glueToConnectionPoint(EndPoint.java:71)
        at pl.tecna.gwt.connectors.client.drop.DiagramWidgetDropController.onDrop(DiagramWidgetDropController.java:57)
        at com.allen_sauer.gwt.dnd.client.PickupDragController.dragEnd(PickupDragController.java:130)
        at com.allen_sauer.gwt.dnd.client.MouseDragHandler.drop(MouseDragHandler.java:529)
        at com.allen_sauer.gwt.dnd.client.MouseDragHandler.onMouseUp(MouseDragHandler.java:277)
        at com.google.gwt.event.dom.client.MouseUpEvent.dispatch(MouseUpEvent.java:56)
        at com.google.gwt.event.dom.client.MouseUpEvent.dispatch(MouseUpEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
        at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
        at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
        at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
        at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
        at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
        at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Thread.java:745)

The Code (line 1237 is marked with a comment):

diagram.addDiagramListener(new DiagramListenerAdapter() {

                  @Override
                  public void onElementConnect(ElementConnectEvent event) {
                      if(con_sequenz.startEndPoint.isGluedToConnectionPoint()){  
                          Widget connectedstart = con_sequenz.startEndPoint.gluedConnectionPoint.parentWidget;
                        if(connectedstart.equals(shapeEnde.connectedWidget))
                        {
                            String fullstartEnde = new String("END"); //    line 1237
                            text.setWidth100();
                            text.setContents(fullstartEnde);
                            pop.addChild(text);
                        }   
                        else if(connectedstart.equals(shapeStart.connectedWidget))
                        {
                            final String fullstartStart = new String("START");      
                            text.setWidth100();
                            text.setContents(fullstartStart);
                            pop.addChild(text);
                        }   
                          }
                    }      
                  });

Aucun commentaire:

Enregistrer un commentaire