| Line 27... |
Line 27... |
| 27 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
27 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
| 28 |
import com.google.gwt.user.client.ui.TextBox;
|
28 |
import com.google.gwt.user.client.ui.TextBox;
|
| 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 |
/**
|
| - |
|
33 |
* Panel contains fields for item details. Some of these fields are editable.
|
| - |
|
34 |
* It also contains vendor item pricings, vendor item keys, and item availability in tabular format.
|
| - |
|
35 |
* Item availability is made invisible for time being
|
| - |
|
36 |
*/
|
| 32 |
public class ItemDetails extends ResizeComposite {
|
37 |
public class ItemDetails extends ResizeComposite {
|
| 33 |
|
38 |
|
| 34 |
private final int TABLE_INDEX_MAPPING_VENDOR_DESC = 0,
|
39 |
private final int TABLE_INDEX_MAPPING_VENDOR_DESC = 0,
|
| 35 |
TABLE_INDEX_MAPPING_ITEM_KEY = 1,
|
40 |
TABLE_INDEX_MAPPING_ITEM_KEY = 1,
|
| 36 |
TABLE_INDEX_MAPPING_BUTTON = 2,
|
41 |
TABLE_INDEX_MAPPING_BUTTON = 2,
|
| Line 72... |
Line 77... |
| 72 |
@UiField TextBox sellingPrice, mrp, weight;
|
77 |
@UiField TextBox sellingPrice, mrp, weight;
|
| 73 |
@UiField Label addedOn, retireDate, updatedOn;
|
78 |
@UiField Label addedOn, retireDate, updatedOn;
|
| 74 |
@UiField Label itemStatus;
|
79 |
@UiField Label itemStatus;
|
| 75 |
@UiField TextBox bestDealsText, bestDealsValue;
|
80 |
@UiField TextBox bestDealsText, bestDealsValue;
|
| 76 |
@UiField FlexTable headerAvailability, availabilityTable;
|
81 |
@UiField FlexTable headerAvailability, availabilityTable;
|
| 77 |
@UiField FlexTable headerVendorM, vendorTableM;
|
82 |
@UiField FlexTable headerVendorItemKey, tableVendorItemKey;
|
| 78 |
@UiField FlexTable headerVendor, vendorTable;
|
83 |
@UiField FlexTable headerVendorPrices, tableVendorPrices;
|
| 79 |
@UiField TextBox bestSellingRank;
|
84 |
@UiField TextBox bestSellingRank;
|
| 80 |
@UiField CheckBox defaultForEntity, risky;
|
85 |
@UiField CheckBox defaultForEntity, risky;
|
| 81 |
//@UiField Button submit;
|
- |
|
| 82 |
@UiField DateBox startDate;
|
86 |
@UiField DateBox startDate;
|
| 83 |
|
87 |
|
| 84 |
public ItemDetails(Item item){
|
88 |
public ItemDetails(Item item){
|
| 85 |
this();
|
89 |
this();
|
| 86 |
setItemDetails(item);
|
90 |
setItemDetails(item);
|
| 87 |
}
|
91 |
}
|
| 88 |
|
92 |
|
| 89 |
public ItemDetails() {
|
93 |
public ItemDetails() {
|
| 90 |
initWidget(uiBinder.createAndBindUi(this));
|
94 |
initWidget(uiBinder.createAndBindUi(this));
|
| 91 |
initAvailabilityHeader();
|
95 |
initAvailabilityHeader();
|
| 92 |
initMappingHeader();
|
96 |
initVendorKeysHeader();
|
| 93 |
initPricingHeader();
|
97 |
initVendorPricingHeader();
|
| 94 |
|
98 |
|
| 95 |
headerAvailability.setVisible(false);
|
99 |
headerAvailability.setVisible(false);
|
| 96 |
availabilityTable.setVisible(false);
|
100 |
availabilityTable.setVisible(false);
|
| 97 |
}
|
101 |
}
|
| 98 |
|
102 |
|
| - |
|
103 |
/**
|
| - |
|
104 |
* Sets the UI fields with item object attributes
|
| - |
|
105 |
* Also populates tables for vendor prices, keys and item availability
|
| - |
|
106 |
* @param item
|
| - |
|
107 |
*/
|
| 99 |
public void setItemDetails(Item item){
|
108 |
public void setItemDetails(Item item){
|
| 100 |
this.item = item;
|
109 |
this.item = item;
|
| 101 |
itemId.setText(item.getId()+"");
|
110 |
itemId.setText(item.getId()+"");
|
| 102 |
productGroup.setText(item.getProductGroup());
|
111 |
productGroup.setText(item.getProductGroup());
|
| 103 |
brand.setText(item.getBrand());
|
112 |
brand.setText(item.getBrand());
|
| Line 126... |
Line 135... |
| 126 |
risky.setValue(item.isRisky());
|
135 |
risky.setValue(item.isRisky());
|
| 127 |
|
136 |
|
| 128 |
itemStatus.setText(item.getItemStatus());
|
137 |
itemStatus.setText(item.getItemStatus());
|
| 129 |
|
138 |
|
| 130 |
updateAvailabilityTable(item.getAvailability());
|
139 |
updateAvailabilityTable(item.getAvailability());
|
| 131 |
updateMappingTable(item.getVendorKeysMap());
|
140 |
updateVendorKeysTable(item.getVendorKeysMap());
|
| 132 |
updatePricingTable(item.getVendorPricesMap());
|
141 |
updateVendorPricingTable(item.getVendorPricesMap());
|
| 133 |
}
|
142 |
}
|
| 134 |
|
143 |
|
| - |
|
144 |
/**
|
| - |
|
145 |
* initialise item availability table header.
|
| - |
|
146 |
*/
|
| 135 |
private void initAvailabilityHeader(){
|
147 |
private void initAvailabilityHeader(){
|
| 136 |
// Initialize the header.
|
- |
|
| 137 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
148 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
| 138 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
|
149 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
|
| 139 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
150 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
| 140 |
|
151 |
|
| 141 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
|
152 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
|
| 142 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
153 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
| 143 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
154 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
| 144 |
|
155 |
|
| 145 |
}
|
156 |
}
|
| 146 |
|
157 |
|
| - |
|
158 |
/**
|
| - |
|
159 |
* initialises vendor item key table header. Creates an Add button and
|
| - |
|
160 |
* adds click event listener to it to create and pop up a dialog for adding
|
| 147 |
private void initMappingHeader(){
|
161 |
* a new vendor item key.
|
| - |
|
162 |
*/
|
| 148 |
// Initialize the header.
|
163 |
private void initVendorKeysHeader(){
|
| 149 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
164 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
| 150 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
165 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
| 151 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
166 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
| 152 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
167 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
| 153 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
168 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
| 154 |
|
169 |
|
| 155 |
headerVendorM.setText(0, TABLE_INDEX_MAPPING_VENDORID, "Vendor Id");
|
170 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDORID, "Vendor Id");
|
| 156 |
headerVendorM.setText(0, TABLE_INDEX_MAPPING_VENDOR_DESC, "Vendor");
|
171 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDOR_DESC, "Vendor");
|
| 157 |
headerVendorM.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY, "Item Key");
|
172 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY, "Item Key");
|
| 158 |
headerVendorM.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, "Prev Item Key");
|
173 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, "Prev Item Key");
|
| 159 |
|
174 |
|
| 160 |
headerVendorM.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_VENDORID, false);
|
175 |
headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_VENDORID, false);
|
| 161 |
headerVendorM.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
176 |
headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 162 |
|
177 |
|
| 163 |
Button addButton = new Button("Add");
|
178 |
Button addButton = new Button("Add");
|
| 164 |
headerVendorM.setWidget(0, TABLE_INDEX_MAPPING_BUTTON, addButton);
|
179 |
headerVendorItemKey.setWidget(0, TABLE_INDEX_MAPPING_BUTTON, addButton);
|
| 165 |
addButton.addClickHandler(new ClickHandler() {
|
180 |
addButton.addClickHandler(new ClickHandler() {
|
| 166 |
@Override
|
181 |
@Override
|
| 167 |
public void onClick(ClickEvent event) {
|
182 |
public void onClick(ClickEvent event) {
|
| 168 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
183 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
| 169 |
modelNumber.getText().trim(), color.getText().trim());
|
184 |
modelNumber.getText().trim(), color.getText().trim());
|
| 170 |
vendorMappingDialog.updateButton.setText("Add");
|
185 |
vendorMappingDialog.updateButton.setText("Add");
|
| 171 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
186 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
| 172 |
@Override
|
187 |
@Override
|
| 173 |
public boolean onUpdate(String key, long vendorId) {
|
188 |
public boolean onUpdate(String key, long vendorId) {
|
| 174 |
int row = vendorTableM.getRowCount();
|
189 |
int row = tableVendorItemKey.getRowCount();
|
| 175 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
190 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
| 176 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
191 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
| 177 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
192 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
| 178 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
193 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
| 179 |
|
194 |
|
| 180 |
vendorTableM.setText(row, TABLE_INDEX_MAPPING_VENDORID, vendorId + "");
|
195 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDORID, vendorId + "");
|
| 181 |
vendorTableM.setText(row, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
196 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
| 182 |
vendorTableM.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, key);
|
197 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, key);
|
| 183 |
vendorTableM.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, key);
|
198 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, key);
|
| 184 |
|
199 |
|
| 185 |
vendorTableM.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_VENDORID, false);
|
200 |
tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_VENDORID, false);
|
| 186 |
vendorTableM.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
201 |
tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 187 |
return true;
|
202 |
return true;
|
| 188 |
}
|
203 |
}
|
| 189 |
});
|
204 |
});
|
| 190 |
vendorMappingDialog.show();
|
205 |
vendorMappingDialog.show();
|
| 191 |
}
|
206 |
}
|
| 192 |
});
|
207 |
});
|
| 193 |
}
|
208 |
}
|
| 194 |
|
209 |
|
| 195 |
|
210 |
/**
|
| - |
|
211 |
* initialises vendor prices table header. Creates an Add button and
|
| - |
|
212 |
* adds click event listener to it to create and pop up a dialog for adding
|
| 196 |
private void initPricingHeader(){
|
213 |
* a prices for a new vendor
|
| - |
|
214 |
*/
|
| 197 |
// Initialize the header.
|
215 |
private void initVendorPricingHeader(){
|
| 198 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
216 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
| 199 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
217 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
| 200 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
218 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
| 201 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
219 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
| 202 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
220 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
| 203 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
221 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
| 204 |
|
222 |
|
| 205 |
headerVendor.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
|
223 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
|
| 206 |
headerVendor.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
|
224 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
|
| 207 |
headerVendor.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
|
225 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
|
| 208 |
headerVendor.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
|
226 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
|
| 209 |
headerVendor.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
|
227 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
|
| 210 |
|
228 |
|
| 211 |
headerVendor.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
|
229 |
headerVendorPrices.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
|
| 212 |
|
230 |
|
| 213 |
Button addButton = new Button("Add");
|
231 |
Button addButton = new Button("Add");
|
| 214 |
headerVendor.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
|
232 |
headerVendorPrices.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
|
| 215 |
addButton.addClickHandler(new ClickHandler() {
|
233 |
addButton.addClickHandler(new ClickHandler() {
|
| 216 |
@Override
|
234 |
@Override
|
| 217 |
public void onClick(ClickEvent event) {
|
235 |
public void onClick(ClickEvent event) {
|
| 218 |
VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
|
236 |
VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
|
| 219 |
vendorPricesDialog.updateButton.setText("Add");
|
237 |
vendorPricesDialog.updateButton.setText("Add");
|
| Line 225... |
Line 243... |
| 225 |
return false;
|
243 |
return false;
|
| 226 |
}
|
244 |
}
|
| 227 |
/*if(!validateVendorPrices(mop, dp, tp)) {
|
245 |
/*if(!validateVendorPrices(mop, dp, tp)) {
|
| 228 |
return false;
|
246 |
return false;
|
| 229 |
}*/
|
247 |
}*/
|
| 230 |
int row = vendorTable.getRowCount();
|
248 |
int row = tableVendorPrices.getRowCount();
|
| 231 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
249 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
| 232 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
250 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
| 233 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
251 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
| 234 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
252 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
| 235 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
253 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
| 236 |
|
254 |
|
| 237 |
vendorTable.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
|
255 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
|
| 238 |
vendorTable.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
256 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
| 239 |
vendorTable.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
257 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
| 240 |
vendorTable.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
258 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
| 241 |
vendorTable.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
259 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
| 242 |
|
260 |
|
| 243 |
vendorTable.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
|
261 |
tableVendorPrices.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
|
| 244 |
return true;
|
262 |
return true;
|
| 245 |
}
|
263 |
}
|
| 246 |
});
|
264 |
});
|
| 247 |
vendorPricesDialog.show();
|
265 |
vendorPricesDialog.show();
|
| 248 |
}
|
266 |
}
|
| 249 |
});
|
267 |
});
|
| 250 |
}
|
268 |
}
|
| 251 |
|
269 |
|
| - |
|
270 |
/**
|
| - |
|
271 |
* Clear and populate item availability table.
|
| - |
|
272 |
* @param availabilityMap
|
| - |
|
273 |
*/
|
| 252 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
274 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
| 253 |
availabilityTable.removeAllRows();
|
275 |
availabilityTable.removeAllRows();
|
| 254 |
if(availabilityMap == null) {
|
276 |
if(availabilityMap == null) {
|
| 255 |
return;
|
277 |
return;
|
| 256 |
}
|
278 |
}
|
| Line 265... |
Line 287... |
| 265 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
287 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
| 266 |
i++;
|
288 |
i++;
|
| 267 |
}
|
289 |
}
|
| 268 |
}
|
290 |
}
|
| 269 |
|
291 |
|
| - |
|
292 |
/**
|
| - |
|
293 |
* Clear and populate vendor item key table with keys in the passed argument.
|
| - |
|
294 |
* With each row in the table, an edit button is created and click event listener
|
| - |
|
295 |
* is added to it to edit that vendor item key row.
|
| - |
|
296 |
* @param vendorKeysMap
|
| - |
|
297 |
*/
|
| 270 |
private void updateMappingTable(Map<String, VendorItemMapping> vendorMappingsMap){
|
298 |
private void updateVendorKeysTable(Map<String, VendorItemMapping> vendorKeysMap){
|
| 271 |
vendorTableM.removeAllRows();
|
299 |
tableVendorItemKey.removeAllRows();
|
| 272 |
|
300 |
|
| 273 |
if(vendorMappingsMap == null || vendorMappingsMap.isEmpty()) {
|
301 |
if(vendorKeysMap == null || vendorKeysMap.isEmpty()) {
|
| 274 |
return;
|
302 |
return;
|
| 275 |
}
|
303 |
}
|
| 276 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
304 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
| 277 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
305 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
| 278 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
306 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
| 279 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
307 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
| 280 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
308 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
| 281 |
|
309 |
|
| 282 |
int i=0;
|
310 |
int i=0;
|
| 283 |
for(Entry<String, VendorItemMapping> e : vendorMappingsMap.entrySet()){
|
311 |
for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()){
|
| 284 |
VendorItemMapping vendorMapping = e.getValue();
|
312 |
VendorItemMapping vendorMapping = e.getValue();
|
| 285 |
vendorTableM.setText(i, TABLE_INDEX_MAPPING_VENDORID, vendorMapping.getVendorId() + "");
|
313 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDORID, vendorMapping.getVendorId() + "");
|
| 286 |
vendorTableM.setText(i, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
|
314 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
|
| 287 |
vendorTableM.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY, vendorMapping.getItemKey());
|
315 |
tableVendorItemKey.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));
|
316 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1));
|
| 289 |
Button editButton = new Button("Edit");
|
317 |
Button editButton = new Button("Edit");
|
| 290 |
vendorTableM.setWidget(i, TABLE_INDEX_MAPPING_BUTTON, editButton);
|
318 |
tableVendorItemKey.setWidget(i, TABLE_INDEX_MAPPING_BUTTON, editButton);
|
| 291 |
editButton.addClickHandler(new ClickHandler() {
|
319 |
editButton.addClickHandler(new ClickHandler() {
|
| 292 |
@Override
|
320 |
@Override
|
| 293 |
public void onClick(ClickEvent event) {
|
321 |
public void onClick(ClickEvent event) {
|
| 294 |
Cell cell = vendorTableM.getCellForEvent(event);
|
322 |
Cell cell = tableVendorItemKey.getCellForEvent(event);
|
| 295 |
int row = cell.getRowIndex();
|
323 |
int row = cell.getRowIndex();
|
| 296 |
long vendorId = Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
324 |
long vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
| 297 |
updateVendorMapping(vendorId, row);
|
325 |
editVendorKey(vendorId, row);
|
| 298 |
}
|
326 |
}
|
| 299 |
});
|
327 |
});
|
| 300 |
vendorTableM.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_VENDORID, false);
|
328 |
tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_VENDORID, false);
|
| 301 |
vendorTableM.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
329 |
tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 302 |
i++;
|
330 |
i++;
|
| 303 |
}
|
331 |
}
|
| 304 |
}
|
332 |
}
|
| 305 |
|
333 |
|
| - |
|
334 |
/**
|
| - |
|
335 |
* Clear and populate vendor prices table with prices in the passed argument.
|
| - |
|
336 |
* With each row in the table, an edit button is created and click event listener
|
| - |
|
337 |
* is added to it to edit that vendor prices row.
|
| - |
|
338 |
* @param vendorPricingMap
|
| - |
|
339 |
*/
|
| 306 |
private void updatePricingTable(Map<Long, VendorPricings> vendorPricingMap){
|
340 |
private void updateVendorPricingTable(Map<Long, VendorPricings> vendorPricingMap){
|
| 307 |
vendorTable.removeAllRows();
|
341 |
tableVendorPrices.removeAllRows();
|
| 308 |
|
342 |
|
| 309 |
if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
|
343 |
if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
|
| 310 |
return;
|
344 |
return;
|
| 311 |
}
|
345 |
}
|
| 312 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
346 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
| 313 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
347 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
| 314 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
348 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
| 315 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
349 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
| 316 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
350 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
| 317 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
351 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
| 318 |
|
352 |
|
| 319 |
|
353 |
|
| 320 |
int i=0;
|
354 |
int i=0;
|
| 321 |
for(VendorPricings vendorDetail : vendorPricingMap.values()){
|
355 |
for(VendorPricings vendorDetail : vendorPricingMap.values()){
|
| 322 |
vendorTable.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
|
356 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
|
| 323 |
vendorTable.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
|
357 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
|
| 324 |
vendorTable.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
|
358 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
|
| 325 |
vendorTable.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
|
359 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
|
| 326 |
vendorTable.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
|
360 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
|
| 327 |
Button editButton = new Button("Edit");
|
361 |
Button editButton = new Button("Edit");
|
| 328 |
vendorTable.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
|
362 |
tableVendorPrices.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
|
| 329 |
editButton.addClickHandler(new ClickHandler() {
|
363 |
editButton.addClickHandler(new ClickHandler() {
|
| 330 |
@Override
|
364 |
@Override
|
| 331 |
public void onClick(ClickEvent event) {
|
365 |
public void onClick(ClickEvent event) {
|
| 332 |
Cell cell = vendorTable.getCellForEvent(event);
|
366 |
Cell cell = tableVendorPrices.getCellForEvent(event);
|
| 333 |
int row = cell.getRowIndex();
|
367 |
int row = cell.getRowIndex();
|
| 334 |
long vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
368 |
long vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
| 335 |
updateVendorPrices(vendorId, row);
|
369 |
editVendorPrices(vendorId, row);
|
| 336 |
}
|
370 |
}
|
| 337 |
});
|
371 |
});
|
| 338 |
vendorTable.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
|
372 |
tableVendorPrices.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
|
| 339 |
i++;
|
373 |
i++;
|
| 340 |
}
|
374 |
}
|
| 341 |
}
|
375 |
}
|
| 342 |
|
376 |
|
| - |
|
377 |
/**
|
| - |
|
378 |
* called on the click event of update item button in ItemActions
|
| 343 |
|
379 |
*/
|
| 344 |
void updateItem() {
|
380 |
void updateItem() {
|
| 345 |
if(item == null) {
|
381 |
if(item == null) {
|
| 346 |
Window.alert("Please select an item to update.");
|
382 |
Window.alert("Please select an item to update.");
|
| 347 |
return;
|
383 |
return;
|
| 348 |
}
|
384 |
}
|
| Line 367... |
Line 403... |
| 367 |
}
|
403 |
}
|
| 368 |
|
404 |
|
| 369 |
/*if(!validatePrices()) {
|
405 |
/*if(!validatePrices()) {
|
| 370 |
return;
|
406 |
return;
|
| 371 |
}*/
|
407 |
}*/
|
| 372 |
//updateItem(); -- Calling this method above. A new item is created with updated data.
|
- |
|
| 373 |
catalogService.updateItem(newItem, new AsyncCallback<Boolean>() {
|
408 |
catalogService.updateItem(newItem, new AsyncCallback<Boolean>() {
|
| 374 |
@Override
|
409 |
@Override
|
| 375 |
public void onSuccess(Boolean result) {
|
410 |
public void onSuccess(Boolean result) {
|
| 376 |
if(result) {
|
411 |
if(result) {
|
| 377 |
item = newItem;
|
412 |
item = newItem;
|
| Line 389... |
Line 424... |
| 389 |
Window.alert("Error while updating item");
|
424 |
Window.alert("Error while updating item");
|
| 390 |
}
|
425 |
}
|
| 391 |
});
|
426 |
});
|
| 392 |
}
|
427 |
}
|
| 393 |
|
428 |
|
| - |
|
429 |
/**
|
| - |
|
430 |
* This method is called while updating item.<br> It will create a new Item object and set
|
| - |
|
431 |
* its editable attributes with UI fields values and non-editable attributes with old Item
|
| - |
|
432 |
* object attributes. This new Item object is then passed to the service to update item in the database.
|
| - |
|
433 |
* <br>If update is successful, the old Item object is replaced with the new Item object.
|
| - |
|
434 |
* @return true if new Item object is created successfully
|
| - |
|
435 |
* <br>false if some error occurs due to NumberFormatException
|
| - |
|
436 |
*/
|
| 394 |
private boolean createNewItem() {
|
437 |
private boolean createNewItem() {
|
| 395 |
newItem = new Item();
|
438 |
newItem = new Item();
|
| 396 |
newItem.setId(Long.parseLong(itemId.getText()));
|
439 |
newItem.setId(Long.parseLong(itemId.getText()));
|
| 397 |
newItem.setProductGroup(productGroup.getText().trim());
|
440 |
newItem.setProductGroup(productGroup.getText().trim());
|
| 398 |
newItem.setBrand(brand.getText().trim());
|
441 |
newItem.setBrand(brand.getText().trim());
|
| Line 488... |
Line 531... |
| 488 |
|
531 |
|
| 489 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
532 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
| 490 |
Add the instance to map and set the map to the item instance created above.*/
|
533 |
Add the instance to map and set the map to the item instance created above.*/
|
| 491 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
534 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
| 492 |
VendorPricings v;
|
535 |
VendorPricings v;
|
| 493 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
536 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
| 494 |
v = new VendorPricings();
|
537 |
v = new VendorPricings();
|
| 495 |
v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_MOP)));
|
538 |
v.setMop(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP)));
|
| 496 |
v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_DP)));
|
539 |
v.setDealerPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP)));
|
| 497 |
v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_TP)));
|
540 |
v.setTransferPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP)));
|
| 498 |
v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_PRICING_VENDORID)));
|
541 |
v.setVendorId(Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID)));
|
| 499 |
vendorPrices.put(v.getVendorId(), v);
|
542 |
vendorPrices.put(v.getVendorId(), v);
|
| 500 |
newItem.setMop(v.getMop());
|
543 |
newItem.setMop(v.getMop());
|
| 501 |
newItem.setDealerPrice(v.getDealerPrice());
|
544 |
newItem.setDealerPrice(v.getDealerPrice());
|
| 502 |
newItem.setTransferPrice(v.getTransferPrice());
|
545 |
newItem.setTransferPrice(v.getTransferPrice());
|
| 503 |
}
|
546 |
}
|
| 504 |
newItem.setVendorPricesMap(vendorPrices);
|
547 |
newItem.setVendorPricesMap(vendorPrices);
|
| 505 |
newItem.setItemStatusDesc(statusDesc.getText().trim());
|
548 |
newItem.setItemStatusDesc(statusDesc.getText().trim());
|
| - |
|
549 |
|
| 506 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
550 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
| 507 |
Add the instance to map and set the map to the item instance created above.*/
|
551 |
Add the instance to map and set the map to the item instance created above.*/
|
| 508 |
Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
|
552 |
Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
|
| 509 |
VendorItemMapping vMapping;
|
553 |
VendorItemMapping vMapping;
|
| 510 |
for(int row = 0; row < vendorTableM.getRowCount(); row++) {
|
554 |
for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
|
| 511 |
vMapping = new VendorItemMapping();
|
555 |
vMapping = new VendorItemMapping();
|
| 512 |
vMapping.setItemKey(vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY));
|
556 |
vMapping.setItemKey(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY));
|
| 513 |
vMapping.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_MAPPING_VENDORID)));
|
557 |
vMapping.setVendorId(Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID)));
|
| 514 |
vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD), vMapping);
|
558 |
vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD), vMapping);
|
| 515 |
}
|
559 |
}
|
| 516 |
newItem.setVendorKeysMap(vendorMappings);
|
560 |
newItem.setVendorKeysMap(vendorMappings);
|
| 517 |
|
561 |
|
| 518 |
newItem.setContentCategoryId(item.getContentCategoryId());
|
562 |
newItem.setContentCategoryId(item.getContentCategoryId());
|
| 519 |
newItem.setFeatureId(item.getFeatureId());
|
563 |
newItem.setFeatureId(item.getFeatureId());
|
| Line 526... |
Line 570... |
| 526 |
newItem.setAvailability(item.getAvailability());
|
570 |
newItem.setAvailability(item.getAvailability());
|
| 527 |
|
571 |
|
| 528 |
return true;
|
572 |
return true;
|
| 529 |
}
|
573 |
}
|
| 530 |
|
574 |
|
| - |
|
575 |
/**
|
| - |
|
576 |
* This method is called when Edit button is clicked corresponding to a row in
|
| - |
|
577 |
* vendor prices table. It will pop up a form to edit the vendor prices.
|
| - |
|
578 |
* @param vendorId
|
| - |
|
579 |
* @param row
|
| - |
|
580 |
*/
|
| 531 |
private void updateVendorPrices(final long vendorId, final int row) {
|
581 |
private void editVendorPrices(final long vendorId, final int row) {
|
| 532 |
String mop = vendorTable.getText(row, TABLE_INDEX_PRICING_MOP);
|
582 |
String mop = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP);
|
| 533 |
String dp = vendorTable.getText(row, TABLE_INDEX_PRICING_DP);
|
583 |
String dp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP);
|
| 534 |
String tp = vendorTable.getText(row, TABLE_INDEX_PRICING_TP);
|
584 |
String tp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP);
|
| 535 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
585 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
| 536 |
pricesDialog.updateButton.setText("Update");
|
586 |
pricesDialog.updateButton.setText("Update");
|
| 537 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
587 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 538 |
@Override
|
588 |
@Override
|
| 539 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
589 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
| 540 |
if(!validateVendorPrices(mop, dp, tp)) {
|
590 |
if(!validateVendorPrices(mop, dp, tp)) {
|
| 541 |
return false;
|
591 |
return false;
|
| 542 |
}
|
592 |
}
|
| 543 |
vendorTable.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
593 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
| 544 |
vendorTable.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
594 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
| 545 |
vendorTable.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
595 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
| 546 |
return true;
|
596 |
return true;
|
| 547 |
}
|
597 |
}
|
| 548 |
});
|
598 |
});
|
| 549 |
pricesDialog.show();
|
599 |
pricesDialog.show();
|
| 550 |
}
|
600 |
}
|
| 551 |
|
601 |
|
| - |
|
602 |
/**
|
| - |
|
603 |
* This method is called when Edit button is clicked corresponding to a row in
|
| - |
|
604 |
* vendor item key table. It will pop up a form to edit the item key.
|
| - |
|
605 |
* @param vendorId
|
| - |
|
606 |
* @param row
|
| - |
|
607 |
*/
|
| 552 |
private void updateVendorMapping(final long vendorId, final int row) {
|
608 |
private void editVendorKey(final long vendorId, final int row) {
|
| 553 |
String key = vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
609 |
String key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
| 554 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
610 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
| 555 |
modelNumber.getText().trim(), color.getText().trim(), key);
|
611 |
modelNumber.getText().trim(), color.getText().trim(), key);
|
| 556 |
mappingDialog.updateButton.setText("Update");
|
612 |
mappingDialog.updateButton.setText("Update");
|
| 557 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
613 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
| 558 |
@Override
|
614 |
@Override
|
| 559 |
public boolean onUpdate(String itemKey, long vendorId) {
|
615 |
public boolean onUpdate(String itemKey, long vendorId) {
|
| 560 |
if(itemKey == null || itemKey.equals("")) {
|
616 |
if(itemKey == null || itemKey.equals("")) {
|
| 561 |
Window.alert("Item key cannot be empty.");
|
617 |
Window.alert("Item key cannot be empty.");
|
| 562 |
return false;
|
618 |
return false;
|
| 563 |
}
|
619 |
}
|
| 564 |
vendorTableM.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, itemKey);
|
620 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, itemKey);
|
| 565 |
return true;
|
621 |
return true;
|
| 566 |
}
|
622 |
}
|
| 567 |
});
|
623 |
});
|
| 568 |
mappingDialog.show();
|
624 |
mappingDialog.show();
|
| 569 |
}
|
625 |
}
|
| 570 |
|
626 |
|
| - |
|
627 |
/**
|
| - |
|
628 |
* This method compares all the editable UI fields values with attributes in the item object.
|
| - |
|
629 |
* If they differ, the attribute name is appended to a string.
|
| - |
|
630 |
* @return String showing attributes which are changed by the user for confirmation.
|
| - |
|
631 |
* <br>Empty string if nothing is changed.
|
| - |
|
632 |
*/
|
| 571 |
private String isItemChanged() {
|
633 |
private String isItemChanged() {
|
| 572 |
StringBuilder sb = new StringBuilder("");
|
634 |
StringBuilder sb = new StringBuilder("");
|
| 573 |
if(!checkStringsIfEqual(productGroup.getText().trim(), item.getProductGroup())) {
|
635 |
if(!checkStringsIfEqual(productGroup.getText().trim(), item.getProductGroup())) {
|
| 574 |
sb.append("\n-Product Group");
|
636 |
sb.append("\n-Product Group");
|
| 575 |
}
|
637 |
}
|
| Line 618... |
Line 680... |
| 618 |
if(newItem.getStartDate() != item.getStartDate()) {
|
680 |
if(newItem.getStartDate() != item.getStartDate()) {
|
| 619 |
sb.append("\n-Start Date");
|
681 |
sb.append("\n-Start Date");
|
| 620 |
}
|
682 |
}
|
| 621 |
VendorPricings vendorPricings;
|
683 |
VendorPricings vendorPricings;
|
| 622 |
long vendorId;
|
684 |
long vendorId;
|
| 623 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
685 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
| 624 |
vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
686 |
vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
| 625 |
vendorPricings = item.getVendorPricesMap().get(vendorId);
|
687 |
vendorPricings = item.getVendorPricesMap().get(vendorId);
|
| 626 |
if(vendorPricings == null) {
|
688 |
if(vendorPricings == null) {
|
| 627 |
sb.append("\n-Vendor Prices (Vendor:" + vendorId + ")");
|
689 |
sb.append("\n-Vendor Prices (Vendor:" + vendorId + ")");
|
| 628 |
continue;
|
690 |
continue;
|
| 629 |
}
|
691 |
}
|
| 630 |
if(vendorPricings.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_MOP))) {
|
692 |
if(vendorPricings.getMop() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP))) {
|
| 631 |
sb.append("\n-MOP (Vendor:" + vendorId + ")");
|
693 |
sb.append("\n-MOP (Vendor:" + vendorId + ")");
|
| 632 |
}
|
694 |
}
|
| 633 |
if(vendorPricings.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_DP))) {
|
695 |
if(vendorPricings.getDealerPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP))) {
|
| 634 |
sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
|
696 |
sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
|
| 635 |
}
|
697 |
}
|
| 636 |
if(vendorPricings.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_PRICING_TP))) {
|
698 |
if(vendorPricings.getTransferPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP))) {
|
| 637 |
sb.append("\n-Transfer Price (Vendor:" + vendorId + ")");
|
699 |
sb.append("\n-Transfer Price (Vendor:" + vendorId + ")");
|
| 638 |
}
|
700 |
}
|
| 639 |
}
|
701 |
}
|
| 640 |
|
702 |
|
| 641 |
VendorItemMapping mapping;
|
703 |
VendorItemMapping mapping;
|
| 642 |
String old_key, new_key;
|
704 |
String old_key, new_key;
|
| 643 |
for(int row = 0; row < vendorTableM.getRowCount(); row++) {
|
705 |
for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
|
| 644 |
vendorId = Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
706 |
vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
| 645 |
old_key = vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD);
|
707 |
old_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD);
|
| 646 |
new_key = vendorTableM.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
708 |
new_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
| 647 |
mapping = item.getVendorKeysMap().get(vendorId + Item.KEY_SEPARATOR + old_key);
|
709 |
mapping = item.getVendorKeysMap().get(vendorId + Item.KEY_SEPARATOR + old_key);
|
| 648 |
if(mapping == null || !old_key.equals(new_key)) {
|
710 |
if(mapping == null || !old_key.equals(new_key)) {
|
| 649 |
sb.append("\n-Vendor Key (Vendor:" + vendorId + ",Key: = " + old_key + ")");
|
711 |
sb.append("\n-Vendor Key (Vendor:" + vendorId + ",Key: = " + old_key + ")");
|
| 650 |
continue;
|
712 |
continue;
|
| 651 |
}
|
713 |
}
|
| Line 689... |
Line 751... |
| 689 |
|
751 |
|
| 690 |
public Item getItem() {
|
752 |
public Item getItem() {
|
| 691 |
return item;
|
753 |
return item;
|
| 692 |
}
|
754 |
}
|
| 693 |
|
755 |
|
| - |
|
756 |
/**
|
| - |
|
757 |
* This method is used while adding vendor prices to ensure that there is only one row in the table for a vendor.
|
| - |
|
758 |
* @param vendorId
|
| - |
|
759 |
* @return true if parameter vendor Id is already added to vendor prices table.
|
| - |
|
760 |
* <br>else false
|
| - |
|
761 |
*/
|
| 694 |
private boolean vendorExists(long vendorId) {
|
762 |
private boolean vendorExists(long vendorId) {
|
| 695 |
long id;
|
763 |
long id;
|
| 696 |
for(int i = 0; i < vendorTable.getRowCount(); i++) {
|
764 |
for(int i = 0; i < tableVendorPrices.getRowCount(); i++) {
|
| 697 |
id = Long.parseLong(vendorTable.getText(i, TABLE_INDEX_PRICING_VENDORID));
|
765 |
id = Long.parseLong(tableVendorPrices.getText(i, TABLE_INDEX_PRICING_VENDORID));
|
| 698 |
if(vendorId == id) {
|
766 |
if(vendorId == id) {
|
| 699 |
return false;
|
767 |
return false;
|
| 700 |
}
|
768 |
}
|
| 701 |
}
|
769 |
}
|
| 702 |
return true;
|
770 |
return true;
|
| 703 |
}
|
771 |
}
|
| 704 |
|
772 |
|
| - |
|
773 |
/**
|
| - |
|
774 |
* This method is used to check if any of the string item attributes is changed by the user.
|
| - |
|
775 |
* @param s1
|
| - |
|
776 |
* @param s2
|
| - |
|
777 |
* @return true if two strings are equal
|
| - |
|
778 |
* <br>true if one of them is null and another is empty.
|
| - |
|
779 |
* <br>false otherwise
|
| - |
|
780 |
*/
|
| 705 |
private boolean checkStringsIfEqual(String s1, String s2) {
|
781 |
private boolean checkStringsIfEqual(String s1, String s2) {
|
| 706 |
if(s1 == s2) {
|
782 |
if(s1 == s2) {
|
| 707 |
return true;
|
783 |
return true;
|
| 708 |
}
|
784 |
}
|
| 709 |
if(s1 != null && s2 != null && s1.equals(s2)) {
|
785 |
if(s1 != null && s2 != null && s1.equals(s2)) {
|