
package fr.gouv.finances.dgfip.xemelios.web.gwt.client.widget;

import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
//import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import fr.gouv.finances.dgfip.xemelios.web.gwt.client.utils.GWTUtils;

public class StdDialogBox extends DecoratedPopupPanel {

    private static final String DEFAULT_STYLENAME = "gwt-DialogBox";

    private VerticalPanel mainPanel = new VerticalPanel();
    private HorizontalPanel titleBarPanel = new HorizontalPanel();
    private SimplePanel contentPanel = new SimplePanel();
    private ImageButton imageButton;
    private Label titleLabel;

    public StdDialogBox(String title/*, String width, String height*/) {
        mainPanel = new VerticalPanel();
        titleBarPanel = new HorizontalPanel();
        titleLabel = new Label(title);
        titleBarPanel.add(titleLabel);
        imageButton = new ImageButton(GWTUtils.getContextPath() + "/img/bt_delete.gif", "Supprimer");
        imageButton.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                hide();
            }
        });
        titleBarPanel.add(imageButton);
        titleBarPanel.setCellHorizontalAlignment(imageButton, HorizontalPanel.ALIGN_RIGHT);
        mainPanel.add(titleBarPanel);
        mainPanel.add(contentPanel);
        setStyleName(DEFAULT_STYLENAME);
        super.setWidget(mainPanel);
    }

    @Override
    public void setTitle(String title) {
        super.setTitle(title);
        titleLabel.setText(title);
    }

    @Override
    public void setWidget(Widget w) {
        contentPanel.setWidget(w);
    }


}
