Error when on a Composite there's a PopupPanel ?

88 views
Skip to first unread message

darkman97

unread,
Aug 30, 2007, 7:30:27 AM8/30/07
to Google Web Toolkit
This code runs on GWT 1.4.10 but crashes on 1.4.60

The error when refreshingPopUp.show() is called :

[ERROR] Unable to load module entry point class
es.git.cecom.gwt.telepub.client.Main (see associated exception for
details)
java.lang.IllegalStateException: Cannot set a new parent without first
clearing the old parent
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:236)
at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:
85)
at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:
68)
at com.google.gwt.user.client.ui.PopupPanel.show(PopupPanel.java:426)
at
es.git.cecom.gwt.telepub.client.widget.RefreshingPopup.show(RefreshingPopup.java:
51)

The code is:

public class RefreshingPopup extends Composite implements HasWidgets {
private PopupPanel panel;
private VerticalPanel vPanel;
private Label msg;

public RefreshingPopup() {
panel = new PopupPanel(false);
panel.setSize("150","60");
panel.setStyleName("refrescando");
vPanel = new VerticalPanel();
vPanel.setSize("100%","100%");
msg = new
Label(Main.get().traducirRefrescoPopup("popup.refresco.refrescando"));
vPanel.add(msg);
vPanel.setCellVerticalAlignment(msg,VerticalPanel.ALIGN_MIDDLE);
vPanel.setCellHorizontalAlignment(msg,
HorizontalPanel.ALIGN_CENTER);
panel.add(vPanel);

initWidget(panel);
}

private void setCenterPopup(){
int left = Window.getClientWidth()/2;
int top = Window.getClientHeight()/2;
panel.setPopupPosition(left,top);
}

public void show(){
setCenterPopup();
panel.show();
}

public void hide(){
setCenterPopup();
panel.hide();
}

/* (non-Javadoc)
* @see
com.google.gwt.user.client.ui.HasWidgets#add(com.google.gwt.user.client.ui.Widget)
*/
public void add(Widget w) {
}

/* (non-Javadoc)
* @see com.google.gwt.user.client.ui.HasWidgets#clear()
*/
public void clear() {
}

/* (non-Javadoc)
* @see com.google.gwt.user.client.ui.HasWidgets#iterator()
*/
public Iterator iterator() {
return null;
}

/* (non-Javadoc)
* @see
com.google.gwt.user.client.ui.HasWidgets#remove(com.google.gwt.user.client.ui.Widget)
*/
public boolean remove(Widget w) {
return true;
}
}

Peter Blazejewicz

unread,
Aug 30, 2007, 4:40:43 PM8/30/07
to Google Web Toolkit
hi,
digg exception tree to see exact reason,
maybe you're adding that popup as regular widget?

to avoid such situation do not use composite but extend base class:

package com.mycompany.project.client;

import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class RefreshingPopup extends PopupPanel {

private Label msg;
private VerticalPanel vPanel;

public RefreshingPopup() {
super(true);
vPanel = new VerticalPanel();
setWidget(vPanel);


vPanel.setSize("100%", "100%");

msg = new Label("New Label");
vPanel.add(msg);
vPanel.setCellHorizontalAlignment(msg,
HasHorizontalAlignment.ALIGN_CENTER);
vPanel.setCellVerticalAlignment(msg,
HasVerticalAlignment.ALIGN_MIDDLE);
setSize("150px", "60px");
}
}

regards,
Peter

darkman97

unread,
Aug 31, 2007, 2:19:26 AM8/31/07
to Google Web Toolkit
Thanks Peter

Really it's like you say, I changed extending base class and not
using composite and it runs propertly.

Probably it's not a good idea to construct a composite with a
PopupPanel it's more logical extending base class, that was and old
code inherits from more older version than GWT 1.3.3.

The final code tranformed has been like something like this (more
simple, if simple normaly good):

public class RefreshingPopup extends PopupPanel {

private VerticalPanel vPanel;
private Label msg;

public RefreshingPopup() {
super(false);
vPanel = new VerticalPanel();


vPanel.setSize("100%","100%");
msg = new

Label(Main.get().traducirRefrescoPopup("popup.refresco.refrescando"));
vPanel.add(msg);
vPanel.setCellVerticalAlignment(msg,VerticalPanel.ALIGN_MIDDLE);
vPanel.setCellHorizontalAlignment(msg,
HorizontalPanel.ALIGN_CENTER);

setWidget(vPanel);
}

public void show(){
super.show();
center();
}
}


Reply all
Reply to author
Forward
0 new messages