| 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.shared.actions.Order;
|
|
|
5 |
|
|
|
6 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
7 |
|
|
|
8 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
9 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
10 |
import com.google.gwt.user.client.ui.Button;
|
|
|
11 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
12 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
13 |
import com.google.gwt.user.client.ui.Label;
|
|
|
14 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
15 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
16 |
|
|
|
17 |
public class AddWeightBox extends DialogBox {
|
| 3473 |
chandransh |
18 |
private Label errorLabel = new Label("");
|
|
|
19 |
|
| 3463 |
chandransh |
20 |
private Label weightLabel = new Label("Weight");
|
|
|
21 |
|
|
|
22 |
private TextBox weightBox = new TextBox();
|
|
|
23 |
|
|
|
24 |
private Button submitbutton = new Button("Submit");
|
|
|
25 |
|
|
|
26 |
private HorizontalPanel hpanel;
|
|
|
27 |
|
|
|
28 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
public AddWeightBox(final EventBus eventBus, final Order order){
|
| 3473 |
chandransh |
32 |
vpanel.add(errorLabel);
|
|
|
33 |
|
| 3463 |
chandransh |
34 |
hpanel = new HorizontalPanel();
|
|
|
35 |
hpanel.setSpacing(5);
|
|
|
36 |
hpanel.add(weightLabel);
|
|
|
37 |
hpanel.add(weightBox);
|
|
|
38 |
hpanel.setCellWidth(weightLabel, "50px");
|
|
|
39 |
vpanel.add(hpanel);
|
|
|
40 |
|
|
|
41 |
vpanel.add(submitbutton);
|
|
|
42 |
|
|
|
43 |
setWidget(vpanel);
|
|
|
44 |
setAutoHideEnabled(true);
|
|
|
45 |
setGlassEnabled(true);
|
|
|
46 |
setText("Please enter weight");
|
|
|
47 |
setModal(true);
|
|
|
48 |
|
|
|
49 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
50 |
|
|
|
51 |
@Override
|
|
|
52 |
public void onClick(ClickEvent event) {
|
|
|
53 |
String weightStr = weightBox.getText();
|
| 3473 |
chandransh |
54 |
try{
|
|
|
55 |
double weight = Double.parseDouble(weightStr);
|
|
|
56 |
eventBus.fireEvent(new AddWeightEvent(order, weight));
|
|
|
57 |
}catch(NumberFormatException nfe){
|
|
|
58 |
errorLabel.setText("Invalid Weight.");
|
|
|
59 |
return;
|
|
|
60 |
}
|
| 3463 |
chandransh |
61 |
clear();
|
| 3473 |
chandransh |
62 |
hide();
|
| 3463 |
chandransh |
63 |
}
|
|
|
64 |
});
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public void clear(){
|
|
|
68 |
weightBox.setText("");
|
|
|
69 |
}
|
|
|
70 |
}
|