Subversion Repositories SmartDukaan

Rev

Rev 6241 | Rev 6777 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2066 ankur.sing 1
package in.shop2020.catalog.dashboard.client;
2
 
2105 ankur.sing 3
import in.shop2020.catalog.dashboard.shared.Item;
4
import in.shop2020.catalog.dashboard.shared.Utils;
2119 ankur.sing 5
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
6
import in.shop2020.catalog.dashboard.shared.VendorPricings;
2066 ankur.sing 7
 
5217 amit.gupta 8
import java.util.Date;
2105 ankur.sing 9
import java.util.HashMap;
10
import java.util.Map;
4725 phani.kuma 11
import java.util.Map.Entry;
2066 ankur.sing 12
 
2105 ankur.sing 13
import com.google.gwt.core.client.GWT;
14
import com.google.gwt.event.dom.client.ClickEvent;
15
import com.google.gwt.event.dom.client.ClickHandler;
16
import com.google.gwt.uibinder.client.UiBinder;
17
import com.google.gwt.uibinder.client.UiField;
18
import com.google.gwt.uibinder.client.UiHandler;
19
import com.google.gwt.user.client.Window;
20
import com.google.gwt.user.client.rpc.AsyncCallback;
21
import com.google.gwt.user.client.ui.Button;
22
import com.google.gwt.user.client.ui.CheckBox;
23
import com.google.gwt.user.client.ui.DialogBox;
24
import com.google.gwt.user.client.ui.FlexTable;
25
import com.google.gwt.user.client.ui.ListBox;
26
import com.google.gwt.user.client.ui.TextBox;
27
import com.google.gwt.user.client.ui.Widget;
28
import com.google.gwt.user.datepicker.client.DateBox;
29
 
2427 ankur.sing 30
/**
31
 * ItemForm is a DialogBox which is created on the click of Add Item button in ItemActions.
32
 * This contains UI fields to fill up item attributes. It also contains tables for adding
33
 * vendor prices and vendor mapping keys.
34
 *
35
 */
5217 amit.gupta 36
public class ItemForm extends DialogBox implements ComingSoon{
2105 ankur.sing 37
 
38
    interface ItemFormUiBinder extends UiBinder<Widget, ItemForm> {}
39
    private static ItemFormUiBinder uiBinder = GWT.create(ItemFormUiBinder.class);
40
 
5586 phani.kuma 41
    private final static CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
2119 ankur.sing 42
    private final int TABLE_INDEX_VENDORID = 0,
43
                      TABLE_INDEX_VENDOR_DESC = 1, 
44
                      TABLE_INDEX_ITEM_KEY = 2,
45
                      TABLE_INDEX_MOP = 2,
46
                      TABLE_INDEX_DP = 3,
6759 amar.kumar 47
                      TABLE_INDEX_TP = 4,
48
                      TABLE_INDEX_NLC = 5;
5586 phani.kuma 49
 
50
    private static boolean entityIdMandatory = Utils.isEntityIdMandatory();
2105 ankur.sing 51
 
5586 phani.kuma 52
    @UiField TextBox productGroup, catalogItemId;
2105 ankur.sing 53
    @UiField TextBox brand, modelNumber, modelName, color, comments;
54
    @UiField TextBox mrp, sellingPrice, weight, bestDealText, bestDealValue, bestSellingRank;
5217 amit.gupta 55
    @UiField DateBox startDate, retireDate, comingSoonStartDate, expectedArrivalDate;
56
    @UiField Button addButton, cancelButton, comingSoonButton;
6241 amit.gupta 57
    @UiField CheckBox defaultForEntity, risky, itemType, hasItemNo, clearance, showSellingPrice;
2105 ankur.sing 58
    @UiField FlexTable headerVendor, vendorTable;
2119 ankur.sing 59
    @UiField FlexTable headerVendorM, vendorTableM;
5384 phani.kuma 60
    @UiField ListBox preferredVendor;
2105 ankur.sing 61
 
62
    public ItemForm(){
63
        setText("Add New Item");
64
        setWidget(uiBinder.createAndBindUi(this));
2427 ankur.sing 65
        initVendorKeysHeader();
66
        initVendorPricesHeader();
4762 phani.kuma 67
        preferredVendor.addItem("select");
4725 phani.kuma 68
        for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
69
        	preferredVendor.addItem(e.getValue());
70
        }
5586 phani.kuma 71
        if(!entityIdMandatory) {
72
        	catalogItemId.setEnabled(false);
73
        }
2105 ankur.sing 74
    }
75
 
2427 ankur.sing 76
    /**
77
     * initialises vendor item key table header. Creates an Add button and
78
     * adds click event listener to it to create and pop up a dialog for adding 
79
     * a new vendor item key. 
80
     */
81
    private void initVendorKeysHeader(){
2119 ankur.sing 82
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
83
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
2359 ankur.sing 84
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "400px");
2119 ankur.sing 85
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
86
 
87
        headerVendorM.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
2359 ankur.sing 88
        headerVendorM.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor");
2119 ankur.sing 89
        headerVendorM.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
90
 
2359 ankur.sing 91
        headerVendorM.getCellFormatter().setVisible(0, TABLE_INDEX_VENDORID, false);
92
 
2119 ankur.sing 93
        Button addButton = new Button("Add");
94
        headerVendorM.setWidget(0, TABLE_INDEX_ITEM_KEY + 1, addButton);
95
        addButton.addClickHandler(new ClickHandler() {
96
            @Override
97
            public void onClick(ClickEvent event) {
2126 ankur.sing 98
                VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
99
                        modelNumber.getText().trim(), color.getText().trim());
2119 ankur.sing 100
                vendorMappingDialog.updateButton.setText("Add");
101
                vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
102
                    @Override
103
                    public boolean onUpdate(String key, long vendorId) {
104
                        final int row = vendorTableM.getRowCount();
105
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
106
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
2359 ankur.sing 107
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "400px");
2119 ankur.sing 108
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
109
 
110
                        vendorTableM.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
111
                        vendorTableM.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
112
                        vendorTableM.setText(row, TABLE_INDEX_ITEM_KEY, key);
113
                        Button removeButton = new Button("X");
114
                        vendorTableM.setWidget(row, TABLE_INDEX_ITEM_KEY + 1, removeButton);
2359 ankur.sing 115
 
116
                        vendorTableM.getCellFormatter().setVisible(row, TABLE_INDEX_VENDORID, false);
2119 ankur.sing 117
                        removeButton.addClickHandler(new ClickHandler() {
118
                            @Override
119
                            public void onClick(ClickEvent event) {
120
                                vendorTableM.removeRow(row);
121
                            }
122
                        });
123
                        return true;
124
                    }
125
                });
126
                vendorMappingDialog.show();
127
            }
128
        });
129
    }
2105 ankur.sing 130
 
2427 ankur.sing 131
    /**
132
     * initialises vendor prices table header. Creates an Add button and
133
     * adds click event listener to it to create and pop up a dialog for adding 
134
     * a prices for a new vendor 
135
     */
136
    private void initVendorPricesHeader(){
2105 ankur.sing 137
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
138
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
139
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
140
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
141
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
6759 amar.kumar 142
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_NLC, "128px");
143
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_NLC + 1, "50px");
2105 ankur.sing 144
 
145
        headerVendor.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
2359 ankur.sing 146
        headerVendor.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor");
2105 ankur.sing 147
        headerVendor.setText(0, TABLE_INDEX_MOP, "MOP");
148
        headerVendor.setText(0, TABLE_INDEX_DP, "Dealer Price");
149
        headerVendor.setText(0, TABLE_INDEX_TP, "Transfer Price");
6759 amar.kumar 150
        headerVendor.setText(0, TABLE_INDEX_NLC, "NLC");
2119 ankur.sing 151
 
2359 ankur.sing 152
        headerVendor.getCellFormatter().setVisible(0, TABLE_INDEX_VENDORID, false);
153
 
2119 ankur.sing 154
        Button addButton = new Button("Add");
6759 amar.kumar 155
        headerVendor.setWidget(0, TABLE_INDEX_NLC + 1, addButton);
2119 ankur.sing 156
        addButton.addClickHandler(new ClickHandler() {
157
            @Override
158
            public void onClick(ClickEvent event) {
159
                VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
160
                vendorPricesDialog.updateButton.setText("Add");
161
                vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
162
                    @Override
6759 amar.kumar 163
                    public boolean onUpdate(double mop, double dp, double tp, double nlc, long vendorId) {
2119 ankur.sing 164
                        if(!vendorExists(vendorId)) {
165
                            Window.alert("Vendor already exists");
166
                            return false;
167
                        }
168
                        /*if(!validateVendorPrices(mop, dp, tp)) {
169
                            return false;
170
                        }*/
171
                        final int row = vendorTable.getRowCount();
172
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
173
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
174
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
175
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
176
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
6759 amar.kumar 177
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_NLC, "128px");
178
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_NLC + 1, "50px");
2119 ankur.sing 179
 
180
                        vendorTable.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
181
                        vendorTable.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
182
                        vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
183
                        vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
184
                        vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
6759 amar.kumar 185
                        vendorTable.setText(row, TABLE_INDEX_NLC, nlc + "");
2359 ankur.sing 186
 
187
                        vendorTable.getCellFormatter().setVisible(row, TABLE_INDEX_VENDORID, false);
188
 
2119 ankur.sing 189
                        Button removeButton = new Button("X");
6759 amar.kumar 190
                        vendorTable.setWidget(row, TABLE_INDEX_NLC + 1, removeButton);
2119 ankur.sing 191
                        removeButton.addClickHandler(new ClickHandler() {
192
                            @Override
193
                            public void onClick(ClickEvent event) {
194
                                vendorTable.removeRow(row);
195
                            }
196
                        });
197
                        return true;
198
                    }
199
                });
200
                vendorPricesDialog.show();
201
            }
202
        });
2105 ankur.sing 203
    }
204
 
205
    @UiHandler("addButton")
206
    /**
2359 ankur.sing 207
     * On add button click a new Item instance is created and all the information from UI fields is dumped in this item instance.
2427 ankur.sing 208
     * This item instance is then passed to the service to be added to the database.
2105 ankur.sing 209
     */
210
    void addItem(ClickEvent event) {
5586 phani.kuma 211
    	if(entityIdMandatory) {
212
    		long entityId = 0;
213
    		try {
214
                if(!catalogItemId.getText().trim().isEmpty()) {
215
                    entityId = Long.parseLong(catalogItemId.getText().trim());
216
                    if(entityId <= 0) {
217
                        throw new NumberFormatException("Invalid value of Catalog Item Id");
218
                    }
219
                }
220
                else {
221
                	Window.alert("Catalog Item Id can not be empty");
222
                	return;
223
                }
224
            } catch(NumberFormatException ex) {
225
                Window.alert("Invalid value of Catalog Item Id");
2119 ankur.sing 226
                return;
227
            }
5586 phani.kuma 228
	    	catalogService.checkEntityId(entityId, new AsyncCallback<Boolean>() {
229
	            @Override
230
	            public void onFailure(Throwable caught) {
231
	                GWT.log("Error checking Catalog Item Id");
232
	                Window.alert("Error checking Catalog Item Id");
233
	                return;
234
	            }
235
	            @Override
236
	            public void onSuccess(Boolean result) {
237
		        	if(!result) {
238
	                    Window.alert("Invalid value of Catalog Item Id");
239
	                    return;
240
	                }
241
	                addNewItem();
242
		        }
243
	        });
244
    	}
245
    	else {
246
	        catalogService.checkSimilarItem(brand.getText().trim(), modelNumber.getText().trim(),
247
	        		modelName.getText().trim(), color.getText().trim(), new AsyncCallback<Long>() {
248
	            @Override
249
	            public void onFailure(Throwable caught) {
250
	                GWT.log("Error checking similar item");
251
	                Window.alert("Error checking similar item");
252
	                return;
253
	            }
254
	            @Override
255
	            public void onSuccess(Long result) {
256
	                if(result != 0) {
257
	                    Window.alert("Similar product exists with Item Id " + result);
258
	                    return;
259
	                }
260
	                addNewItem();
261
	            }
262
	        });
263
    	}
2119 ankur.sing 264
    }
265
 
2126 ankur.sing 266
    private void addNewItem() {
2105 ankur.sing 267
        Item item = new Item();
268
 
4762 phani.kuma 269
        if(!productGroup.getText().trim().isEmpty()) {
270
        	item.setProductGroup(productGroup.getText().trim());
271
        }
272
        else {
273
        	Window.alert("Product Group can not be empty.");
274
            return;
275
        }
5586 phani.kuma 276
 
277
        if(entityIdMandatory) {
278
	        try {
279
	            if(!catalogItemId.getText().trim().isEmpty()) {
280
	                long entityId = Long.parseLong(catalogItemId.getText().trim());
281
	                if(entityId <= 0) {
282
	                    throw new NumberFormatException("Invalid value of Catalog Item Id");
283
	                }
284
	                item.setCatalogItemId(entityId);
285
	            }
286
	            else {
287
	            	Window.alert("Catalog Item Id can not be empty");
288
	            	return;
289
	            }
290
	        } catch(NumberFormatException ex) {
291
	            Window.alert("Invalid value of Catalog Item Id");
292
	            return;
293
	        }
294
        }
295
 
2105 ankur.sing 296
        item.setBrand(brand.getText().trim());
297
        item.setModelNumber(modelNumber.getText().trim());
298
        item.setModelName(modelName.getText().trim());
299
        item.setColor(color.getText().trim());
300
        item.setComments(comments.getText().trim());
301
        try {
2126 ankur.sing 302
            if(!mrp.getText().trim().isEmpty()) {
303
                double mrpValue = Double.parseDouble(mrp.getText().trim());
304
                if(mrpValue <= 0) {
305
                    throw new NumberFormatException("Negative value of MRP");
306
                }
307
                item.setMrp(mrpValue);
2105 ankur.sing 308
            }
309
        } catch(NumberFormatException ex) {
2126 ankur.sing 310
            Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
2105 ankur.sing 311
            return;
312
        }
313
        try {
2126 ankur.sing 314
            if(!sellingPrice.getText().trim().isEmpty()) {
2427 ankur.sing 315
                double spValue = Double.parseDouble(sellingPrice.getText().trim());
316
                if(spValue <= 0) {
317
                    throw new NumberFormatException("Negative value of Selling price");
318
                }
319
                item.setSellingPrice(spValue);
2126 ankur.sing 320
            }
2105 ankur.sing 321
        } catch(NumberFormatException ex) {
2126 ankur.sing 322
            Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
2105 ankur.sing 323
            return;
324
        }
325
        try {
2126 ankur.sing 326
            if(!weight.getText().trim().isEmpty()) {
2105 ankur.sing 327
                double wtValue = Double.parseDouble(weight.getText().trim());
2126 ankur.sing 328
                if(wtValue <= 0) {
2105 ankur.sing 329
                    throw new NumberFormatException("Negative value of Weight");
330
                }
331
                item.setWeight(wtValue);
332
            }
333
        } catch(NumberFormatException ex) {
2126 ankur.sing 334
            Window.alert("Invalid weight format/value. Value shoule be greater than zero");
2105 ankur.sing 335
            return;
336
        }
337
        try {
338
            if(!startDate.getTextBox().getText().trim().equals("")) {
339
                item.setStartDate(startDate.getValue().getTime());
340
            }
341
        } catch(Exception ex) {
342
            Window.alert("Invalid start date format");
343
            return;
344
        }
5217 amit.gupta 345
        if(comingSoonStartDate.getValue()==null){
346
        	item.setComingSoonStartDate(null);
347
        }else {
348
        	item.setComingSoonStartDate(comingSoonStartDate.getValue().getTime());
349
        }
350
        if(expectedArrivalDate.getValue()==null){
351
        	item.setExpectedArrivalDate(null);
352
        }else {
353
        	item.setExpectedArrivalDate(expectedArrivalDate.getValue().getTime());
354
        }
2105 ankur.sing 355
        item.setBestDealsText(bestDealText.getText().trim());
356
        try {
357
            if(!bestDealValue.getText().trim().equals("")) {
358
                double bdValue = Double.parseDouble(bestDealValue.getText().trim());
359
                if(bdValue < 0) {
360
                    throw new NumberFormatException("Negative value of BestDealValue");
361
                }
362
                item.setBestDealsValue(bdValue);
363
            }
364
        } catch(NumberFormatException ex) {
365
            Window.alert("Invalid best deal value format");
366
            return;
367
        }
368
        try {
369
            if(!bestSellingRank.getText().trim().equals("")) {
370
                long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
371
                if(bsrValue < 0) {
372
                    throw new NumberFormatException("Negative value of Best Selling Rank");
373
                }
374
                item.setBestSellingRank(bsrValue);
375
            }
376
        } catch(NumberFormatException ex) {
377
            Window.alert("Invalid best selling rank format");
378
            return;
379
        }
380
        item.setDefaultForEntity(defaultForEntity.getValue());
2252 ankur.sing 381
        item.setRisky(risky.getValue());
5384 phani.kuma 382
        item.setHasItemNo(hasItemNo.getValue());
383
        item.setItemType(itemType.getValue());
5460 phani.kuma 384
        item.setClearance(clearance.getValue());
4762 phani.kuma 385
        if(preferredVendor.getSelectedIndex() == 0) {
386
        	Window.alert("Invalid Vendor Selected");
387
            return;
388
        }
389
    	else {
390
    		item.setPreferredVendor(Utils.getVendorId(preferredVendor.getItemText(preferredVendor.getSelectedIndex())));
391
    	}
2105 ankur.sing 392
 
2119 ankur.sing 393
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
2105 ankur.sing 394
          Add the instance to map and set the map to the item instance created above.*/
2119 ankur.sing 395
        Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
396
        VendorPricings v;
2105 ankur.sing 397
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
2119 ankur.sing 398
            v = new VendorPricings();
2105 ankur.sing 399
            v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
400
            v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
401
            v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
402
            v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
6759 amar.kumar 403
            v.setNlc(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_NLC)));
2105 ankur.sing 404
            vendorPrices.put(v.getVendorId(), v);
405
        }
2119 ankur.sing 406
        item.setVendorPricesMap(vendorPrices);
2105 ankur.sing 407
 
2119 ankur.sing 408
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
409
        Add the instance to map and set the map to the item instance created above.*/
2359 ankur.sing 410
        Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
2119 ankur.sing 411
        VendorItemMapping vMapping;
412
        for(int row = 0; row < vendorTableM.getRowCount(); row++) {
413
            vMapping = new VendorItemMapping();
414
            vMapping.setItemKey(vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY));
415
            vMapping.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID)));
2359 ankur.sing 416
            vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + vMapping.getItemKey(), vMapping);
2119 ankur.sing 417
        }
2359 ankur.sing 418
        item.setVendorKeysMap(vendorMappings);
2119 ankur.sing 419
 
420
        if(!Utils.validateItem(item)) {
421
            return;
422
        }
423
 
2427 ankur.sing 424
        /*Service method to add item. */
2105 ankur.sing 425
        catalogService.addItem(item, new AsyncCallback<Long>() {
426
            @Override
427
            public void onSuccess(Long result) {
428
                if(result == null || result == 0) {
429
                    Window.alert("Error while adding item");
430
                    return;
431
                }
432
                Window.alert("Item added successfully. Id = " + result);
433
                hide();
434
            }
435
            @Override
436
            public void onFailure(Throwable caught) {
2427 ankur.sing 437
                caught.printStackTrace();
2105 ankur.sing 438
                Window.alert("Error while adding item");
439
            }
440
        });
441
    }
442
 
443
    @UiHandler("cancelButton")
444
    void closeForm(ClickEvent event) {
445
        this.hide();
446
    }
2427 ankur.sing 447
 
2105 ankur.sing 448
    /**
449
     * Checks if vendor details already exists corresponding to the vendor Id parameter. 
450
     */
451
    private boolean vendorExists(long vendorId) {
452
        long id;
453
        for(int i = 0; i < vendorTable.getRowCount(); i++) {
454
            id = Long.parseLong(vendorTable.getText(i, TABLE_INDEX_VENDORID));
455
            if(vendorId == id) {
456
                return false;
457
            }
458
        }
459
        return true;
460
    }
461
 
462
    /**
2119 ankur.sing 463
     * validate vendor prices (MOP, DealerPrice, TransferPrice)
2105 ankur.sing 464
     */
2566 chandransh 465
    @SuppressWarnings("unused")
466
	private boolean validateVendorPrices(double mop, double dp, double tp) {
2105 ankur.sing 467
        double mrpValue;
468
        try {
469
            mrpValue = Double.parseDouble(mrp.getText().trim());
470
        } catch (NumberFormatException ex) {
471
            Window.alert("Invalid MRP value.");
472
            return false;
473
        }
474
        if(mrpValue < mop) {
475
            Window.alert("MOP cannot be more than MRP.");
476
            return false;
477
        }
478
        if(tp > mop) {
479
            Window.alert("Transfer Price cannot be more than MOP.");
480
            return false;
481
        }
482
        return true;
483
    }
5217 amit.gupta 484
 
485
	@UiHandler("comingSoonButton")
486
	void onComingSoonButtonClick(ClickEvent event) {
487
		ComingSoonDialog cd = new ComingSoonDialog(this);
488
		cd.show();
489
	}
490
 
491
	public void setComingSoonStartDate(Date date){
492
		this.comingSoonStartDate.setValue(date);
493
	}
494
	public void setBestDealsText(String bestDealsText){
495
		this.bestDealText.setText(bestDealsText);
496
	}
497
 
498
	public void setExpectedArrivalDate(Date date){
499
		this.expectedArrivalDate.setValue(date);
500
	}
501
 
6241 amit.gupta 502
	public void setShowPrice(boolean b){
503
		this.showSellingPrice.setValue(b);
504
	}
505
 
506
	public boolean isShowPrice(){
507
		return this.showSellingPrice.getValue();
508
	}
509
 
5217 amit.gupta 510
	@Override
511
	public String getBestDealsText() {
512
		return this.bestDealText.getValue();
513
	}
514
 
515
	@Override
516
	public Date getComingSoonStartDate() {
517
		return this.comingSoonStartDate.getValue();
518
	}
519
 
520
	@Override
521
	public Date getExpectedArrivalDate() {
6241 amit.gupta 522
		return this.expectedArrivalDate.getValue();
5217 amit.gupta 523
	}
2066 ankur.sing 524
}