| 167 |
ashish |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.event.AcceptOrderEvent;
|
|
|
4 |
import in.shop2020.hotspot.dashbaord.client.event.AddressLabelEvent;
|
| 192 |
ashish |
5 |
import in.shop2020.hotspot.dashbaord.client.event.ShippedOrderEvent;
|
| 167 |
ashish |
6 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
|
|
7 |
|
|
|
8 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
9 |
|
|
|
10 |
import com.google.gwt.core.client.GWT;
|
|
|
11 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
13 |
import com.google.gwt.resources.client.CssResource;
|
|
|
14 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
15 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
16 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
17 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
18 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
|
|
19 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
20 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
|
|
21 |
|
|
|
22 |
public class OrderDetails extends ResizeComposite{
|
|
|
23 |
|
|
|
24 |
public interface Listener{
|
|
|
25 |
void onClick();
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
interface Binder extends UiBinder<Widget, OrderDetails>{ }
|
|
|
29 |
|
|
|
30 |
interface SelectionStyle extends CssResource{
|
|
|
31 |
String selectedRow();
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
private static final Binder binder = GWT.create(Binder.class);
|
|
|
35 |
|
|
|
36 |
@UiField FlexTable header;
|
|
|
37 |
@UiField FlexTable table;
|
|
|
38 |
@UiField HTML details;
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
private final EventBus eventbus;
|
|
|
42 |
private Order order;
|
|
|
43 |
private Order transaction;
|
|
|
44 |
|
|
|
45 |
public OrderDetails(EventBus eventbus, Order order, Order order2){
|
|
|
46 |
this.eventbus = eventbus;
|
|
|
47 |
this.order = order;
|
|
|
48 |
this.transaction = order2;
|
|
|
49 |
initWidget(binder.createAndBindUi(this));
|
|
|
50 |
initTable();
|
|
|
51 |
registerhandlers();
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
private void initTable() {
|
|
|
55 |
header.getColumnFormatter().setWidth(0, "128px");
|
|
|
56 |
header.getColumnFormatter().setWidth(1, "200px");
|
|
|
57 |
header.getColumnFormatter().setWidth(2, "200px");
|
|
|
58 |
header.getColumnFormatter().setWidth(3, "200px");
|
|
|
59 |
header.getColumnFormatter().setWidth(4, "200px");
|
|
|
60 |
|
|
|
61 |
header.setText(0, 0, "Accept Order");
|
|
|
62 |
header.setText(0, 1, "Add Billing Details");
|
|
|
63 |
header.setText(0, 2, "Print shipping label");
|
|
|
64 |
header.setText(0, 3, "Prepare for Shipping ");
|
|
|
65 |
header.setText(0, 4, "Mark Shipped");
|
|
|
66 |
header.setText(0, 5, "View Order Details");
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
private void registerhandlers(){
|
|
|
72 |
header.addClickHandler(new ClickHandler() {
|
|
|
73 |
|
|
|
74 |
@Override
|
|
|
75 |
public void onClick(ClickEvent event) {
|
|
|
76 |
|
|
|
77 |
Cell cell = header.getCellForEvent(event);
|
|
|
78 |
|
|
|
79 |
int columnIndex = cell.getCellIndex();
|
|
|
80 |
|
|
|
81 |
if(columnIndex == 0){
|
|
|
82 |
//accept orders
|
|
|
83 |
eventbus.fireEvent(new AcceptOrderEvent(order));
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
if(columnIndex == 1){
|
|
|
87 |
//generate billing information
|
| 192 |
ashish |
88 |
BillingInfoBox box = new BillingInfoBox(eventbus, order);
|
| 167 |
ashish |
89 |
box.clear();
|
|
|
90 |
box.center();
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
if(columnIndex == 2){
|
|
|
94 |
eventbus.fireEvent(new AddressLabelEvent(order));
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
if(columnIndex == 3){
|
| 192 |
ashish |
98 |
ShipmentInfoBox box = new ShipmentInfoBox(eventbus, order);
|
| 167 |
ashish |
99 |
box.clear();
|
|
|
100 |
box.center();
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
if(columnIndex == 4){
|
| 192 |
ashish |
104 |
|
|
|
105 |
eventbus.fireEvent(new ShippedOrderEvent(order, "", "", "", false));
|
|
|
106 |
|
| 167 |
ashish |
107 |
}
|
|
|
108 |
}
|
|
|
109 |
});
|
|
|
110 |
}
|
|
|
111 |
}
|