| 1146 |
chandransh |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.event.AddJacketNumberEvent;
|
|
|
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 JacketInfoBox extends DialogBox {
|
|
|
18 |
private Label errorLabel = new Label("");
|
|
|
19 |
private Label jacketNumberLabel = new Label("Jacket Number");
|
|
|
20 |
private TextBox jacketNumberBox = new TextBox();
|
| 2352 |
chandransh |
21 |
private Label imeiNumberLabel = new Label("IMEI No.");
|
|
|
22 |
private TextBox imeiNumberBox = new TextBox();
|
| 1146 |
chandransh |
23 |
private Button submitbutton = new Button("Submit");
|
|
|
24 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
25 |
|
|
|
26 |
public JacketInfoBox(final EventBus eventBus, final Order order){
|
|
|
27 |
vpanel.add(errorLabel);
|
| 2352 |
chandransh |
28 |
vpanel.add(getHorizontalPanel(jacketNumberLabel, jacketNumberBox)); //Ask for the jacket number
|
|
|
29 |
if("Handsets".equals(order.getProductGroup())){
|
|
|
30 |
vpanel.add(getHorizontalPanel(imeiNumberLabel, imeiNumberBox)); //Ask for IMEI only in case of Handsets
|
|
|
31 |
}
|
| 1146 |
chandransh |
32 |
vpanel.add(submitbutton);
|
|
|
33 |
|
|
|
34 |
setWidget(vpanel);
|
|
|
35 |
setAutoHideEnabled(true);
|
|
|
36 |
setGlassEnabled(true);
|
| 2352 |
chandransh |
37 |
setText("Enter the Jacket Number and IMEI no.");
|
| 1146 |
chandransh |
38 |
setModal(true);
|
|
|
39 |
|
|
|
40 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
41 |
|
|
|
42 |
@Override
|
|
|
43 |
public void onClick(ClickEvent event) {
|
| 2352 |
chandransh |
44 |
long jacketNumber = -1;
|
|
|
45 |
try {
|
|
|
46 |
jacketNumber = Long.parseLong(jacketNumberBox.getText());
|
|
|
47 |
} catch(NumberFormatException nfe){
|
|
|
48 |
nfe.printStackTrace();
|
| 1146 |
chandransh |
49 |
}
|
| 2352 |
chandransh |
50 |
|
|
|
51 |
if(jacketNumber <= 0){
|
|
|
52 |
errorLabel.setText("Invalid Jacket number.");
|
|
|
53 |
return;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
long imeiNumber = -1;
|
|
|
57 |
if("Handsets".equals(order.getProductGroup())){
|
|
|
58 |
try {
|
|
|
59 |
imeiNumber = Long.parseLong(imeiNumberBox.getText());
|
|
|
60 |
} catch(NumberFormatException nfe){
|
|
|
61 |
nfe.printStackTrace();
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
if(imeiNumber <= 0){
|
|
|
65 |
errorLabel.setText("Invalid IMEI number");
|
|
|
66 |
return;
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
eventBus.fireEvent(new AddJacketNumberEvent(order, jacketNumber, imeiNumber));
|
|
|
71 |
hide();
|
|
|
72 |
clean();
|
| 1146 |
chandransh |
73 |
}
|
|
|
74 |
});
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public void clean(){
|
|
|
78 |
jacketNumberBox.setText("");
|
| 2352 |
chandransh |
79 |
imeiNumberBox.setText("");
|
| 1146 |
chandransh |
80 |
errorLabel.setText("");
|
|
|
81 |
}
|
| 2352 |
chandransh |
82 |
|
|
|
83 |
private HorizontalPanel getHorizontalPanel(Label label, TextBox textBox){
|
|
|
84 |
HorizontalPanel hpanel = new HorizontalPanel();
|
|
|
85 |
hpanel.setSpacing(5);
|
|
|
86 |
hpanel.add(label);
|
|
|
87 |
hpanel.add(textBox);
|
|
|
88 |
hpanel.setCellWidth(label, "120px");
|
|
|
89 |
return hpanel;
|
|
|
90 |
}
|
| 1146 |
chandransh |
91 |
}
|