0

I have a GXT 2.x application with a Menubar Item that renders a separate LayoutContainer.

Here's the hierarchy MainUI.java -> MenuBar.java -> ReservationPopUp.java

I have replaced my contents of ReservationPopUp.java with KNOWN working examples of LayoutContainer implementations and they respond to the ESC key and "X" button.

Here's how the MenuItem renders the ReservationPopUp.java

MenuItem mntmReserve = new MenuItem("Reserve"); 
mntmReserve.addSelectionListener(new SelectionListener<MenuEvent>() {
    public void componentSelected(MenuEvent ce) {
        RootPanel.get().add(new ReservationPopUp());

}

Here's a slimmed down version of my ReservationPopUp.java

public class ReservationPopUp extends LayoutContainer  {
public ReservationPopUp() {
}

@Override  
  protected void onRender(Element parent, int pos) {  

    super.onRender(parent, pos);
    setSize("1024", "809");
    final Window window = new Window();
    window.setDraggable(false);
    window.setSize(537, 399);  
    window.setPlain(true);  
    window.setModal(true);  
    window.setBlinkModal(true);  
    window.setHeading("Reserve A Server");
    window.setClosable(true);
    window.setOnEsc(true);
    window.setSize("465", "345");
    window.setLayout(new AbsoluteLayout());

    LabelField lblfldUsers = new LabelField("Users");
    window.add(lblfldUsers, new AbsoluteData(43, 218));
    final ComboBox<AsyncUser> userList = new ComboBox<AsyncUser>();

    window.add(userList, new AbsoluteData(81, 218));
    userList.setEmptyText("Select a User...");
    userList.setSize("347px", "24px");

    LabelField labelServers = new LabelField("Servers");
    window.add(labelServers, new AbsoluteData(32, 6));

    final DualListField<AsyncServer> serverList = new DualListField<AsyncServer>();  
        ....
    window.add(serverList, new AbsoluteData(81, 6));
    serverList.setSize("347px", "206px");

    window.addButton(new Button("Cancel", new SelectionListener<ButtonEvent>() {  
          @Override  
          public void componentSelected(ButtonEvent ce) {  
            ReservationPopUp.this.hide();  
          }  
    }));

    window.addButton(new Button("Reserve", new SelectionListener<ButtonEvent>() {  
          @Override  
          public void componentSelected(ButtonEvent ce) {
            if (serverList.getToList().getListView().getItemCount() == 0 ) {
                MessageBox.alert("Invalid Selection","No Server(s) Selected", null);
            } else if ( userList.getValue() == null) {

            } else {
                // DO some stuff
                ReservationPopUp.this.hide();  
            }
          }  
        }));

    window.addWindowListener(new WindowListener() {  
        @Override  
        public void windowHide(WindowEvent we) {
            ReservationPopUp.this.hide();
        }  
      }); 
    window.setFocusWidget(window.getButtonBar().getItem(0));
    add(window);

}

}

Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
RockWad
  • 15
  • 2
  • 6

1 Answers1

2

Window is a popup, it doesn't need to be (and shouldn't be) added to anything. Extend the Window class instead of the LayoutContainer, and instead of adding the ReservationPopup to the page, just call Window.show().

Colin Alworth
  • 17,801
  • 2
  • 26
  • 39