Subversion Repositories SmartDukaan

Rev

Rev 3872 | Go to most recent revision | 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
 
2489 ankur.sing 37
    private static String LEGEND = "Currently Showing: ";
1961 ankur.sing 38
    private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
39
 
40
    interface ItemListUiBinder extends UiBinder<Widget, ItemList> { }
41
    private static final ItemListUiBinder uiBinder = GWT.create(ItemListUiBinder.class);
42
 
43
    interface SelectionStyle extends CssResource{
44
        String selectedRow();
45
        String alertsRow();
46
    }
47
 
3524 chandransh 48
    @UiField CellTable<Item> itemDescriptionTable;
49
    // Create paging controls.
50
    @UiField SimplePager pager = new SimplePager();
51
 
1961 ankur.sing 52
    @UiField SelectionStyle selectionStyle;
2489 ankur.sing 53
    @UiField Label currentlyShowing;
1961 ankur.sing 54
 
2126 ankur.sing 55
    private ItemDetails itemDetails;
56
 
3850 chandransh 57
    private String currentTreeItemSelection = null;
58
 
3872 chandransh 59
    private String searchText = "";
60
 
61
    private List<String> searchTerms = new ArrayList<String>();
62
 
3850 chandransh 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
 
3524 chandransh 112
    // Create a data provider.
113
    ListDataProvider<Item> dataProvider = new ListDataProvider<Item>();
114
 
3850 chandransh 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);
3872 chandransh 144
            else if(currentTreeItemSelection.equals(CatalogTree.SEARCH))
145
                loadSearchItems(start, limit);
6530 vikram.rag 146
            else if(currentTreeItemSelection.equals(CatalogTree.INVENTORY_OUTOFSYNC_ITEM_LIST))
147
                loadInventoryOutofSyncItems(start, limit);
148
 
3850 chandransh 149
        }
150
    };
151
 
1961 ankur.sing 152
    public ItemList() {
153
        initWidget(uiBinder.createAndBindUi(this));
154
        initItemList();
155
    }
3850 chandransh 156
 
6530 vikram.rag 157
    protected void loadInventoryOutofSyncItems(final int offset, final int limit) {
158
        catalogService.getInventoryOutofSyncItems(offset, limit, new AsyncCallback<List<Item>>() {
159
            public void onFailure(Throwable caught) {
160
                caught.printStackTrace();
161
                Window.alert("Could not get Inventory Out of Sync Items...");
162
            }
163
            public void onSuccess(List<Item> result) {
164
                updateAsyncItemDescriptionTable(offset, result);
165
                currentlyShowing.setText(LEGEND + "Inventory Out-of-Sync Items");
166
            }
167
        });
168
 
169
        catalogService.getInventoryOutofSyncItemsCount(new AsyncCallback<Integer>() {
170
 
171
            @Override
172
            public void onFailure(Throwable caught) {
173
                caught.printStackTrace();
174
                Window.alert("Could not get the count of items...");
175
            }
176
 
177
            @Override
178
            public void onSuccess(Integer count) {
179
                updateItemDescriptionTableRowCount(count);
180
            }
181
        });
182
    }
183
 
184
 
185
	private void initItemList() {
3524 chandransh 186
        // Add the columns.        
187
        itemDescriptionTable.addColumn(idColumn, "Item Id");
188
        itemDescriptionTable.addColumn(pgColumn, "Product Group");
189
        itemDescriptionTable.addColumn(brandColumn, "Brand");
190
        itemDescriptionTable.addColumn(modelNumberColumn, "Model Number");
191
        itemDescriptionTable.addColumn(modelNameColumn, "Model Name");
192
        itemDescriptionTable.addColumn(colorColumn, "Color");
193
        itemDescriptionTable.addColumn(categoryColumn, "Category");
194
 
195
        //Set the widths
196
        itemDescriptionTable.setWidth("100%");
197
        itemDescriptionTable.setColumnWidth(idColumn, 80.0, Unit.PX);
198
        itemDescriptionTable.setColumnWidth(pgColumn, 128.0, Unit.PX);
199
        itemDescriptionTable.setColumnWidth(brandColumn, 150.0, Unit.PX);
200
        itemDescriptionTable.setColumnWidth(modelNumberColumn, 200.0, Unit.PX);
201
        itemDescriptionTable.setColumnWidth(modelNameColumn, 200.0, Unit.PX);
202
        itemDescriptionTable.setColumnWidth(colorColumn, 128.0, Unit.PX);
203
        itemDescriptionTable.setColumnWidth(categoryColumn, 220.0, Unit.PX);
204
 
205
        // Connect the table to the data provider.
3850 chandransh 206
        //dataProvider.addDataDisplay(itemDescriptionTable);
207
        asyncDataProvider.addDataDisplay(itemDescriptionTable);
3524 chandransh 208
 
209
        //Add paging support
210
        pager.setDisplay(itemDescriptionTable);
211
 
212
        // Add a selection model to handle item selection.
213
        final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>();
214
        itemDescriptionTable.setSelectionModel(selectionModel);
215
        selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
216
 
217
            @Override
218
            public void onSelectionChange(SelectionChangeEvent event) {
219
                Item selectedItem = selectionModel.getSelectedObject();
220
                catalogService.getItem(selectedItem.getId(), new AsyncCallback<Item>() {
221
                    @Override
222
                    public void onSuccess(Item result) {
223
                        itemDetails.setItemDetails(result);
224
                    }
225
                    @Override
226
                    public void onFailure(Throwable caught) {
227
                        caught.printStackTrace();
228
                        Window.alert("Unable to fetch item details.");
229
                    }
230
                });
231
            }
232
        });
233
 
234
        loadAllRiskyItems();
1961 ankur.sing 235
    }
236
 
3850 chandransh 237
    public void loadAllItems() {
238
        currentTreeItemSelection = CatalogTree.ALL_ITEMS;
239
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
1961 ankur.sing 240
    }
241
 
3850 chandransh 242
    public void loadAllActiveItems() {
243
        currentTreeItemSelection = CatalogTree.ALL_ACTIVE_ITEMS;
244
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
1961 ankur.sing 245
    }
246
 
3850 chandransh 247
    public void loadAllPhasedOutItems() {
248
        currentTreeItemSelection = CatalogTree.ALL_PHASED_OUT_ITEMS;
249
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
250
    }
1961 ankur.sing 251
 
3850 chandransh 252
    public void loadAllPausedItems() {
253
        currentTreeItemSelection = CatalogTree.ALL_PAUSED_ITEMS;
254
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
255
    }
2427 ankur.sing 256
 
3850 chandransh 257
    public void loadAllInProcessItems() {
258
        currentTreeItemSelection = CatalogTree.IN_PROCESS_ITEMS;
259
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
260
    }
261
 
262
    public void loadAllContentCompleteItems(){
263
        currentTreeItemSelection = CatalogTree.CONTENT_COMPLETE_ITEMS;
264
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
265
    }
266
 
267
    public void loadAllRiskyItems() {
268
        currentTreeItemSelection = CatalogTree.RISKY_ITEMS;
269
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
270
    }
271
 
272
    public void loadBestDeals() {
273
        currentTreeItemSelection = CatalogTree.BEST_DEALS;
274
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
275
    }
276
 
3872 chandransh 277
    public void loadBestSellers() {
278
        currentTreeItemSelection = CatalogTree.BEST_SELLERS;
279
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
280
    }
281
 
3850 chandransh 282
    public void loadLatestArrivals() {
283
        currentTreeItemSelection = CatalogTree.LATEST_ARRIVALS;
284
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
285
    }
286
 
3872 chandransh 287
    public void searchForItems(String searchText) {
288
        currentTreeItemSelection = CatalogTree.SEARCH;
289
        this.searchText = searchText.trim().replaceAll("\\s+", " ");
290
        searchTerms = Arrays.asList(this.searchText.split(" "));
3850 chandransh 291
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
292
    }
293
 
294
    private void updateItemDescriptionTableRowCount(Integer count){
295
        asyncDataProvider.updateRowCount(count, true);
296
    }
297
 
298
    private void updateAsyncItemDescriptionTable(int start, List<Item> items){
299
        // Add the data to the data provider, which automatically pushes it to the
300
        // widget.
301
        asyncDataProvider.updateRowData(start, items);
302
    }
303
 
304
    private void loadAllItems(final int offset, final int limit) {
305
        catalogService.getAllItems(offset, limit, new AsyncCallback<List<Item>>() {
1961 ankur.sing 306
            public void onFailure(Throwable caught) {
2126 ankur.sing 307
                caught.printStackTrace();
1992 ankur.sing 308
                Window.alert("Could not get all items...");
1961 ankur.sing 309
            }
310
            public void onSuccess(List<Item> result) {
3850 chandransh 311
                updateAsyncItemDescriptionTable(offset, result);
312
                currentlyShowing.setText(LEGEND + "All Items");
1961 ankur.sing 313
            }
314
        });
3850 chandransh 315
 
316
        catalogService.getItemCountByStatus(false, ItemStatus.ACTIVE, new AsyncCallback<Integer>() {
317
 
318
            @Override
319
            public void onFailure(Throwable caught) {
320
                caught.printStackTrace();
321
                Window.alert("Could not get the count of items...");
322
            }
323
 
324
            @Override
325
            public void onSuccess(Integer count) {
326
                updateItemDescriptionTableRowCount(count);
327
            }
328
        });
1961 ankur.sing 329
    }
330
 
3850 chandransh 331
    private void loadAllActiveItems(final int offset, final int limit) {
332
        catalogService.getAllActiveItems(offset, limit, new AsyncCallback<List<Item>>() {
2119 ankur.sing 333
            public void onFailure(Throwable caught) {
2126 ankur.sing 334
                caught.printStackTrace();
2119 ankur.sing 335
                Window.alert("Could not get all active items...");
336
            }
337
            public void onSuccess(List<Item> result) {
3850 chandransh 338
                updateAsyncItemDescriptionTable(offset, result);
2489 ankur.sing 339
                currentlyShowing.setText(LEGEND + "Active Items");
2119 ankur.sing 340
            }
341
        });
3850 chandransh 342
 
343
        catalogService.getItemCountByStatus(true, ItemStatus.ACTIVE, new AsyncCallback<Integer>() {
344
 
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
        });
2119 ankur.sing 356
    }
357
 
3850 chandransh 358
    private void loadAllPhasedOutItems(final int offset, int limit){
359
        catalogService.getAllPhasedOutItems(offset, limit, new AsyncCallback<List<Item>>() {
2208 ankur.sing 360
            public void onFailure(Throwable caught) {
361
                caught.printStackTrace();
362
                Window.alert("Could not load phased out items...");
363
            }
364
            public void onSuccess(List<Item> result) {
3850 chandransh 365
                updateAsyncItemDescriptionTable(offset, result);
2489 ankur.sing 366
                currentlyShowing.setText(LEGEND + "Phased Out Items");
2208 ankur.sing 367
            }
368
        });
3850 chandransh 369
 
370
        catalogService.getItemCountByStatus(true, ItemStatus.PHASED_OUT, 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
        });
2208 ankur.sing 383
    }
384
 
3850 chandransh 385
    private void loadAllPausedItems(final int offset, int limit) {
386
        catalogService.getAllPausedItems(offset, limit, new AsyncCallback<List<Item>>() {
2208 ankur.sing 387
            public void onFailure(Throwable caught) {
388
                caught.printStackTrace();
389
                Window.alert("Could not load paused items...");
390
            }
391
            public void onSuccess(List<Item> result) {
3850 chandransh 392
                updateAsyncItemDescriptionTable(offset, result);
2489 ankur.sing 393
                currentlyShowing.setText(LEGEND + "Paused Items");
2208 ankur.sing 394
            }
395
        });
3850 chandransh 396
 
397
        catalogService.getItemCountByStatus(true, ItemStatus.PAUSED, 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
        });
2208 ankur.sing 410
    }
411
 
3850 chandransh 412
    private void loadAllInProcessItems(final int offset, int limit) {
413
        catalogService.getAllInProcessItems(offset, limit, new AsyncCallback<List<Item>>() {
2359 ankur.sing 414
            public void onFailure(Throwable caught) {
415
                caught.printStackTrace();
416
                Window.alert("Could not load IN_PROCESS items...");
417
            }
418
            public void onSuccess(List<Item> result) {
3850 chandransh 419
                updateAsyncItemDescriptionTable(offset, result);
2489 ankur.sing 420
                currentlyShowing.setText(LEGEND + "In Process Items");
2359 ankur.sing 421
            }
422
        });
3850 chandransh 423
 
424
        catalogService.getItemCountByStatus(true, ItemStatus.IN_PROCESS, 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
        });
2359 ankur.sing 437
    }
438
 
3850 chandransh 439
    private void loadAllContentCompleteItems(final int offset, int limit) {
440
        catalogService.getAllContentCompleteItems(offset, limit, new AsyncCallback<List<Item>>() {
2359 ankur.sing 441
            public void onFailure(Throwable caught) {
442
                caught.printStackTrace();
443
                Window.alert("Could not load CONTENT_COMPLETE items...");
444
            }
445
            public void onSuccess(List<Item> result) {
3850 chandransh 446
                updateAsyncItemDescriptionTable(offset, result);
2489 ankur.sing 447
                currentlyShowing.setText(LEGEND + "Content Complete Items");
2359 ankur.sing 448
            }
449
        });
3850 chandransh 450
 
451
        catalogService.getItemCountByStatus(true, ItemStatus.CONTENT_COMPLETE, new AsyncCallback<Integer>() {
452
 
453
            @Override
2359 ankur.sing 454
            public void onFailure(Throwable caught) {
455
                caught.printStackTrace();
3850 chandransh 456
                Window.alert("Could not get the count of items...");
2359 ankur.sing 457
            }
3850 chandransh 458
 
459
            @Override
460
            public void onSuccess(Integer count) {
461
                updateItemDescriptionTableRowCount(count);
2359 ankur.sing 462
            }
463
        });
464
    }
465
 
3850 chandransh 466
    private void loadAllRiskyItems(final int start, final int limit) {
467
        catalogService.getRiskyItems(new AsyncCallback<List<Item>>() {
1992 ankur.sing 468
            public void onFailure(Throwable caught) {
2126 ankur.sing 469
                caught.printStackTrace();
3850 chandransh 470
                Window.alert("Could not load RISKY items...");
1992 ankur.sing 471
            }
472
            public void onSuccess(List<Item> result) {
3872 chandransh 473
                updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
3850 chandransh 474
                updateItemDescriptionTableRowCount(result.size());
475
                currentTreeItemSelection = CatalogTree.RISKY_ITEMS;
476
                currentlyShowing.setText(LEGEND + "Risky Items");
1992 ankur.sing 477
            }
478
        });
479
    }
3850 chandransh 480
 
3872 chandransh 481
    private void loadBestDeals(final int start, final int limit) {
482
        catalogService.getBestDeals(new AsyncCallback<List<Item>>() {
1992 ankur.sing 483
            public void onFailure(Throwable caught) {
2126 ankur.sing 484
                caught.printStackTrace();
3872 chandransh 485
                Window.alert("Could not load best deals.");
1992 ankur.sing 486
            }
487
            public void onSuccess(List<Item> result) {
3872 chandransh 488
                updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
3850 chandransh 489
                updateItemDescriptionTableRowCount(result.size());
3872 chandransh 490
                currentlyShowing.setText(LEGEND + "Best Deals");
1992 ankur.sing 491
            }
492
        });
493
    }
3850 chandransh 494
 
495
    private void loadBestSellers(final int start, final int limit) {
1992 ankur.sing 496
        catalogService.getBestSellers(new AsyncCallback<List<Item>>() {
497
            public void onFailure(Throwable caught) {
2126 ankur.sing 498
                caught.printStackTrace();
1992 ankur.sing 499
                Window.alert("Could not load best sellers.");
500
            }
501
            public void onSuccess(List<Item> result) {
3872 chandransh 502
                updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
3850 chandransh 503
                updateItemDescriptionTableRowCount(result.size());
2489 ankur.sing 504
                currentlyShowing.setText(LEGEND + "Best Sellers");
1992 ankur.sing 505
            }
506
        });
507
    }
2126 ankur.sing 508
 
3872 chandransh 509
    private void loadLatestArrivals(final int start, final int limit) {
510
        catalogService.getLatestArrivals(new AsyncCallback<List<Item>>() {
3850 chandransh 511
            public void onFailure(Throwable caught) {
512
                caught.printStackTrace();
3872 chandransh 513
                Window.alert("Could not load latest arrivals.");
3850 chandransh 514
            }
515
            public void onSuccess(List<Item> result) {
3872 chandransh 516
                updateAsyncItemDescriptionTable(start, result.subList(start, Math.min(start + limit, result.size())));
3850 chandransh 517
                updateItemDescriptionTableRowCount(result.size());
3872 chandransh 518
                currentlyShowing.setText(LEGEND + "Latest Arrivals");
3850 chandransh 519
            }
520
        });
3872 chandransh 521
 
3850 chandransh 522
    }
523
 
3872 chandransh 524
    private void loadSearchItems(final int start, final int limit) {
525
        catalogService.searchItems(start, limit, searchTerms, new AsyncCallback<List<Item>>() {
526
            public void onFailure(Throwable caught) {
527
                caught.printStackTrace();
528
                Window.alert("Could not load the search results.");
529
            }
530
            public void onSuccess(List<Item> result) {
531
                updateAsyncItemDescriptionTable(start, result);
532
                currentlyShowing.setText(LEGEND + "Search results for " + searchText);
533
            }
534
        });
535
 
536
 
537
        catalogService.getSearchResultCount(searchTerms, new AsyncCallback<Integer>() {
538
 
539
            @Override
540
            public void onFailure(Throwable caught) {
541
                caught.printStackTrace();
542
                Window.alert("Could not get the count of items...");
543
            }
544
 
545
            @Override
546
            public void onSuccess(Integer count) {
547
                updateItemDescriptionTableRowCount(count);
548
            }
549
        });
550
    }
551
 
2126 ankur.sing 552
    public void setItemDetails(ItemDetails itemDetails) {
553
        this.itemDetails = itemDetails;
554
    }
2489 ankur.sing 555
 
556
    /**
557
     * This method is called when item is updated in ItemDetails.java to update 
558
     * attributes in the list also.
559
     * @param item
560
     */
561
    public void updateItem(Item item) {
3524 chandransh 562
        //TODO: Update the item in the list when its details are updated
563
//        itemDescriptionTable.setText(selectedRow, INDEX_PRODUCT_GROUP, item.getProductGroup());
564
//        itemDescriptionTable.setText(selectedRow, INDEX_BRAND, item.getBrand());
565
//        itemDescriptionTable.setText(selectedRow, INDEX_MODEL_NUMBER, item.getModelNumber());
566
//        itemDescriptionTable.setText(selectedRow, INDEX_MODEL_NAME, item.getModelName());
567
//        itemDescriptionTable.setText(selectedRow, INDEX_COLOR, item.getColor());
2489 ankur.sing 568
    }
6530 vikram.rag 569
 
570
	public void loadInventoryOutofSyncItems() {
571
		currentTreeItemSelection = CatalogTree.INVENTORY_OUTOFSYNC_ITEM_LIST;
572
        itemDescriptionTable.setVisibleRangeAndClearData(new Range(0, pager.getPageSize()), true);
573
 
574
	}
1961 ankur.sing 575
}