Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
597 chandransh 37
	private Label orderTreeHeader = new Label("Orders");
584 chandransh 38
	private Label catalogTreeHeader = new Label("Catalog");
534 chandransh 39
	private Tree catalogTree = new Tree();
40
	private final Anchor allItems = new Anchor("All Items");
41
	private final Anchor bestSellers = new Anchor("Best Sellers");
42
	private final Anchor bestDeals = new Anchor("Best Deals");
43
	private final Anchor latestArrivals = new Anchor("Latest Arrivals");
44
 
306 ashish 45
	private final Anchor alerts = new Anchor("Alerts");
167 ashish 46
	private final Image image = new Image("img/shop2020.jpg");
47
	private Widget finalWidget = null;
48
	private Widget northWidget = null;
306 ashish 49
	private TopPanel topPanel = new TopPanel();
534 chandransh 50
 
167 ashish 51
	public InboxWidget(){
534 chandransh 52
		//Prepare the order tree
53
		TreeItem orderRootItem = createOrderTree();
54
		orderTree.addItem(orderRootItem);
55
		orderTree.setWidth("200px");
56
		orderTree.setSelectedItem(orderRootItem.getChild(1)); //FIXME: 1 is the index of the pending orders. Using numbers in code is bad practice. Fix this.
57
		orderTree.ensureSelectedItemVisible();
58
 
59
		//Prepare the catalogue tree
60
		TreeItem catalogRootItem = createCatalogTree();
61
		catalogTree.addItem(catalogRootItem);
62
		catalogTree.setWidth("200px");
63
		catalogTree.setSelectedItem(catalogRootItem.getChild(0)); //FIXME: 0 is the index of All Items. Using numbers in code is bad practice.
64
		catalogTree.ensureSelectedItemVisible();
584 chandransh 65
 
534 chandransh 66
		//Prepare the left panel
67
		StackLayoutPanel leftPanel = new StackLayoutPanel(Unit.PX);
597 chandransh 68
		leftPanel.add(orderTree, orderTreeHeader, 25);
584 chandransh 69
		leftPanel.add(catalogTree, catalogTreeHeader, 25);
534 chandransh 70
		leftPanel.add(new HTML("<b>that</b>"), "Reports", 25);
71
 
72
		// Prepare the lower body of dashboard with the left navigation and the
73
		// display area on the right.
74
		sp.addWest(leftPanel, 200);
75
		sp.add(messageDetails);
76
 
77
		//Prepare the complete body with the header
306 ashish 78
		dpanel.addNorth(topPanel, 5);
79
		dpanel.add(sp);
534 chandransh 80
 
167 ashish 81
		finalWidget = messageDetails;
306 ashish 82
		initWidget(dpanel);
167 ashish 83
 
84
		commandList.setHTML("<p> hi, how ae you doing buddy </p><ul><li>one<li>two<li>three</ul>");
306 ashish 85
		messageDetails.setText("");
167 ashish 86
	}
534 chandransh 87
 
88
	private TreeItem createOrderTree(){
306 ashish 89
		TreeItem root = new TreeItem("Orders");
90
		root.addItem(allOrders);
91
		root.addItem(newOrders);
92
		root.addItem(acceptedOrders);
93
		root.addItem(billedOrders);
94
		root.addItem(shippedOrders);
95
		root.addItem(rejectedOrders);
96
		root.addItem(notAvailable);
97
		root.addItem(alerts);
486 rajveer 98
		alerts.setVisible(false);
306 ashish 99
		return root;
100
	}
101
 
534 chandransh 102
	private TreeItem createCatalogTree(){
103
		TreeItem root = new TreeItem("Catalog");
104
		root.addItem(allItems);
105
		root.addItem(bestDeals);
106
		root.addItem(bestSellers);
107
		root.addItem(latestArrivals);
108
		return root;
109
	}
167 ashish 110
	@Override
111
	public Widget asWidget() {
112
 
113
		return this;
114
	}
115
 
116
	@Override
534 chandransh 117
	public void updateDetailsPane(Widget details) {
118
		if(finalWidget != null){
119
			sp.remove(finalWidget);
120
		}
121
		sp.add(details);
122
		finalWidget = details;
123
	}
124
 
125
	@Override
126
	public void removeDetailsPane() {
127
		updateDetailsPane(messageDetails);	
128
	}
167 ashish 129
 
130
	@Override
131
	public void updateOrderList(OrderList orderList) {
132
		if(finalWidget != null){
133
			sp.remove(finalWidget);
134
		}
135
		if(northWidget != null){
136
			sp.remove(northWidget);
137
		}
138
		sp.addNorth(orderList, 200);
139
		this.northWidget = orderList;
140
 
141
		sp.add(finalWidget);
142
	}
584 chandransh 143
 
144
	@Override
145
	public void updateItemList(ItemList itemList) {
146
		if(finalWidget != null){
147
			sp.remove(finalWidget);
148
		}
149
		if(northWidget != null){
150
			sp.remove(northWidget);
151
		}
152
		sp.addNorth(itemList, 200);
153
		this.northWidget = itemList;
154
 
155
		sp.add(finalWidget);
156
	}
534 chandransh 157
 
158
	@Override
159
	public void changeGreeting(String greeting) {
160
		topPanel.changeGreeting(greeting);		
161
	}
162
 
163
	@Override
164
	public HasClickHandlers getMessageBox() {
165
		return null;
166
	}	
167 ashish 167
 
168
	@Override
169
	public HasClickHandlers getAcceptedOrdersAnchor() {
170
		return acceptedOrders;
171
	}
172
 
173
	@Override
486 rajveer 174
	public HasClickHandlers getRejectedOrdersAnchor() {
175
		return rejectedOrders;
176
	}
177
 
178
	@Override
167 ashish 179
	public HasClickHandlers getBilledOrdersAnchor() {
180
		return billedOrders;
181
	}
182
 
183
	@Override
184
	public HasClickHandlers getNewOrdersAnchor() {
185
		return newOrders;
186
	}
187
 
188
	@Override
189
	public HasClickHandlers getShippedOrdersAnchor() {
190
		return shippedOrders;
191
	}
192
 
193
	@Override
306 ashish 194
	public HasClickHandlers getSignOutLink() {
195
		return topPanel.getSignOutLink();
196
	}
197
 
198
	@Override
199
	public HasClickHandlers getAllOrdersAnchor() {
200
		return allOrders;
201
	}
202
 
203
	@Override
204
	public HasClickHandlers getAlertsAnchor() {
205
		return alerts;
206
	}
207
 
208
	@Override
209
	public HasClickHandlers getNotAvailableAnchor() {
210
		return notAvailable;
211
	}
212
 
597 chandransh 213
	public HasClickHandlers getOrdersTreeHeader(){
214
		return orderTreeHeader;
215
	}
216
 
217
	public HasClickHandlers getAllItemsAnchor(){
218
		return allItems;
219
	}
220
 
221
	public HasClickHandlers getBestDealsAnchor(){
222
		return bestDeals;
223
	}
224
 
225
	public HasClickHandlers getBestSellersAnchor(){
226
		return bestSellers;
227
	}
228
 
229
	public HasClickHandlers getLatestArrivalsAnchor(){
230
		return latestArrivals;
231
	}
232
 
584 chandransh 233
	public HasClickHandlers getCatalogTreeHeader(){
234
		return catalogTreeHeader;
235
	}
236
 
167 ashish 237
}