package org.uberfire.client.screens.popup;

import javax.enterprise.event.Event;
import javax.inject.Inject;

import com.github.gwtbootstrap.client.ui.Button;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Widget;
import org.uberfire.lifecycle.OnStartup;
import org.uberfire.client.annotations.WorkbenchPartTitle;
import org.uberfire.client.annotations.WorkbenchPartView;
import org.uberfire.client.annotations.WorkbenchPopup;
import org.uberfire.mvp.PlaceRequest;
import org.uberfire.workbench.events.BeforeClosePlaceEvent;

/**
 *
 */
@WorkbenchPopup(identifier = "MyTestPopUp")
public class SimplePopUp {

    @Inject
    public Event<BeforeClosePlaceEvent> beforeClosePlaceEvent;

    private PlaceRequest place;

    @OnStartup
    public void onStartup( final PlaceRequest place ) {
        this.place = place;
    }

    @WorkbenchPartTitle
    public String getTitle() {
        return "MyPopUp Title here";
    }

    @WorkbenchPartView
    public Widget getView() {
        Button b = new Button( "Close" );
        b.addClickHandler( new ClickHandler() {

            @Override
            public void onClick( final ClickEvent event ) {
                beforeClosePlaceEvent.fire( new BeforeClosePlaceEvent( place ) );
            }
        } );
        return b;
    }

}

@@ -37,16 +37,55 @@
 popup;%0A%0A
+import javax.annotation.PostConstruct;%0A
 import j
@@ -109,24 +109,24 @@
 vent.Event;%0A
-
 import javax
@@ -191,16 +191,114 @@
 Button;%0A
+import com.github.gwtbootstrap.client.ui.Label;%0Aimport com.github.gwtbootstrap.client.ui.TextBox;%0A
 import c
@@ -393,16 +393,68 @@
 andler;%0A
+import com.google.gwt.user.client.ui.VerticalPanel;%0A
 import c
@@ -994,16 +994,603 @@
 place;%0A%0A
+    private VerticalPanel view = new VerticalPanel();%0A    private Label l;%0A    private TextBox t;%0A    private Button b;%0A%0A    @PostConstruct%0A    public void setup() %7B%0A        l = new Label( %22Click to close%22 );%0A        t = new TextBox();%0A        b = new Button( %22Close%22 );%0A        b.addClickHandler( new ClickHandler() %7B%0A%0A            @Override%0A            public void onClick( final ClickEvent event ) %7B%0A                beforeClosePlaceEvent.fire( new BeforeClosePlaceEvent( place ) );%0A            %7D%0A        %7D );%0A        view.add( l );%0A        view.add( t );%0A        view.add( b );%0A    %7D%0A%0A
     @OnS
@@ -1680,16 +1680,44 @@
  place;%0A
+        b.setFocus( true );%0A
     %7D%0A%0A 
@@ -1879,298 +1879,19 @@
     
-Button b = new Button( %22Close%22 );%0A        b.addClickHandler( new ClickHandler() %7B%0A%0A            @Override%0A            public void onClick( final ClickEvent event ) %7B%0A                beforeClosePlaceEvent.fire( new BeforeClosePlaceEvent( place ) );%0A            %7D%0A        %7D );%0A        return b
+return view
 ;%0A  

Improve SimplePopup to check interaction of Focus Events and PopupView