| 4113 |
chandransh |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.event.SearchOrderEvent;
|
|
|
4 |
|
|
|
5 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
6 |
|
|
|
7 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
8 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
9 |
import com.google.gwt.user.client.ui.Button;
|
|
|
10 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
11 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
12 |
import com.google.gwt.user.client.ui.Label;
|
|
|
13 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
14 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
15 |
|
|
|
16 |
public class SearchBox extends DialogBox {
|
|
|
17 |
private Label errorLabel = new Label("");
|
|
|
18 |
|
|
|
19 |
private Label orderIdLabel = new Label("Order Id");
|
|
|
20 |
private TextBox orderIdBox = new TextBox();
|
|
|
21 |
|
|
|
22 |
private Button submitbutton = new Button("Search");
|
|
|
23 |
|
|
|
24 |
private HorizontalPanel hpanel;
|
|
|
25 |
|
|
|
26 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
27 |
|
|
|
28 |
public SearchBox(final EventBus eventBus, final long warehouseId){
|
|
|
29 |
vpanel.add(errorLabel);
|
|
|
30 |
|
|
|
31 |
hpanel = new HorizontalPanel();
|
|
|
32 |
hpanel.setSpacing(5);
|
|
|
33 |
hpanel.add(orderIdLabel);
|
|
|
34 |
hpanel.add(orderIdBox);
|
|
|
35 |
hpanel.setCellWidth(orderIdLabel, "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 |
String orderIdStr = orderIdBox.getText();
|
|
|
51 |
long orderId = -1;
|
|
|
52 |
try {
|
|
|
53 |
orderId = Long.parseLong(orderIdStr);
|
|
|
54 |
} catch(NumberFormatException nfe){
|
|
|
55 |
|
|
|
56 |
}
|
|
|
57 |
if(orderId < 0)
|
|
|
58 |
errorLabel.setText("Please enter a valid order Id");
|
|
|
59 |
eventBus.fireEvent(new SearchOrderEvent(orderId, warehouseId));
|
|
|
60 |
hide();
|
|
|
61 |
clean();
|
|
|
62 |
}
|
|
|
63 |
});
|
|
|
64 |
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public void clean(){
|
|
|
68 |
orderIdBox.setText("");
|
|
|
69 |
errorLabel.setText("");
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
}
|