Vaadin 7 - popup windows

In my Vaadin 6 project, I open a number of secondary/popup windows. One of them is a simple ‘help’ window - hit the help button, and it pops up a window with a list of commands and some text explanation. I’m trying to re-write the program for Vaadin 7, and I don’t quite see how to do that.

The original code looked something like this:


    Button tbHelp = new NativeButton();
    tbHelp.setIcon(tr);
    tbHelp.setDescription("myAPP Help Window");
    tbHelp.addListener(new Button.ClickListener() {
    private static final long serialVersionUID = 1L
        @Override
        public void buttonClick(ClickEvent event) {
            showHelpWindow();
        }
    });
...
...
    private void showHelpWindow(){
        wHelp = new Window("myAPP Help");
        wHelp.setHeight("650px");
        wHelp.setWidth("650px");
        wHelp.addComponent(new Win_Help(myApp, wHelp));
        wHelp.center();
        myApp.getMainWindow().addWindow(wHelp);
    }

    private void closeHelpWindow(){
        if(wHelp != null){
            Win_Help.removeHelpWindow(myApp, wHelp);
            wHelp = null;
        }
    }

And the help window itself looked like:

    public class Win_Help extends VerticalLayout{
	private static final long serialVersionUID = 1L;
	private Button b_Close = null;
	private HorizontalLayout hlHeader = null;
	private My_Application app = null;
	private VerticalLayout myPage = null;
	private Window wHelp = null;

	public VerticalLayout getMyPage() {
		return myPage;
	}

	public Win_Help(My_Application myApp, Window w){
		HorizontalLayout hlHelpDescription = null;
		HorizontalLayout hlCloseWindow = null;
		HorizontalLayout hlHelp = null;
...
...

		addComponent(hlReDrawGraph);
		addComponent(hlScreenShot);
		addComponent(hlPreferences);
		addComponent(hlUsersGuide);
		addComponent(hlCloseWindow);

		setComponentAlignment(hlHelpDescription, Alignment.MIDDLE_CENTER);
	}

	public void closeButtonClick(Button.ClickEvent event){
		removeHelpWindow(app, wHelp);
	}
	
	public static void removeHelpWindow(My_Application app, Window w){
		app.getMainWindow().removeWindow(w);
	}
    }

So how do I do this in Vaadin 7? I found some sample code that purports to open sub-windows, but it calls routines like getApplication() which I can’t seem to locate in the new library… I’m guessing that I’m missing something very simple here…

Thanks,

nbc

Use myUI.addWindow(window) instead of myApp.getMainWindow().addWindow(window).

You can get the current UI with UI.getCurrent() if you don’t have a reference to it, or use Component.getUI() for any suitable attached component.