| 1146 |
chandransh |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
| 4286 |
rajveer |
3 |
import java.util.Map;
|
|
|
4 |
import java.util.Map.Entry;
|
|
|
5 |
|
| 1146 |
chandransh |
6 |
import in.shop2020.hotspot.dashbaord.client.event.AddJacketNumberEvent;
|
| 2843 |
chandransh |
7 |
import in.shop2020.hotspot.dashbaord.shared.actions.BillingType;
|
| 1146 |
chandransh |
8 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
|
|
9 |
|
|
|
10 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
11 |
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
13 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
14 |
import com.google.gwt.user.client.ui.Button;
|
|
|
15 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
16 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
17 |
import com.google.gwt.user.client.ui.Label;
|
| 4286 |
rajveer |
18 |
import com.google.gwt.user.client.ui.ListBox;
|
| 1146 |
chandransh |
19 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
20 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 2781 |
chandransh |
21 |
import com.google.gwt.user.client.ui.Widget;
|
| 1146 |
chandransh |
22 |
|
|
|
23 |
public class JacketInfoBox extends DialogBox {
|
|
|
24 |
private Label errorLabel = new Label("");
|
| 2781 |
chandransh |
25 |
|
| 1146 |
chandransh |
26 |
private Label jacketNumberLabel = new Label("Jacket Number");
|
|
|
27 |
private TextBox jacketNumberBox = new TextBox();
|
| 2781 |
chandransh |
28 |
|
|
|
29 |
private Label itemNumberLabel = new Label("Item Number");
|
|
|
30 |
private TextBox itemNumberBox = new TextBox();
|
|
|
31 |
|
| 4658 |
mandeep.dh |
32 |
private Label serialNumberLabel = new Label("Serial No.");
|
|
|
33 |
private TextBox serialNumberBox = new TextBox();
|
| 2781 |
chandransh |
34 |
|
|
|
35 |
private Label billedBy = new Label("Billed by");
|
|
|
36 |
|
| 4286 |
rajveer |
37 |
private Label vendorLabel = new Label("Vendor");
|
|
|
38 |
private ListBox vendorBox = new ListBox();
|
|
|
39 |
|
|
|
40 |
|
| 1146 |
chandransh |
41 |
private Button submitbutton = new Button("Submit");
|
|
|
42 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
43 |
|
| 4286 |
rajveer |
44 |
|
| 4363 |
rajveer |
45 |
public JacketInfoBox(final EventBus eventBus, final Order order, final String user, final BillingType billingType, Map<Long, String> vendors){
|
| 1146 |
chandransh |
46 |
vpanel.add(errorLabel);
|
| 2352 |
chandransh |
47 |
vpanel.add(getHorizontalPanel(jacketNumberLabel, jacketNumberBox)); //Ask for the jacket number
|
| 2843 |
chandransh |
48 |
if(billingType == BillingType.OURS){
|
|
|
49 |
vpanel.add(getHorizontalPanel(itemNumberLabel, itemNumberBox)); //Ask for the item number
|
| 4345 |
mandeep.dh |
50 |
if("Handsets".equalsIgnoreCase(order.getProductGroup())) {
|
| 4658 |
mandeep.dh |
51 |
vpanel.add(getHorizontalPanel(serialNumberLabel, serialNumberBox)); //Ask for Serial number only in case of Handsets
|
| 2843 |
chandransh |
52 |
}
|
| 2352 |
chandransh |
53 |
}
|
| 4286 |
rajveer |
54 |
|
|
|
55 |
for(Entry<Long, String> vendor: vendors.entrySet()){
|
|
|
56 |
vendorBox.addItem(vendor.getValue(), vendor.getKey()+"");
|
|
|
57 |
}
|
|
|
58 |
vpanel.add(getHorizontalPanel(vendorLabel, vendorBox));
|
|
|
59 |
|
|
|
60 |
|
| 2781 |
chandransh |
61 |
vpanel.add(getHorizontalPanel(billedBy, new Label(user)));
|
| 1146 |
chandransh |
62 |
vpanel.add(submitbutton);
|
|
|
63 |
|
|
|
64 |
setWidget(vpanel);
|
|
|
65 |
setAutoHideEnabled(true);
|
|
|
66 |
setGlassEnabled(true);
|
| 2843 |
chandransh |
67 |
if(billingType == BillingType.OURS)
|
|
|
68 |
setText("Enter all the details below:");
|
|
|
69 |
else
|
|
|
70 |
setText("Enter Jacket Number below:");
|
| 1146 |
chandransh |
71 |
setModal(true);
|
|
|
72 |
|
|
|
73 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
74 |
|
|
|
75 |
@Override
|
|
|
76 |
public void onClick(ClickEvent event) {
|
| 2352 |
chandransh |
77 |
long jacketNumber = -1;
|
| 4658 |
mandeep.dh |
78 |
String serialNumber = null;
|
| 2843 |
chandransh |
79 |
String itemNumber = "NO_NUMBER";
|
| 2352 |
chandransh |
80 |
try {
|
|
|
81 |
jacketNumber = Long.parseLong(jacketNumberBox.getText());
|
|
|
82 |
} catch(NumberFormatException nfe){
|
|
|
83 |
nfe.printStackTrace();
|
| 1146 |
chandransh |
84 |
}
|
| 2352 |
chandransh |
85 |
|
|
|
86 |
if(jacketNumber <= 0){
|
|
|
87 |
errorLabel.setText("Invalid Jacket number.");
|
|
|
88 |
return;
|
|
|
89 |
}
|
|
|
90 |
|
| 2843 |
chandransh |
91 |
if(billingType == BillingType.OURS){
|
|
|
92 |
itemNumber = itemNumberBox.getText();
|
|
|
93 |
if(itemNumber==null || itemNumber.trim().isEmpty()){
|
|
|
94 |
errorLabel.setText("Item Number can't be left empty");
|
|
|
95 |
return;
|
|
|
96 |
}
|
|
|
97 |
|
| 3986 |
chandransh |
98 |
if("Handsets".equalsIgnoreCase(order.getProductGroup())){
|
| 2843 |
chandransh |
99 |
try {
|
| 4658 |
mandeep.dh |
100 |
serialNumber = serialNumberBox.getText();
|
| 2843 |
chandransh |
101 |
} catch(NumberFormatException nfe){
|
|
|
102 |
nfe.printStackTrace();
|
|
|
103 |
}
|
|
|
104 |
|
| 4658 |
mandeep.dh |
105 |
if(serialNumber == null){
|
|
|
106 |
errorLabel.setText("Invalid Serial number");
|
| 2843 |
chandransh |
107 |
return;
|
|
|
108 |
}
|
|
|
109 |
}
|
| 2781 |
chandransh |
110 |
}
|
| 4286 |
rajveer |
111 |
long vendorId = -1;
|
|
|
112 |
try {
|
|
|
113 |
vendorId = Long.parseLong(vendorBox.getValue(vendorBox.getSelectedIndex()));
|
|
|
114 |
} catch(NumberFormatException nfe){
|
|
|
115 |
nfe.printStackTrace();
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
if(vendorId <= 0){
|
|
|
119 |
errorLabel.setText("Invalid Vendor");
|
|
|
120 |
return;
|
|
|
121 |
}
|
|
|
122 |
|
| 4658 |
mandeep.dh |
123 |
eventBus.fireEvent(new AddJacketNumberEvent(order, jacketNumber, serialNumber, itemNumber.trim(), user, billingType, vendorId));
|
| 2352 |
chandransh |
124 |
hide();
|
|
|
125 |
clean();
|
| 1146 |
chandransh |
126 |
}
|
|
|
127 |
});
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
public void clean(){
|
|
|
131 |
jacketNumberBox.setText("");
|
| 4658 |
mandeep.dh |
132 |
serialNumberBox.setText("");
|
| 1146 |
chandransh |
133 |
errorLabel.setText("");
|
|
|
134 |
}
|
| 2352 |
chandransh |
135 |
|
| 4658 |
mandeep.dh |
136 |
private HorizontalPanel getHorizontalPanel(Label label, Widget textBox) {
|
| 2352 |
chandransh |
137 |
HorizontalPanel hpanel = new HorizontalPanel();
|
|
|
138 |
hpanel.setSpacing(5);
|
|
|
139 |
hpanel.add(label);
|
|
|
140 |
hpanel.add(textBox);
|
|
|
141 |
hpanel.setCellWidth(label, "120px");
|
|
|
142 |
return hpanel;
|
|
|
143 |
}
|
| 1146 |
chandransh |
144 |
}
|