Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3463 chandransh 1
package in.shop2020.hotspot.dashbaord.client.inbox;
2
 
3
import in.shop2020.hotspot.dashbaord.client.event.AddWeightEvent;
4
import in.shop2020.hotspot.dashbaord.client.event.RejectOrderEvent;
5
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
6
 
7
import org.enunes.gwt.mvp.client.EventBus;
8
 
9
import com.google.gwt.event.dom.client.ClickEvent;
10
import com.google.gwt.event.dom.client.ClickHandler;
11
import com.google.gwt.user.client.ui.Button;
12
import com.google.gwt.user.client.ui.DialogBox;
13
import com.google.gwt.user.client.ui.HorizontalPanel;
14
import com.google.gwt.user.client.ui.Label;
15
import com.google.gwt.user.client.ui.TextBox;
16
import com.google.gwt.user.client.ui.VerticalPanel;
17
 
18
public class AddWeightBox extends DialogBox {
19
    private Label weightLabel = new Label("Weight");
20
 
21
    private TextBox weightBox = new TextBox();
22
 
23
    private Button submitbutton = new Button("Submit");
24
 
25
    private HorizontalPanel hpanel;
26
 
27
    private VerticalPanel vpanel = new VerticalPanel();
28
 
29
 
30
    public AddWeightBox(final EventBus eventBus, final Order order){
31
        hpanel = new HorizontalPanel();
32
        hpanel.setSpacing(5);
33
        hpanel.add(weightLabel);
34
        hpanel.add(weightBox);
35
        hpanel.setCellWidth(weightLabel, "50px");
36
        vpanel.add(hpanel);
37
 
38
        vpanel.add(submitbutton);
39
 
40
        setWidget(vpanel);
41
        setAutoHideEnabled(true);
42
        setGlassEnabled(true);
43
        setText("Please enter weight");
44
        setModal(true);
45
 
46
        submitbutton.addClickHandler(new ClickHandler() {
47
 
48
            @Override
49
            public void onClick(ClickEvent event) {
50
                hide();
51
                String weightStr = weightBox.getText();
52
                double weight = Double.parseDouble(weightStr);
53
                eventBus.fireEvent(new AddWeightEvent(order, weight));
54
                clear();
55
            }
56
        });
57
    }
58
 
59
    public void clear(){
60
        weightBox.setText("");
61
    }
62
}