Subversion Repositories SmartDukaan

Rev

Rev 2252 | Rev 2387 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2252 Rev 2359
Line 29... Line 29...
29
import com.google.gwt.user.client.ui.Widget;
29
import com.google.gwt.user.client.ui.Widget;
30
import com.google.gwt.user.datepicker.client.DateBox;
30
import com.google.gwt.user.datepicker.client.DateBox;
31
 
31
 
32
public class ItemDetails extends ResizeComposite {
32
public class ItemDetails extends ResizeComposite {
33
 
33
 
34
    private final int TABLE_INDEX_VENDORID = 0, 
34
    private final int TABLE_INDEX_MAPPING_VENDOR_DESC = 0, 
-
 
35
                      TABLE_INDEX_MAPPING_ITEM_KEY = 1,
-
 
36
                      TABLE_INDEX_MAPPING_BUTTON = 2,
35
                      TABLE_INDEX_VENDOR_DESC = 1, 
37
                      TABLE_INDEX_MAPPING_VENDORID = 3, 
36
                      TABLE_INDEX_ITEM_KEY = 2,
38
                      TABLE_INDEX_MAPPING_ITEM_KEY_OLD = 4;
-
 
39
                      
-
 
40
    private final int TABLE_INDEX_PRICING_VENDOR_DESC = 0, 
37
                      TABLE_INDEX_MOP = 2,
41
                      TABLE_INDEX_PRICING_MOP = 1,
38
                      TABLE_INDEX_DP = 3,
42
                      TABLE_INDEX_PRICING_DP = 2,
39
                      TABLE_INDEX_TP = 4;
43
                      TABLE_INDEX_PRICING_TP = 3,
-
 
44
                      TABLE_INDEX_PRICING_BUTTON = 4,
-
 
45
                      TABLE_INDEX_PRICING_VENDORID = 5;
-
 
46
    
40
    private final int TABLE_INDEX_WAREHOUSE_ID = 0,
47
    private final int TABLE_INDEX_WAREHOUSE_ID = 0,
41
                      TABLE_INDEX_WAREHOUSE_DESC = 1,
48
                      TABLE_INDEX_WAREHOUSE_DESC = 1,
42
                      TABLE_INDEX_WAREHOUSE_INV = 2;
49
                      TABLE_INDEX_WAREHOUSE_INV = 2;
-
 
50
    
-
 
51
    private final String PRICE_WIDTH = "100px", VENDOR_DESC_WIDTH = "130px",
-
 
52
                         VENDOR_ID_WIDTH = "100px", ITEM_KEY_WIDTH = "200px",
-
 
53
                         BUTTON_WIDTH = "50px";
43
 
54
 
44
    interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
55
    interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
45
    private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
56
    private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
46
    private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
57
    private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
47
 
58
 
Line 55... Line 66...
55
 
66
 
56
    @UiField ItemDetailStyle style;
67
    @UiField ItemDetailStyle style;
57
    @UiField Label itemId;
68
    @UiField Label itemId;
58
    @UiField TextBox productGroup, brand, modelNumber, modelName, color;
69
    @UiField TextBox productGroup, brand, modelNumber, modelName, color;
59
    @UiField Label contentCategory, catalogItemId;
70
    @UiField Label contentCategory, catalogItemId;
60
    @UiField TextBox comments;
71
    @UiField TextBox statusDesc, comments;
61
    @UiField TextBox sellingPrice, mrp, weight;
72
    @UiField TextBox sellingPrice, mrp, weight;
62
    @UiField Label addedOn, retireDate, updatedOn;
73
    @UiField Label addedOn, retireDate, updatedOn;
63
    @UiField Label itemStatus;
74
    @UiField Label itemStatus;
64
    @UiField TextBox bestDealsText, bestDealsValue; 
75
    @UiField TextBox bestDealsText, bestDealsValue; 
65
    @UiField FlexTable headerAvailability, availabilityTable;
76
    @UiField FlexTable headerAvailability, availabilityTable;
Line 92... Line 103...
92
        brand.setText(item.getBrand());
103
        brand.setText(item.getBrand());
93
        modelNumber.setText(item.getModelNumber());
104
        modelNumber.setText(item.getModelNumber());
94
        modelName.setText(item.getModelName());
105
        modelName.setText(item.getModelName());
95
        color.setText(item.getColor());
106
        color.setText(item.getColor());
96
 
107
 
-
 
108
        statusDesc.setText(item.getItemStatusDesc());
97
        contentCategory.setText(item.getContentCategory()+"");
109
        contentCategory.setText(item.getContentCategory()+"");
98
        comments.setText(item.getComments());
110
        comments.setText(item.getComments());
99
        catalogItemId.setText(item.getCatalogItemId() + "");
111
        catalogItemId.setText(item.getCatalogItemId() + "");
100
 
112
 
101
        mrp.setText(item.getMrp() != -1 ? item.getMrp()+"" : "");
113
        mrp.setText(item.getMrp() != -1 ? item.getMrp()+"" : "");
Line 114... Line 126...
114
        risky.setValue(item.isRisky());
126
        risky.setValue(item.isRisky());
115
        
127
        
116
        itemStatus.setText(item.getItemStatus());
128
        itemStatus.setText(item.getItemStatus());
117
 
129
 
118
        updateAvailabilityTable(item.getAvailability());
130
        updateAvailabilityTable(item.getAvailability());
119
        updateMappingTable(item.getVendorMappingsMap());
131
        updateMappingTable(item.getVendorKeysMap());
120
        updatePricingTable(item.getVendorPricesMap());
132
        updatePricingTable(item.getVendorPricesMap());
121
    }
133
    }
122
 
134
 
123
    private void initAvailabilityHeader(){
135
    private void initAvailabilityHeader(){
124
        // Initialize the header.
136
        // Initialize the header.
Line 132... Line 144...
132
 
144
 
133
    }
145
    }
134
 
146
 
135
    private void initMappingHeader(){
147
    private void initMappingHeader(){
136
        // Initialize the header.
148
        // Initialize the header.
137
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
149
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
138
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
150
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
139
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
151
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
140
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
152
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
-
 
153
        headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
141
 
154
 
142
        headerVendorM.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
155
        headerVendorM.setText(0, TABLE_INDEX_MAPPING_VENDORID, "Vendor Id");
143
        headerVendorM.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
156
        headerVendorM.setText(0, TABLE_INDEX_MAPPING_VENDOR_DESC, "Vendor");
144
        headerVendorM.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
157
        headerVendorM.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY, "Item Key");
-
 
158
        headerVendorM.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, "Prev Item Key");
-
 
159
        
-
 
160
        headerVendorM.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_VENDORID, false);
-
 
161
        headerVendorM.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
145
        
162
        
146
        Button addButton = new Button("Add");
163
        Button addButton = new Button("Add");
147
        headerVendorM.setWidget(0, TABLE_INDEX_ITEM_KEY + 1, addButton);
164
        headerVendorM.setWidget(0, TABLE_INDEX_MAPPING_BUTTON, addButton);
148
        addButton.addClickHandler(new ClickHandler() {
165
        addButton.addClickHandler(new ClickHandler() {
149
            @Override
166
            @Override
150
            public void onClick(ClickEvent event) {
167
            public void onClick(ClickEvent event) {
151
                VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
168
                VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
152
                        modelNumber.getText().trim(), color.getText().trim());
169
                        modelNumber.getText().trim(), color.getText().trim());
153
                vendorMappingDialog.updateButton.setText("Add");
170
                vendorMappingDialog.updateButton.setText("Add");
154
                vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
171
                vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
155
                    @Override
172
                    @Override
156
                    public boolean onUpdate(String key, long vendorId) {
173
                    public boolean onUpdate(String key, long vendorId) {
157
                        int row = vendorTableM.getRowCount();
174
                        int row = vendorTableM.getRowCount();
158
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
175
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
159
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
176
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
160
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
177
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
-
 
178
                        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
-
 
179
                        
-
 
180
                        vendorTableM.setText(row, TABLE_INDEX_MAPPING_VENDORID, vendorId + "");
-
 
181
                        vendorTableM.setText(row, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
-
 
182
                        vendorTableM.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, key);
-
 
183
                        vendorTableM.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, key);
161
                        
184
                        
162
                        vendorTableM.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
185
                        vendorTableM.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_VENDORID, false);
163
                        vendorTableM.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
-
 
164
                        vendorTableM.setText(row, TABLE_INDEX_ITEM_KEY, key);
186
                        vendorTableM.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
165
                        return true;
187
                        return true;
166
                    }
188
                    }
167
                });
189
                });
168
                vendorMappingDialog.show();
190
                vendorMappingDialog.show();
169
            }
191
            }
Line 171... Line 193...
171
    }
193
    }
172
 
194
 
173
    
195
    
174
    private void initPricingHeader(){
196
    private void initPricingHeader(){
175
        // Initialize the header.
197
        // Initialize the header.
176
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
198
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
177
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
199
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
178
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
-
 
179
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
200
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
180
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
201
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
181
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
202
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
182
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP + 1, "50px");
203
        headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
183
 
204
 
184
        headerVendor.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
205
        headerVendor.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
185
        headerVendor.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
206
        headerVendor.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
186
        headerVendor.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
207
        headerVendor.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
187
        headerVendor.setText(0, TABLE_INDEX_MOP, "MOP");
208
        headerVendor.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
188
        headerVendor.setText(0, TABLE_INDEX_DP, "Dealer Price");
209
        headerVendor.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
-
 
210
        
189
        headerVendor.setText(0, TABLE_INDEX_TP, "Transfer Price");
211
        headerVendor.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
190
        
212
        
191
        Button addButton = new Button("Add");
213
        Button addButton = new Button("Add");
192
        headerVendor.setWidget(0, TABLE_INDEX_TP + 1, addButton);
214
        headerVendor.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
193
        addButton.addClickHandler(new ClickHandler() {
215
        addButton.addClickHandler(new ClickHandler() {
194
            @Override
216
            @Override
195
            public void onClick(ClickEvent event) {
217
            public void onClick(ClickEvent event) {
196
                VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
218
                VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
197
                vendorPricesDialog.updateButton.setText("Add");
219
                vendorPricesDialog.updateButton.setText("Add");
Line 204... Line 226...
204
                        }
226
                        }
205
                        /*if(!validateVendorPrices(mop, dp, tp)) {
227
                        /*if(!validateVendorPrices(mop, dp, tp)) {
206
                            return false;
228
                            return false;
207
                        }*/
229
                        }*/
208
                        int row = vendorTable.getRowCount();
230
                        int row = vendorTable.getRowCount();
209
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
231
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
210
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
232
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
211
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
233
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
212
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
234
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
213
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
235
                        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
-
 
236
                        
-
 
237
                        vendorTable.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
-
 
238
                        vendorTable.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
-
 
239
                        vendorTable.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
-
 
240
                        vendorTable.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
-
 
241
                        vendorTable.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
214
                        
242
                        
215
                        vendorTable.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
243
                        vendorTable.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
216
                        vendorTable.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
-
 
217
                        vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
-
 
218
                        vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
-
 
219
                        vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
-
 
220
                        return true;
244
                        return true;
221
                    }
245
                    }
222
                });
246
                });
223
                vendorPricesDialog.show();
247
                vendorPricesDialog.show();
224
            }
248
            }
Line 232... Line 256...
232
        }
256
        }
233
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
257
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
234
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
258
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
235
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
259
        availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
236
 
260
 
237
 
-
 
238
        int i=0;
261
        int i=0;
239
        for(Entry<Long, Long> availability : availabilityMap.entrySet()){
262
        for(Entry<Long, Long> availability : availabilityMap.entrySet()){
240
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, availability.getKey() + "");
263
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, availability.getKey() + "");
241
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
264
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
242
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
265
            availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
243
            i++;
266
            i++;
244
        }
267
        }
245
    }
268
    }
246
    
269
    
247
    private void updateMappingTable(Map<Long, VendorItemMapping> vendorMappingsMap){
270
    private void updateMappingTable(Map<String, VendorItemMapping> vendorMappingsMap){
248
        vendorTableM.removeAllRows();
271
        vendorTableM.removeAllRows();
249
        
272
        
250
        if(vendorMappingsMap == null || vendorMappingsMap.isEmpty()) {
273
        if(vendorMappingsMap == null || vendorMappingsMap.isEmpty()) {
251
            return;
274
            return;
252
        }
275
        }
253
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
276
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
254
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
277
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
255
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
278
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
256
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
279
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
-
 
280
        vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
257
 
281
 
258
        int i=0;
282
        int i=0;
259
        for(VendorItemMapping vendorMapping : vendorMappingsMap.values()){
283
        for(Entry<String, VendorItemMapping> e : vendorMappingsMap.entrySet()){
-
 
284
            VendorItemMapping vendorMapping = e.getValue();
260
            vendorTableM.setText(i, TABLE_INDEX_VENDORID, vendorMapping.getVendorId() + "");
285
            vendorTableM.setText(i, TABLE_INDEX_MAPPING_VENDORID, vendorMapping.getVendorId() + "");
261
            vendorTableM.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
286
            vendorTableM.setText(i, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
262
            vendorTableM.setText(i, TABLE_INDEX_ITEM_KEY, vendorMapping.getItemKey());
287
            vendorTableM.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY, vendorMapping.getItemKey());
-
 
288
            vendorTableM.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1));
263
            Button editButton = new Button("Edit");
289
            Button editButton = new Button("Edit");
264
            vendorTableM.setWidget(i, TABLE_INDEX_ITEM_KEY + 1, editButton);
290
            vendorTableM.setWidget(i, TABLE_INDEX_MAPPING_BUTTON, editButton);
265
            i++;
-
 
266
            editButton.addClickHandler(new ClickHandler() {
291
            editButton.addClickHandler(new ClickHandler() {
267
                @Override
292
                @Override
268
                public void onClick(ClickEvent event) {
293
                public void onClick(ClickEvent event) {
269
                    Cell cell = vendorTableM.getCellForEvent(event);
294
                    Cell cell = vendorTableM.getCellForEvent(event);
270
                    int row = cell.getRowIndex();
295
                    int row = cell.getRowIndex();
271
                    long vendorId = Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID));
296
                    long vendorId = Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_MAPPING_VENDORID));
272
                    updateVendorMapping(vendorId, row);
297
                    updateVendorMapping(vendorId, row);
273
                }
298
                }
274
            });
299
            });
-
 
300
            vendorTableM.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_VENDORID, false);
-
 
301
            vendorTableM.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
-
 
302
            i++;
275
        }
303
        }
276
    }
304
    }
277
 
305
 
278
    private void updatePricingTable(Map<Long, VendorPricings> vendorPricingMap){
306
    private void updatePricingTable(Map<Long, VendorPricings> vendorPricingMap){
279
        vendorTable.removeAllRows();
307
        vendorTable.removeAllRows();
280
        
308
        
281
        if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
309
        if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
282
            return;
310
            return;
283
        }
311
        }
284
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
312
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
285
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
313
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
286
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
314
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
287
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
315
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
288
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
316
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
289
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP + 1, "50px");
317
        vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
290
 
318
 
291
 
319
 
292
        int i=0;
320
        int i=0;
293
        for(VendorPricings vendorDetail : vendorPricingMap.values()){
321
        for(VendorPricings vendorDetail : vendorPricingMap.values()){
294
            vendorTable.setText(i, TABLE_INDEX_VENDORID, vendorDetail.getVendorId() + "");
322
            vendorTable.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
295
            vendorTable.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
323
            vendorTable.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
296
            vendorTable.setText(i, TABLE_INDEX_MOP, vendorDetail.getMop() + "");
324
            vendorTable.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
297
            vendorTable.setText(i, TABLE_INDEX_DP, vendorDetail.getDealerPrice() + "");
325
            vendorTable.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
298
            vendorTable.setText(i, TABLE_INDEX_TP, vendorDetail.getTransferPrice() + "");
326
            vendorTable.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
299
            Button editButton = new Button("Edit");
327
            Button editButton = new Button("Edit");
300
            vendorTable.setWidget(i, TABLE_INDEX_TP + 1, editButton);
328
            vendorTable.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
301
            i++;
-
 
302
            editButton.addClickHandler(new ClickHandler() {
329
            editButton.addClickHandler(new ClickHandler() {
303
                @Override
330
                @Override
304
                public void onClick(ClickEvent event) {
331
                public void onClick(ClickEvent event) {
305
                    Cell cell = vendorTable.getCellForEvent(event);
332
                    Cell cell = vendorTable.getCellForEvent(event);
306
                    int row = cell.getRowIndex();
333
                    int row = cell.getRowIndex();
307
                    long vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
334
                    long vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_PRICING_VENDORID));
308
                    updateVendorPrices(vendorId, row);
335
                    updateVendorPrices(vendorId, row);
309
                }
336
                }
310
            });
337
            });
-
 
338
            vendorTable.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
-
 
339
            i++;
311
        }
340
        }
312
    }
341
    }
313
 
342
 
314
    
343
    
315
    void updateItem() {
344
    void updateItem() {
Line 461... Line 490...
461
          Add the instance to map and set the map to the item instance created above.*/
490
          Add the instance to map and set the map to the item instance created above.*/
462
        Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
491
        Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
463
        VendorPricings v;
492
        VendorPricings v;
464
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
493
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
465
            v = new VendorPricings();
494
            v = new VendorPricings();
466
            v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
495
            v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_MOP)));
467
            v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
496
            v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_DP)));
468
            v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
497
            v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_TP)));
469
            v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
498
            v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_PRICING_VENDORID)));
470
            vendorPrices.put(v.getVendorId(), v);
499
            vendorPrices.put(v.getVendorId(), v);
471
            newItem.setMop(v.getMop());
500
            newItem.setMop(v.getMop());
472
            newItem.setDealerPrice(v.getDealerPrice());
501
            newItem.setDealerPrice(v.getDealerPrice());
473
            newItem.setTransferPrice(v.getTransferPrice());
502
            newItem.setTransferPrice(v.getTransferPrice());
474
        }
503
        }
475
        newItem.setVendorPricesMap(vendorPrices);
504
        newItem.setVendorPricesMap(vendorPrices);
476
        
505
        newItem.setItemStatusDesc(statusDesc.getText().trim());
477
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
506
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
478
        Add the instance to map and set the map to the item instance created above.*/
507
        Add the instance to map and set the map to the item instance created above.*/
479
        Map<Long, VendorItemMapping> vendorMappings = new HashMap<Long, VendorItemMapping>();
508
        Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
480
        VendorItemMapping vMapping;
509
        VendorItemMapping vMapping;
481
        for(int row = 0; row < vendorTableM.getRowCount(); row++) {
510
        for(int row = 0; row < vendorTableM.getRowCount(); row++) {
482
            vMapping = new VendorItemMapping();
511
            vMapping = new VendorItemMapping();
483
            vMapping.setItemKey(vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY));
512
            vMapping.setItemKey(vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY));
484
            vMapping.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID)));
513
            vMapping.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_MAPPING_VENDORID)));
485
            vendorMappings.put(vMapping.getVendorId(), vMapping);
514
            vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD), vMapping);
486
        }
515
        }
487
        newItem.setVendorMappingsMap(vendorMappings);
516
        newItem.setVendorKeysMap(vendorMappings);
488
        
517
        
489
        newItem.setContentCategoryId(item.getContentCategoryId());
518
        newItem.setContentCategoryId(item.getContentCategoryId());
490
        newItem.setFeatureId(item.getFeatureId());
519
        newItem.setFeatureId(item.getFeatureId());
491
        newItem.setFeatureDescription(item.getFeatureDescription());
520
        newItem.setFeatureDescription(item.getFeatureDescription());
492
        newItem.setAddedOn(item.getAddedOn());
521
        newItem.setAddedOn(item.getAddedOn());
Line 498... Line 527...
498
        
527
        
499
        return true;
528
        return true;
500
    }
529
    }
501
 
530
 
502
    private void updateVendorPrices(final long vendorId, final int row) {
531
    private void updateVendorPrices(final long vendorId, final int row) {
503
        String mop = vendorTable.getText(row, TABLE_INDEX_MOP);
532
        String mop = vendorTable.getText(row, TABLE_INDEX_PRICING_MOP);
504
        String dp = vendorTable.getText(row, TABLE_INDEX_DP);
533
        String dp = vendorTable.getText(row, TABLE_INDEX_PRICING_DP);
505
        String tp = vendorTable.getText(row, TABLE_INDEX_TP);
534
        String tp = vendorTable.getText(row, TABLE_INDEX_PRICING_TP);
506
        String key = vendorTable.getText(row, TABLE_INDEX_ITEM_KEY);
-
 
507
        VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
535
        VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
508
        pricesDialog.updateButton.setText("Update");
536
        pricesDialog.updateButton.setText("Update");
509
        pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
537
        pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
510
            @Override
538
            @Override
511
            public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
539
            public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
512
                if(!validateVendorPrices(mop, dp, tp)) {
540
                if(!validateVendorPrices(mop, dp, tp)) {
513
                    return false;
541
                    return false;
514
                }
542
                }
515
                vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
543
                vendorTable.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
516
                vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
544
                vendorTable.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
517
                vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
545
                vendorTable.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
518
                return true;
546
                return true;
519
            }
547
            }
520
        });
548
        });
521
        pricesDialog.show();
549
        pricesDialog.show();
522
    }
550
    }
523
    
551
    
524
    private void updateVendorMapping(final long vendorId, final int row) {
552
    private void updateVendorMapping(final long vendorId, final int row) {
525
        String key = vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY);
553
        String key = vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
526
        VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
554
        VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(), 
527
                modelNumber.getText().trim(), color.getText().trim(), key);
555
                modelNumber.getText().trim(), color.getText().trim(), key);
528
        mappingDialog.updateButton.setText("Update");
556
        mappingDialog.updateButton.setText("Update");
529
        mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
557
        mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
530
            @Override
558
            @Override
531
            public boolean onUpdate(String itemKey, long vendorId) {
559
            public boolean onUpdate(String itemKey, long vendorId) {
532
                if(itemKey == null || itemKey.equals("")) {
560
                if(itemKey == null || itemKey.equals("")) {
533
                    Window.alert("Item key cannot be empty.");
561
                    Window.alert("Item key cannot be empty.");
534
                    return false;
562
                    return false;
535
                }
563
                }
536
                vendorTableM.setText(row, TABLE_INDEX_ITEM_KEY, itemKey);
564
                vendorTableM.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, itemKey);
537
                return true;
565
                return true;
538
            }
566
            }
539
        });
567
        });
540
        mappingDialog.show();
568
        mappingDialog.show();
541
    }
569
    }
Line 555... Line 583...
555
            sb.append("\nModel Name");
583
            sb.append("\nModel Name");
556
        }
584
        }
557
        if(!color.getText().trim().equals(item.getColor())) {
585
        if(!color.getText().trim().equals(item.getColor())) {
558
            sb.append("\nColor");
586
            sb.append("\nColor");
559
        }
587
        }
-
 
588
        if(!statusDesc.getText().trim().equals(item.getItemStatusDesc())) {
-
 
589
            sb.append("\nStatus Description");
-
 
590
        }
560
        if(!comments.getText().trim().equals(item.getComments())) {
591
        if(!comments.getText().trim().equals(item.getComments())) {
561
            sb.append("\nComments");
592
            sb.append("\nComments");
562
        }
593
        }
563
        if(newItem.getMrp() != item.getMrp()) {
594
        if(newItem.getMrp() != item.getMrp()) {
564
            sb.append("\nMRP");
595
            sb.append("\nMRP");
Line 588... Line 619...
588
            sb.append("\nStart Date");
619
            sb.append("\nStart Date");
589
        }
620
        }
590
        VendorPricings vendorPricings;
621
        VendorPricings vendorPricings;
591
        long vendorId;
622
        long vendorId;
592
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
623
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
593
            vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
624
            vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_PRICING_VENDORID));
594
            vendorPricings = item.getVendorPricesMap().get(vendorId);
625
            vendorPricings = item.getVendorPricesMap().get(vendorId);
-
 
626
            if(vendorPricings == null) {
-
 
627
                sb.append("\nVendor Prices (Vendor:" + vendorId + ")");
-
 
628
                continue;
-
 
629
            }
595
            if(vendorPricings.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
630
            if(vendorPricings.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_MOP))) {
596
                sb.append("\nMOP (Vendor:" + vendorId + ")");
631
                sb.append("\nMOP (Vendor:" + vendorId + ")");
597
            }
632
            }
598
            if(vendorPricings.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
633
            if(vendorPricings.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_DP))) {
599
                sb.append("\nDealer Price (Vendor:" + vendorId + ")");
634
                sb.append("\nDealer Price (Vendor:" + vendorId + ")");
600
            }
635
            }
601
            if(vendorPricings.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP))) {
636
            if(vendorPricings.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_TP))) {
602
                sb.append("\nTransfer Price (Vendor:" + vendorId + ")");
637
                sb.append("\nTransfer Price (Vendor:" + vendorId + ")");
603
            }
638
            }
604
        }
639
        }
605
        return sb.toString();
640
        return sb.toString();
606
    }
641
    }
Line 644... Line 679...
644
    }
679
    }
645
    
680
    
646
    private boolean vendorExists(long vendorId) {
681
    private boolean vendorExists(long vendorId) {
647
        long id;
682
        long id;
648
        for(int i = 0; i < vendorTable.getRowCount(); i++) {
683
        for(int i = 0; i < vendorTable.getRowCount(); i++) {
649
            id = Long.parseLong(vendorTable.getText(i, TABLE_INDEX_VENDORID));
684
            id = Long.parseLong(vendorTable.getText(i, TABLE_INDEX_PRICING_VENDORID));
650
            if(vendorId == id) {
685
            if(vendorId == id) {
651
                return false;
686
                return false;
652
            }
687
            }
653
        }
688
        }
654
        return true;
689
        return true;