Subversion Repositories SmartDukaan

Rev

Rev 2209 | Blame | Last modification | View Log | RSS feed

package in.shop2020.hotspot.dashbaord.client.inbox;

import in.shop2020.hotspot.dashbaord.shared.data.Address;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class AddressWidget extends DialogBox{
        
        private Address address;
        private AddressWidgetPanel wpanel;
        
        private class AddressWidgetPanel extends Composite{
                
                VerticalPanel vpanel;
                
                
                
                public AddressWidgetPanel(){
                        vpanel = new VerticalPanel();
                        if(address.getCompleteAddress() == null){                       
                                vpanel.add(new Label(address.getName()));
                                vpanel.add(new Label(address.getLine1()));
                                vpanel.add(new Label(address.getLine2()));
                                vpanel.add(new Label(address.getLocality()));
                                vpanel.add(new Label("Landmark: "+address.getLandmark()));
                                vpanel.add(new Label(address.getCity()));
                                vpanel.add(new Label(address.getState()));
                                vpanel.add(new Label(address.getZip()));
                                vpanel.add(new Label(address.getCountry()));
                                vpanel.add(new Label(address.getPhone()));
                        }else{
                                vpanel.add(new Label(address.getCompleteAddress()));
                        }
                        initWidget(vpanel);
                }               
        }
        
        public AddressWidget(Address address){
                this.address = address;
                wpanel = new AddressWidgetPanel();
                DockLayoutPanel panel = new DockLayoutPanel(Unit.PX);
                panel.addNorth(wpanel, 380);
                
                Button button = new Button("Print");
                
                panel.addSouth(button, 20);
                setWidget(panel);
                setModal(true);
                setText("Address for shipment");
                setGlassEnabled(true);
                //setSize("400px", "400px");
                
                button.addClickHandler(new ClickHandler() {
                        
                        @Override
                        public void onClick(ClickEvent event) {
                                Print.it(wpanel);
                                hide();
                        }
                });
        }
}