Subversion Repositories SmartDukaan

Rev

Rev 6530 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1961 ankur.sing 1
package in.shop2020.catalog.dashboard.client;
2
 
3
import in.shop2020.catalog.dashboard.shared.Item;
3850 chandransh 4
import in.shop2020.catalog.dashboard.shared.ItemStatus;
1961 ankur.sing 5
 
3872 chandransh 6
import java.util.ArrayList;
7
import java.util.Arrays;
1961 ankur.sing 8
import java.util.List;
9
 
10
import com.google.gwt.core.client.GWT;
3524 chandransh 11
import com.google.gwt.dom.client.Style.Unit;
1961 ankur.sing 12
import com.google.gwt.resources.client.CssResource;
13
import com.google.gwt.uibinder.client.UiBinder;
14
import com.google.gwt.uibinder.client.UiField;
3524 chandransh 15
import com.google.gwt.user.cellview.client.CellTable;
16
import com.google.gwt.user.cellview.client.SimplePager;
17
import com.google.gwt.user.cellview.client.TextColumn;
1961 ankur.sing 18
import com.google.gwt.user.client.Window;
19
import com.google.gwt.user.client.rpc.AsyncCallback;
2489 ankur.sing 20
import com.google.gwt.user.client.ui.Label;
1961 ankur.sing 21
import com.google.gwt.user.client.ui.ResizeComposite;
22
import com.google.gwt.user.client.ui.Widget;
3850 chandransh 23
import com.google.gwt.view.client.AsyncDataProvider;
24
import com.google.gwt.view.client.HasData;
3524 chandransh 25
import com.google.gwt.view.client.ListDataProvider;
3850 chandransh 26
import com.google.gwt.view.client.Range;
3524 chandransh 27
import com.google.gwt.view.client.SelectionChangeEvent;
28
import com.google.gwt.view.client.SingleSelectionModel;
1961 ankur.sing 29
 
2427 ankur.sing 30
/**
31
 * List of items. List contains item Id, product group, brand, model number, model name, color and category
32
 * Dashboard user can select an item in this list and its details are shown in ItemDetails widget.
33
 *
34
 */
1961 ankur.sing 35
public class ItemList extends ResizeComposite{
36
 
11671 vikram.rag 37
	private static String LEGEND = "Currently Showing: ";
38
	private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
1961 ankur.sing 39
 
11671 vikram.rag 40
	interface ItemListUiBinder extends UiBinder<Widget, ItemList> { }
41
	private static final ItemListUiBinder uiBinder = GWT.create(ItemListUiBinder.class);
3524 chandransh 42
 
11671 vikram.rag 43
	interface SelectionStyle extends CssResource{
44
		String selectedRow();
45
		String alertsRow();
46
	}
3850 chandransh 47
 
11671 vikram.rag 48
	@UiField CellTable<Item> itemDescriptionTable;
49
	// Create paging controls.
50
	@UiField SimplePager pager = new SimplePager();
6530 vikram.rag 51
 
11671 vikram.rag 52
	@UiField SelectionStyle selectionStyle;
53
	@UiField Label currentlyShowing;
6530 vikram.rag 54
 
11671 vikram.rag 55
	private ItemDetails itemDetails;
6530 vikram.rag 56
 
11671 vikram.rag 57
	private String currentTreeItemSelection = null;
6530 vikram.rag 58
 
11671 vikram.rag 59
	private String searchText = "";
60
 
61
	private List<String> searchTerms = new ArrayList<String>();
62
 
63
	private TextColumn<Item> idColumn = new TextColumn<Item>() {
64
		@Override
65
		public String getValue(Item item) {
66
			return item.getId() + "";
67
		}
68
	};
69
 
70
	private TextColumn<Item> pgColumn = new TextColumn<Item>() {
71
		@Override
72
		public String getValue(Item item) {
73
			return item.getProductGroup();
74
		}
75
	};
76
 
77
	private TextColumn<Item> brandColumn = new TextColumn<Item>(){
78
		@Override
79
		public String getValue(Item item) {
80
			return item.getBrand();
81
		}
82
	};
83
 
84
	private TextColumn<Item> modelNumberColumn = new TextColumn<Item>(){
85
		@Override
86
		public String getValue(Item item) {
87
			return item.getModelNumber();
88
		}
89
	};
90
 
91
	private TextColumn<Item> modelNameColumn = new TextColumn<Item>(){
92
		@Override
93
		public String getValue(Item item) {
94
			return item.getModelName();
95
		}
96
	};
97
 
98
	private TextColumn<Item> colorColumn = new TextColumn<Item>(){
99
		@Override
100
		public String getValue(Item item) {
101
			return item.getColor();
102
		}
103
	};
104
 
105
	private TextColumn<Item> categoryColumn = new TextColumn<Item>(){
106
		@Override
107
		public String getValue(Item item) {
108
			return item.getContentCategory()+"";
109
		}
110
	};
111
 
112
	// Create a data provider.
113
	ListDataProvider<Item> dataProvider = new ListDataProvider<Item>();
114
 
115
	AsyncDataProvider<Item> asyncDataProvider = new AsyncDataProvider<Item>() {
116
 
117
		@Override
118
		protected void onRangeChanged(HasData<Item> display) {
119
			Range range = display.getVisibleRange();
120
			int start = range.getStart();
121
			int limit = range.getLength();
122
			if(currentTreeItemSelection == null)
123
				currentTreeItemSelection = CatalogTree.RISKY_ITEMS;
124
			if(currentTreeItemSelection.equals(CatalogTree.ALL_ITEMS))
125
				loadAllItems(start, limit);
126
			else if(currentTreeItemSelection.equals(CatalogTree.ALL_ACTIVE_ITEMS))
127
				loadAllActiveItems(start, limit);
128
			else if(currentTreeItemSelection.equals(CatalogTree.ALL_PAUSED_ITEMS))
129
				loadAllPausedItems(start, limit);
130
			else if(currentTreeItemSelection.equals(CatalogTree.ALL_PHASED_OUT_ITEMS))
131
				loadAllPhasedOutItems(start, limit);
132
			else if(currentTreeItemSelection.equals(CatalogTree.IN_PROCESS_ITEMS))
133
				loadAllInProcessItems(start, limit);
134
			else if(currentTreeItemSelection.equals(CatalogTree.CONTENT_COMPLETE_ITEMS))
135
				loadAllContentCompleteItems(start, limit);
136
			else if(currentTreeItemSelection.equals(CatalogTree.BEST_DEALS))
137
				loadBestDeals(start, limit);
138
			else if(currentTreeItemSelection.equals(CatalogTree.BEST_SELLERS))
139
				loadBestSellers(start, limit);
140
			else if(currentTreeItemSelection.equals(CatalogTree.LATEST_ARRIVALS))
141
				loadLatestArrivals(start, limit);
142
			else if(currentTreeItemSelection.equals(CatalogTree.RISKY_ITEMS))
143
				loadAllRiskyItems(start, limit);
144
			else if(currentTreeItemSelection.equals(CatalogTree.SEARCH))
145
				loadSearchItems(start, limit);
146
			else if(currentTreeItemSelection.equals(CatalogTree.INVENTORY_OUTOFSYNC_ITEM_LIST))
147
				loadInventoryOutofSyncItems(start, limit);
148
			else if(currentTreeItemSelection.equals(CatalogTree.PRIVATE_DEALS))
149
				loadPrivateDealItems(start,limit);
150
		}
151
	};
152
 
153
	public ItemList() {
154
		initWidget(uiBinder.createAndBindUi(this));
155
		initItemList();
156
	}
157
 
158
	protected void loadInventoryOutofSyncItems(final int offset, final int limit) {
159
		catalogService.getInventoryOutofSyncItems(offset, limit, new AsyncCallback<List<Item>>() {
160
			public void onFailure(Throwable caught) {
161
				caught.printStackTrace();
162
				Window.alert("Could not get Inventory Out of Sync Items...");
163
			}
164
			public void onSuccess(List<Item> result) {
165
				updateAsyncItemDescriptionTable(offset, result);
166
				currentlyShowing.setText(LEGEND + "Inventory Out-of-Sync Items");
167
			}
168
		});
169
 
170
		catalogService.getInventoryOutofSyncItemsCount(new AsyncCallback<Integer>() {
171
 
172
			@Override
173
			public void onFailure(Throwable caught) {
174
				caught.printStackTrace();
175
				Window.alert("Could not get the count of items...");
176
			}
177
 
178
			@Override
179
			public void onSuccess(Integer count) {
180
				updateItemDescriptionTableRowCount(count);
181
			}
182
		});
183
	}
184
 
185
	protected void loadPrivateDealItems(final int offset, final int limit){
186
		catalogService.getPrivateDealItems(offset, limit, new AsyncCallback<List<Item>>() {
187
			public void onFailure(Throwable caught) {
188
				caught.printStackTrace();
189
				Window.alert("Could not Private Deal Items...");
190
			}
191
			public void onSuccess(List<Item> result) {
192
				updateAsyncItemDescriptionTable(offset, result);
193
				currentlyShowing.setText(LEGEND + "Private Deals");
194
			}
195
		});
196
		catalogService.getPrivateDealItemsCount(new AsyncCallback<Integer>() {
197
			@Override
198
			public void onFailure(Throwable caught) {
199
				caught.printStackTrace();
200
				Window.alert("Could not get the count of items...");
201
			}
202
 
203
			@Override
204
			public void onSuccess(Integer count) {
205
				updateItemDescriptionTableRowCount(count);
206
			}
207
		});
208
	}
209
 
210
 
6530 vikram.rag 211
	private void initItemList() {
11671 vikram.rag 212
		// Add the columns.        
213
		itemDescriptionTable.addColumn(idColumn, "Item Id");
214
		itemDescriptionTable.addColumn(pgColumn, "Product Group");
215
		itemDescriptionTable.addColumn(brandColumn, "Brand");
216
		itemDescriptionTable.addColumn(modelNumberColumn, "Model Number");
217
		itemDescriptionTable.addColumn(modelNameColumn, "Model Name");
218
		itemDescriptionTable.addColumn(colorColumn, "Color");
219
		itemDescriptionTable.addColumn(categoryColumn, "Category");
3524 chandransh 220
 
11671 vikram.rag 221
		//Set the widths
222
		itemDescriptionTable.setWidth("100%");
223
		itemDescriptionTable.setColumnWidth(idColumn, 80.0, Unit.PX);
224
		itemDescriptionTable.setColumnWidth(pgColumn, 128.0, Unit.PX);
225
		itemDescriptionTable.setColumnWidth(brandColumn, 150.0, Unit.PX);
226
		itemDescriptionTable.setColumnWidth(modelNumberColumn, 200.0, Unit.PX);
227
		itemDescriptionTable.setColumnWidth(modelNameColumn, 200.0, Unit.PX);
228
		itemDescriptionTable.setColumnWidth(colorColumn, 128.0, Unit.PX);
229
		itemDescriptionTable.setColumnWidth(categoryColumn, 220.0, Unit.PX);
3524 chandransh 230
 
11671 vikram.rag 231
		// Connect the table to the data provider.
232
		//dataProvider.addDataDisplay(itemDescriptionTable);
233
		asyncDataProvider.addDataDisplay(itemDescriptionTable);
3524 chandransh 234
 
11671 vikram.rag 235
		//Add paging support
236
		pager.setDisplay(itemDescriptionTable);
3850 chandransh 237
 
11671 vikram.rag 238
		// Add a selection model to handle item selection.
239
		final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>();
240
		itemDescriptionTable.setSelectionModel(selectionModel);
241
		selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
3850 chandransh 242
 
11671 vikram.rag 243
			@Override
244
			public void onSelectionChange(SelectionChangeEvent event) {
245
				Item selectedItem = selectionModel.getSelectedObject();
246
				catalogService.getItem(selectedItem.getId(), new AsyncCallback<Item>() {
247
					@Override
248
					public void onSuccess(Item result) {
249
						itemDetails.setItemDetails(result);
250
					}
251
					@Override
252
					public void onFailure(Throwable caught) {
253
						caught.printStackTrace();
254
						Window.alert("Unable to fetch item details.");
255
					}
256
				});
257
			}
258
		});
3850 chandransh 259
 
11671 vikram.rag 260
		loadAllRiskyItems();
261
	}
3850 chandransh 262
 
11671 vikram.rag 263
	public void loadAllItems() {
264
		currentTreeItemSelection = CatalogTree.ALL_ITEMS;
265
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
266
	}
3850 chandransh 267
 
11671 vikram.rag 268
	public void loadAllActiveItems() {
269
		currentTreeItemSelection = CatalogTree.ALL_ACTIVE_ITEMS;
270
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
271
	}
3850 chandransh 272
 
11671 vikram.rag 273
	public void loadAllPhasedOutItems() {
274
		currentTreeItemSelection = CatalogTree.ALL_PHASED_OUT_ITEMS;
275
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
276
	}
3850 chandransh 277
 
11671 vikram.rag 278
	public void loadAllPausedItems() {
279
		currentTreeItemSelection = CatalogTree.ALL_PAUSED_ITEMS;
280
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
281
	}
3850 chandransh 282
 
11671 vikram.rag 283
	public void loadAllInProcessItems() {
284
		currentTreeItemSelection = CatalogTree.IN_PROCESS_ITEMS;
285
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
286
	}
3850 chandransh 287
 
11671 vikram.rag 288
	public void loadAllContentCompleteItems(){
289
		currentTreeItemSelection = CatalogTree.CONTENT_COMPLETE_ITEMS;
290
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
291
	}
3850 chandransh 292
 
11671 vikram.rag 293
	public void loadAllRiskyItems() {
294
		currentTreeItemSelection = CatalogTree.RISKY_ITEMS;
295
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
296
	}
3850 chandransh 297
 
11671 vikram.rag 298
	public void loadBestDeals() {
299
		currentTreeItemSelection = CatalogTree.BEST_DEALS;
300
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
301
	}
3850 chandransh 302
 
11671 vikram.rag 303
	public void loadBestSellers() {
304
		currentTreeItemSelection = CatalogTree.BEST_SELLERS;
305
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
306
	}
3850 chandransh 307
 
11671 vikram.rag 308
	public void loadLatestArrivals() {
309
		currentTreeItemSelection = CatalogTree.LATEST_ARRIVALS;
310
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
311
	}
3850 chandransh 312
 
11671 vikram.rag 313
	public void searchForItems(String searchText) {
314
		currentTreeItemSelection = CatalogTree.SEARCH;
315
		this.searchText = searchText.trim().replaceAll("\\s+", " ");
316
		searchTerms = Arrays.asList(this.searchText.split(" "));
317
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
318
	}
2126 ankur.sing 319
 
11671 vikram.rag 320
	private void updateItemDescriptionTableRowCount(Integer count){
321
		asyncDataProvider.updateRowCount(count, true);
322
	}
3850 chandransh 323
 
11671 vikram.rag 324
	private void updateAsyncItemDescriptionTable(int start, List<Item> items){
325
		// Add the data to the data provider, which automatically pushes it to the
326
		// widget.
327
		asyncDataProvider.updateRowData(start, items);
328
	}
3872 chandransh 329
 
11671 vikram.rag 330
	private void loadAllItems(final int offset, final int limit) {
331
		catalogService.getAllItems(offset, limit, new AsyncCallback<List<Item>>() {
332
 
333
			public void onFailure(Throwable caught) {
334
				caught.printStackTrace();
335
				Window.alert("Could not get all items..");
336
			}
337
			public void onSuccess(List<Item> result) {
338
				updateAsyncItemDescriptionTable(offset, result);
339
				currentlyShowing.setText(LEGEND + "All Items");
340
			}
341
		});
3872 chandransh 342
 
11671 vikram.rag 343
		catalogService.getItemCountByStatus(false, ItemStatus.ACTIVE, new AsyncCallback<Integer>() {
6530 vikram.rag 344
 
11671 vikram.rag 345
			@Override
346
			public void onFailure(Throwable caught) {
347
				caught.printStackTrace();
348
				Window.alert("Could not get the count of items...");
349
			}
350
 
351
			@Override
352
			public void onSuccess(Integer count) {
353
				updateItemDescriptionTableRowCount(count);
354
			}
355
		});
356
	}
357
 
358
	private void loadAllActiveItems(final int offset, final int limit) {
359
		catalogService.getAllActiveItems(offset, limit, new AsyncCallback<List<Item>>() {
360
			public void onFailure(Throwable caught) {
361
				caught.printStackTrace();
362
				Window.alert("Could not get all active items...");
363
			}
364
			public void onSuccess(List<Item> result) {
365
				updateAsyncItemDescriptionTable(offset, result);
366
				currentlyShowing.setText(LEGEND + "Active Items");
367
			}
368
		});
369
 
370
		catalogService.getItemCountByStatus(true, ItemStatus.ACTIVE, new AsyncCallback<Integer>() {
371
 
372
			@Override
373
			public void onFailure(Throwable caught) {
374
				caught.printStackTrace();
375
				Window.alert("Could not get the count of items...");
376
			}
377
 
378
			@Override
379
			public void onSuccess(Integer count) {
380
				updateItemDescriptionTableRowCount(count);
381
			}
382
		});
383
	}
384
 
385
	private void loadAllPhasedOutItems(final int offset, int limit){
386
		catalogService.getAllPhasedOutItems(offset, limit, new AsyncCallback<List<Item>>() {
387
			public void onFailure(Throwable caught) {
388
				caught.printStackTrace();
389
				Window.alert("Could not load phased out items...");
390
			}
391
			public void onSuccess(List<Item> result) {
392
				updateAsyncItemDescriptionTable(offset, result);
393
				currentlyShowing.setText(LEGEND + "Phased Out Items");
394
			}
395
		});
396
 
397
		catalogService.getItemCountByStatus(true, ItemStatus.PHASED_OUT, new AsyncCallback<Integer>() {
398
 
399
			@Override
400
			public void onFailure(Throwable caught) {
401
				caught.printStackTrace();
402
				Window.alert("Could not get the count of items...");
403
			}
404
 
405
			@Override
406
			public void onSuccess(Integer count) {
407
				updateItemDescriptionTableRowCount(count);
408
			}
409
		});
410
	}
411
 
412
	private void loadAllPausedItems(final int offset, int limit) {
413
		catalogService.getAllPausedItems(offset, limit, new AsyncCallback<List<Item>>() {
414
			public void onFailure(Throwable caught) {
415
				caught.printStackTrace();
416
				Window.alert("Could not load paused items...");
417
			}
418
			public void onSuccess(List<Item> result) {
419
				updateAsyncItemDescriptionTable(offset, result);
420
				currentlyShowing.setText(LEGEND + "Paused Items");
421
			}
422
		});
423
 
424
		catalogService.getItemCountByStatus(true, ItemStatus.PAUSED, new AsyncCallback<Integer>() {
425
 
426
			@Override
427
			public void onFailure(Throwable caught) {
428
				caught.printStackTrace();
429
				Window.alert("Could not get the count of items...");
430
			}
431
 
432
			@Override
433
			public void onSuccess(Integer count) {
434
				updateItemDescriptionTableRowCount(count);
435
			}
436
		});
437
	}
438
 
439
	private void loadAllInProcessItems(final int offset, int limit) {
440
		catalogService.getAllInProcessItems(offset, limit, new AsyncCallback<List<Item>>() {
441
			public void onFailure(Throwable caught) {
442
				caught.printStackTrace();
443
				Window.alert("Could not load IN_PROCESS items...");
444
			}
445
			public void onSuccess(List<Item> result) {
446
				updateAsyncItemDescriptionTable(offset, result);
447
				currentlyShowing.setText(LEGEND + "In Process Items");
448
			}
449
		});
450
 
451
		catalogService.getItemCountByStatus(true, ItemStatus.IN_PROCESS, new AsyncCallback<Integer>() {
452
 
453
			@Override
454
			public void onFailure(Throwable caught) {
455
				caught.printStackTrace();
456
				Window.alert("Could not get the count of items...");
457
			}
458
 
459
			@Override
460
			public void onSuccess(Integer count) {
461
				updateItemDescriptionTableRowCount(count);
462
			}
463
		});
464
	}
465
 
466
	private void loadAllContentCompleteItems(final int offset, int limit) {
467
		catalogService.getAllContentCompleteItems(offset, limit, new AsyncCallback<List<Item>>() {
468
			public void onFailure(Throwable caught) {
469
				caught.printStackTrace();
470
				Window.alert("Could not load CONTENT_COMPLETE items...");
471
			}
472
			public void onSuccess(List<Item> result) {
473
				updateAsyncItemDescriptionTable(offset, result);
474
				currentlyShowing.setText(LEGEND + "Content Complete Items");
475
			}
476
		});
477
 
478
		catalogService.getItemCountByStatus(true, ItemStatus.CONTENT_COMPLETE, new AsyncCallback<Integer>() {
479
 
480
			@Override
481
			public void onFailure(Throwable caught) {
482
				caught.printStackTrace();
483
				Window.alert("Could not get the count of items...");
484
			}
485
 
486
			@Override
487
			public void onSuccess(Integer count) {
488
				updateItemDescriptionTableRowCount(count);
489
			}
490
		});
491
	}
492
 
493
	private void loadAllRiskyItems(final int start, final int limit) {
494
		catalogService.getRiskyItems(new AsyncCallback<List<Item>>() {
495
			public void onFailure(Throwable caught) {
496
				caught.printStackTrace();
497
				Window.alert("Could not load RISKY items...");
498
			}
499
			public void onSuccess(List<Item> result) {
500
				updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
501
				updateItemDescriptionTableRowCount(result.size());
502
				currentTreeItemSelection = CatalogTree.RISKY_ITEMS;
503
				currentlyShowing.setText(LEGEND + "Risky Items");
504
			}
505
		});
506
	}
507
 
508
	private void loadBestDeals(final int start, final int limit) {
509
		catalogService.getBestDeals(new AsyncCallback<List<Item>>() {
510
			public void onFailure(Throwable caught) {
511
				caught.printStackTrace();
512
				Window.alert("Could not load best deals.");
513
			}
514
			public void onSuccess(List<Item> result) {
515
				updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
516
				updateItemDescriptionTableRowCount(result.size());
517
				currentlyShowing.setText(LEGEND + "Best Deals");
518
			}
519
		});
520
	}
521
 
522
	private void loadBestSellers(final int start, final int limit) {
523
		catalogService.getBestSellers(new AsyncCallback<List<Item>>() {
524
			public void onFailure(Throwable caught) {
525
				caught.printStackTrace();
526
				Window.alert("Could not load best sellers.");
527
			}
528
			public void onSuccess(List<Item> result) {
529
				updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
530
				updateItemDescriptionTableRowCount(result.size());
531
				currentlyShowing.setText(LEGEND + "Best Sellers");
532
			}
533
		});
534
	}
535
 
536
	private void loadLatestArrivals(final int start, final int limit) {
537
		catalogService.getLatestArrivals(new AsyncCallback<List<Item>>() {
538
			public void onFailure(Throwable caught) {
539
				caught.printStackTrace();
540
				Window.alert("Could not load latest arrivals.");
541
			}
542
			public void onSuccess(List<Item> result) {
543
				updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
544
				updateItemDescriptionTableRowCount(result.size());
545
				currentlyShowing.setText(LEGEND + "Latest Arrivals");
546
			}
547
		});
548
 
549
	}
550
 
551
	private void loadSearchItems(final int start, final int limit) {
552
		catalogService.searchItems(start, limit, searchTerms, new AsyncCallback<List<Item>>() {
553
			public void onFailure(Throwable caught) {
554
				caught.printStackTrace();
555
				Window.alert("Could not load the search results.");
556
			}
557
			public void onSuccess(List<Item> result) {
558
				updateAsyncItemDescriptionTable(start, result);
559
				currentlyShowing.setText(LEGEND + "Search results for " + searchText);
560
			}
561
		});
562
 
563
 
564
		catalogService.getSearchResultCount(searchTerms, new AsyncCallback<Integer>() {
565
 
566
			@Override
567
			public void onFailure(Throwable caught) {
568
				caught.printStackTrace();
569
				Window.alert("Could not get the count of items...");
570
			}
571
 
572
			@Override
573
			public void onSuccess(Integer count) {
574
				updateItemDescriptionTableRowCount(count);
575
			}
576
		});
577
	}
578
 
579
	public void setItemDetails(ItemDetails itemDetails) {
580
		this.itemDetails = itemDetails;
581
	}
582
 
583
	/**
584
	 * This method is called when item is updated in ItemDetails.java to update 
585
	 * attributes in the list also.
586
	 * @param item
587
	 */
588
	public void updateItem(Item item) {
589
		//TODO: Update the item in the list when its details are updated
590
		//        itemDescriptionTable.setText(selectedRow, INDEX_PRODUCT_GROUP, item.getProductGroup());
591
		//        itemDescriptionTable.setText(selectedRow, INDEX_BRAND, item.getBrand());
592
		//        itemDescriptionTable.setText(selectedRow, INDEX_MODEL_NUMBER, item.getModelNumber());
593
		//        itemDescriptionTable.setText(selectedRow, INDEX_MODEL_NAME, item.getModelName());
594
		//        itemDescriptionTable.setText(selectedRow, INDEX_COLOR, item.getColor());
595
	}
596
 
6530 vikram.rag 597
	public void loadInventoryOutofSyncItems() {
598
		currentTreeItemSelection = CatalogTree.INVENTORY_OUTOFSYNC_ITEM_LIST;
11671 vikram.rag 599
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
600
 
6530 vikram.rag 601
	}
11671 vikram.rag 602
	public void loadPrivateDealItems(){
603
		currentTreeItemSelection = CatalogTree.PRIVATE_DEALS;
604
		itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
605
	}
606
 
1961 ankur.sing 607
}