| 167 |
ashish |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.inbox.InboxPresenter.Display;
|
|
|
4 |
|
|
|
5 |
import com.google.gwt.dom.client.Style.Unit;
|
|
|
6 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
7 |
import com.google.gwt.user.client.ui.Anchor;
|
|
|
8 |
import com.google.gwt.user.client.ui.Composite;
|
| 306 |
ashish |
9 |
import com.google.gwt.user.client.ui.DockLayoutPanel;
|
| 167 |
ashish |
10 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
11 |
import com.google.gwt.user.client.ui.Image;
|
| 584 |
chandransh |
12 |
import com.google.gwt.user.client.ui.Label;
|
|
|
13 |
import com.google.gwt.user.client.ui.SimplePanel;
|
| 167 |
ashish |
14 |
import com.google.gwt.user.client.ui.SplitLayoutPanel;
|
|
|
15 |
import com.google.gwt.user.client.ui.StackLayoutPanel;
|
| 306 |
ashish |
16 |
import com.google.gwt.user.client.ui.Tree;
|
|
|
17 |
import com.google.gwt.user.client.ui.TreeItem;
|
| 167 |
ashish |
18 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
19 |
|
|
|
20 |
public class InboxWidget extends Composite implements Display{
|
|
|
21 |
|
|
|
22 |
private final HTML commandList = new HTML("Navigation");
|
|
|
23 |
private final HTML messageList = new HTML("Messages are");
|
|
|
24 |
private final HTML messageDetails = new HTML("Message Details");
|
| 306 |
ashish |
25 |
private DockLayoutPanel dpanel = new DockLayoutPanel(Unit.EM);
|
| 167 |
ashish |
26 |
private SplitLayoutPanel sp = new SplitLayoutPanel();
|
| 534 |
chandransh |
27 |
|
|
|
28 |
private Tree orderTree = new Tree();
|
|
|
29 |
private final Anchor allOrders = new Anchor("All");
|
| 487 |
rajveer |
30 |
private final Anchor newOrders = new Anchor("Pending");
|
| 534 |
chandransh |
31 |
private final Anchor acceptedOrders = new Anchor("Accepted");
|
| 306 |
ashish |
32 |
private final Anchor billedOrders = new Anchor("Billed");
|
|
|
33 |
private final Anchor shippedOrders = new Anchor("Shipped");
|
| 530 |
chandransh |
34 |
private final Anchor rejectedOrders = new Anchor("Rejected");
|
| 306 |
ashish |
35 |
private final Anchor notAvailable = new Anchor("No Stock");
|
| 534 |
chandransh |
36 |
|
| 584 |
chandransh |
37 |
private Label catalogTreeHeader = new Label("Catalog");
|
| 534 |
chandransh |
38 |
private Tree catalogTree = new Tree();
|
|
|
39 |
private final Anchor allItems = new Anchor("All Items");
|
|
|
40 |
private final Anchor bestSellers = new Anchor("Best Sellers");
|
|
|
41 |
private final Anchor bestDeals = new Anchor("Best Deals");
|
|
|
42 |
private final Anchor latestArrivals = new Anchor("Latest Arrivals");
|
|
|
43 |
|
| 306 |
ashish |
44 |
private final Anchor alerts = new Anchor("Alerts");
|
| 167 |
ashish |
45 |
private final Image image = new Image("img/shop2020.jpg");
|
|
|
46 |
private Widget finalWidget = null;
|
|
|
47 |
private Widget northWidget = null;
|
| 306 |
ashish |
48 |
private TopPanel topPanel = new TopPanel();
|
| 534 |
chandransh |
49 |
|
| 167 |
ashish |
50 |
public InboxWidget(){
|
| 534 |
chandransh |
51 |
//Prepare the order tree
|
|
|
52 |
TreeItem orderRootItem = createOrderTree();
|
|
|
53 |
orderTree.addItem(orderRootItem);
|
|
|
54 |
orderTree.setWidth("200px");
|
|
|
55 |
orderTree.setSelectedItem(orderRootItem.getChild(1)); //FIXME: 1 is the index of the pending orders. Using numbers in code is bad practice. Fix this.
|
|
|
56 |
orderTree.ensureSelectedItemVisible();
|
|
|
57 |
|
|
|
58 |
//Prepare the catalogue tree
|
|
|
59 |
TreeItem catalogRootItem = createCatalogTree();
|
|
|
60 |
catalogTree.addItem(catalogRootItem);
|
|
|
61 |
catalogTree.setWidth("200px");
|
|
|
62 |
catalogTree.setSelectedItem(catalogRootItem.getChild(0)); //FIXME: 0 is the index of All Items. Using numbers in code is bad practice.
|
|
|
63 |
catalogTree.ensureSelectedItemVisible();
|
| 584 |
chandransh |
64 |
|
| 534 |
chandransh |
65 |
//Prepare the left panel
|
|
|
66 |
StackLayoutPanel leftPanel = new StackLayoutPanel(Unit.PX);
|
|
|
67 |
leftPanel.add(orderTree, "Orders", 25);
|
| 584 |
chandransh |
68 |
leftPanel.add(catalogTree, catalogTreeHeader, 25);
|
| 534 |
chandransh |
69 |
leftPanel.add(new HTML("<b>that</b>"), "Reports", 25);
|
|
|
70 |
|
|
|
71 |
// Prepare the lower body of dashboard with the left navigation and the
|
|
|
72 |
// display area on the right.
|
|
|
73 |
sp.addWest(leftPanel, 200);
|
|
|
74 |
sp.add(messageDetails);
|
|
|
75 |
|
|
|
76 |
//Prepare the complete body with the header
|
| 306 |
ashish |
77 |
dpanel.addNorth(topPanel, 5);
|
|
|
78 |
dpanel.add(sp);
|
| 534 |
chandransh |
79 |
|
| 167 |
ashish |
80 |
finalWidget = messageDetails;
|
| 306 |
ashish |
81 |
initWidget(dpanel);
|
| 167 |
ashish |
82 |
|
|
|
83 |
commandList.setHTML("<p> hi, how ae you doing buddy </p><ul><li>one<li>two<li>three</ul>");
|
| 306 |
ashish |
84 |
messageDetails.setText("");
|
| 167 |
ashish |
85 |
}
|
| 534 |
chandransh |
86 |
|
|
|
87 |
private TreeItem createOrderTree(){
|
| 306 |
ashish |
88 |
TreeItem root = new TreeItem("Orders");
|
|
|
89 |
root.addItem(allOrders);
|
|
|
90 |
root.addItem(newOrders);
|
|
|
91 |
root.addItem(acceptedOrders);
|
|
|
92 |
root.addItem(billedOrders);
|
|
|
93 |
root.addItem(shippedOrders);
|
|
|
94 |
root.addItem(rejectedOrders);
|
|
|
95 |
root.addItem(notAvailable);
|
|
|
96 |
root.addItem(alerts);
|
| 486 |
rajveer |
97 |
alerts.setVisible(false);
|
| 306 |
ashish |
98 |
return root;
|
|
|
99 |
}
|
|
|
100 |
|
| 534 |
chandransh |
101 |
private TreeItem createCatalogTree(){
|
|
|
102 |
TreeItem root = new TreeItem("Catalog");
|
|
|
103 |
root.addItem(allItems);
|
|
|
104 |
root.addItem(bestDeals);
|
|
|
105 |
root.addItem(bestSellers);
|
|
|
106 |
root.addItem(latestArrivals);
|
|
|
107 |
return root;
|
|
|
108 |
}
|
| 167 |
ashish |
109 |
@Override
|
|
|
110 |
public Widget asWidget() {
|
|
|
111 |
|
|
|
112 |
return this;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
@Override
|
| 534 |
chandransh |
116 |
public void updateDetailsPane(Widget details) {
|
|
|
117 |
if(finalWidget != null){
|
|
|
118 |
sp.remove(finalWidget);
|
|
|
119 |
}
|
|
|
120 |
sp.add(details);
|
|
|
121 |
finalWidget = details;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
@Override
|
|
|
125 |
public void removeDetailsPane() {
|
|
|
126 |
updateDetailsPane(messageDetails);
|
|
|
127 |
}
|
| 167 |
ashish |
128 |
|
|
|
129 |
@Override
|
|
|
130 |
public void updateOrderList(OrderList orderList) {
|
|
|
131 |
if(finalWidget != null){
|
|
|
132 |
sp.remove(finalWidget);
|
|
|
133 |
}
|
|
|
134 |
if(northWidget != null){
|
|
|
135 |
sp.remove(northWidget);
|
|
|
136 |
}
|
|
|
137 |
sp.addNorth(orderList, 200);
|
|
|
138 |
this.northWidget = orderList;
|
|
|
139 |
|
|
|
140 |
sp.add(finalWidget);
|
|
|
141 |
}
|
| 584 |
chandransh |
142 |
|
|
|
143 |
@Override
|
|
|
144 |
public void updateItemList(ItemList itemList) {
|
|
|
145 |
if(finalWidget != null){
|
|
|
146 |
sp.remove(finalWidget);
|
|
|
147 |
}
|
|
|
148 |
if(northWidget != null){
|
|
|
149 |
sp.remove(northWidget);
|
|
|
150 |
}
|
|
|
151 |
sp.addNorth(itemList, 200);
|
|
|
152 |
this.northWidget = itemList;
|
|
|
153 |
|
|
|
154 |
sp.add(finalWidget);
|
|
|
155 |
}
|
| 534 |
chandransh |
156 |
|
|
|
157 |
@Override
|
|
|
158 |
public void changeGreeting(String greeting) {
|
|
|
159 |
topPanel.changeGreeting(greeting);
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
@Override
|
|
|
163 |
public HasClickHandlers getMessageBox() {
|
|
|
164 |
return null;
|
|
|
165 |
}
|
| 167 |
ashish |
166 |
|
|
|
167 |
@Override
|
|
|
168 |
public HasClickHandlers getAcceptedOrdersAnchor() {
|
|
|
169 |
return acceptedOrders;
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
@Override
|
| 486 |
rajveer |
173 |
public HasClickHandlers getRejectedOrdersAnchor() {
|
|
|
174 |
return rejectedOrders;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
@Override
|
| 167 |
ashish |
178 |
public HasClickHandlers getBilledOrdersAnchor() {
|
|
|
179 |
return billedOrders;
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
@Override
|
|
|
183 |
public HasClickHandlers getNewOrdersAnchor() {
|
|
|
184 |
return newOrders;
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
@Override
|
|
|
188 |
public HasClickHandlers getShippedOrdersAnchor() {
|
|
|
189 |
return shippedOrders;
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
@Override
|
| 306 |
ashish |
193 |
public HasClickHandlers getSignOutLink() {
|
|
|
194 |
return topPanel.getSignOutLink();
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
@Override
|
|
|
198 |
public HasClickHandlers getAllOrdersAnchor() {
|
|
|
199 |
return allOrders;
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
@Override
|
|
|
203 |
public HasClickHandlers getAlertsAnchor() {
|
|
|
204 |
return alerts;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
@Override
|
|
|
208 |
public HasClickHandlers getNotAvailableAnchor() {
|
|
|
209 |
return notAvailable;
|
|
|
210 |
}
|
|
|
211 |
|
| 584 |
chandransh |
212 |
public HasClickHandlers getCatalogTreeHeader(){
|
|
|
213 |
return catalogTreeHeader;
|
|
|
214 |
}
|
|
|
215 |
|
| 167 |
ashish |
216 |
}
|