| Line 1... |
Line 1... |
| 1 |
package in.shop2020.catalog.dashboard.client;
|
1 |
package in.shop2020.catalog.dashboard.client;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| - |
|
4 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
| 4 |
|
5 |
|
| 5 |
import java.util.Date;
|
6 |
import java.util.Date;
|
| - |
|
7 |
import java.util.HashMap;
|
| 6 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| 7 |
import java.util.Map.Entry;
|
9 |
import java.util.Map.Entry;
|
| 8 |
|
10 |
|
| 9 |
import com.google.gwt.core.client.GWT;
|
11 |
import com.google.gwt.core.client.GWT;
|
| 10 |
import com.google.gwt.event.dom.client.ClickEvent;
|
12 |
import com.google.gwt.event.dom.client.ClickEvent;
|
| Line 13... |
Line 15... |
| 13 |
import com.google.gwt.uibinder.client.UiBinder;
|
15 |
import com.google.gwt.uibinder.client.UiBinder;
|
| 14 |
import com.google.gwt.uibinder.client.UiField;
|
16 |
import com.google.gwt.uibinder.client.UiField;
|
| 15 |
import com.google.gwt.uibinder.client.UiHandler;
|
17 |
import com.google.gwt.uibinder.client.UiHandler;
|
| 16 |
import com.google.gwt.user.client.Window;
|
18 |
import com.google.gwt.user.client.Window;
|
| 17 |
import com.google.gwt.user.client.ui.Button;
|
19 |
import com.google.gwt.user.client.ui.Button;
|
| - |
|
20 |
import com.google.gwt.user.client.ui.CheckBox;
|
| 18 |
import com.google.gwt.user.client.ui.FlexTable;
|
21 |
import com.google.gwt.user.client.ui.FlexTable;
|
| 19 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
22 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
| 20 |
import com.google.gwt.user.client.ui.Label;
|
23 |
import com.google.gwt.user.client.ui.Label;
|
| - |
|
24 |
import com.google.gwt.user.client.ui.ListBox;
|
| 21 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
25 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
| 22 |
import com.google.gwt.user.client.ui.TextBox;
|
26 |
import com.google.gwt.user.client.ui.TextBox;
|
| 23 |
import com.google.gwt.user.client.ui.Widget;
|
27 |
import com.google.gwt.user.client.ui.Widget;
|
| 24 |
|
28 |
|
| 25 |
public class ItemDetails extends ResizeComposite {
|
29 |
public class ItemDetails extends ResizeComposite {
|
| 26 |
|
- |
|
| 27 |
|
30 |
|
| - |
|
31 |
private final int TABLE_INDEX_VENDORID = 0, TABLE_INDEX_VENDOR_DESC = 1, TABLE_INDEX_MOP = 2, TABLE_INDEX_DP = 3, TABLE_INDEX_TP = 4;
|
| - |
|
32 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0, TABLE_INDEX_WAREHOUSE_DESC = 1, TABLE_INDEX_WAREHOUSE_INV = 2;
|
| - |
|
33 |
private Item newItem;
|
| - |
|
34 |
|
| 28 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
35 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
| 29 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
36 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
| 30 |
|
37 |
|
| 31 |
public interface ItemUpdateListener {
|
38 |
public interface ItemUpdateListener {
|
| 32 |
void onItemUpdate(Item item);
|
39 |
void onItemUpdate(Item item);
|
| 33 |
}
|
40 |
}
|
| 34 |
|
41 |
|
| 35 |
interface ItemDetailStyle extends CssResource{
|
42 |
interface ItemDetailStyle extends CssResource{
|
| 36 |
String greenLabel();
|
43 |
String greenLabel();
|
| 37 |
String fieldChanged();
|
44 |
String fieldChanged();
|
| 38 |
}
|
45 |
}
|
| 39 |
|
46 |
|
| 40 |
private ItemUpdateListener itemUpdateListener;
|
47 |
private ItemUpdateListener itemUpdateListener;
|
| 41 |
|
48 |
|
| 42 |
private Item item;
|
49 |
private Item item;
|
| 43 |
|
50 |
|
| 44 |
@UiField ItemDetailStyle style;
|
51 |
@UiField ItemDetailStyle style;
|
| 45 |
@UiField Label itemId;
|
52 |
@UiField Label itemId;
|
| 46 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
53 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
| 47 |
@UiField Label category, catalogItemId;
|
54 |
@UiField Label category, catalogItemId;
|
| 48 |
@UiField TextBox comments;
|
55 |
@UiField TextBox comments;
|
| 49 |
@UiField TextBox sellingPrice, mrp, /*mop, dealerPrice, transferPrice,*/ weight;
|
56 |
@UiField TextBox sellingPrice, mrp, /*mop, dealerPrice, transferPrice,*/ weight;
|
| 50 |
@UiField Label addedOn, startDate, retireDate, updatedOn;
|
57 |
@UiField Label addedOn, startDate, retireDate, updatedOn;
|
| 51 |
@UiField Label itemStatus;
|
58 |
@UiField Label itemStatus;
|
| 52 |
@UiField TextBox bestDealsText, bestDealsValue;
|
59 |
@UiField TextBox bestDealsText, bestDealsValue;
|
| 53 |
@UiField FlexTable headerAvailability, availabilityTable;
|
60 |
@UiField FlexTable headerAvailability, availabilityTable;
|
| 54 |
@UiField FlexTable headerPricing, pricingTable;
|
61 |
@UiField FlexTable headerPricing, pricingTable;
|
| - |
|
62 |
@UiField TextBox bestSellingRank;
|
| - |
|
63 |
@UiField CheckBox defaultForEntity;
|
| 55 |
@UiField Button submit;
|
64 |
@UiField Button submit;
|
| 56 |
|
65 |
|
| 57 |
public ItemDetails(Item item){
|
66 |
public ItemDetails(Item item){
|
| 58 |
initWidget(uiBinder.createAndBindUi(this));
|
67 |
initWidget(uiBinder.createAndBindUi(this));
|
| 59 |
adjustUIFields();
|
- |
|
| 60 |
initAvailabilityHeader();
|
68 |
initAvailabilityHeader();
|
| 61 |
initPricingHeader();
|
69 |
initPricingHeader();
|
| 62 |
setItemDetails(item);
|
70 |
setItemDetails(item);
|
| 63 |
}
|
71 |
}
|
| 64 |
|
72 |
|
| 65 |
public ItemDetails() {
|
73 |
public ItemDetails() {
|
| 66 |
this.item = null;
|
74 |
this.item = null;
|
| 67 |
initWidget(uiBinder.createAndBindUi(this));
|
75 |
initWidget(uiBinder.createAndBindUi(this));
|
| 68 |
adjustUIFields();
|
- |
|
| 69 |
initAvailabilityHeader();
|
76 |
initAvailabilityHeader();
|
| 70 |
initPricingHeader();
|
77 |
initPricingHeader();
|
| 71 |
}
|
- |
|
| 72 |
|
- |
|
| 73 |
private void adjustUIFields() {
|
- |
|
| 74 |
sellingPrice.setSize("8", "4");
|
- |
|
| 75 |
}
|
78 |
}
|
| 76 |
|
79 |
|
| 77 |
public void setItemDetails(Item item){
|
80 |
public void setItemDetails(Item item){
|
| 78 |
this.item = item;
|
81 |
this.item = item;
|
| 79 |
itemId.setText(item.getId()+"");
|
82 |
itemId.setText(item.getId()+"");
|
| 80 |
productGroup.setText(item.getProductGroup());
|
83 |
productGroup.setText(item.getProductGroup());
|
| 81 |
brand.setText(item.getBrand());
|
84 |
brand.setText(item.getBrand());
|
| 82 |
modelNumber.setText(item.getModelNumber());
|
85 |
modelNumber.setText(item.getModelNumber());
|
| 83 |
modelName.setText(item.getModelName());
|
86 |
modelName.setText(item.getModelName());
|
| 84 |
color.setText(item.getColor());
|
87 |
color.setText(item.getColor());
|
| 85 |
|
88 |
|
| 86 |
category.setText(item.getCategory()+"");
|
89 |
category.setText(item.getCategory()+"");
|
| 87 |
comments.setText(item.getComments());
|
90 |
comments.setText(item.getComments());
|
| 88 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
91 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
| 89 |
|
92 |
|
| 90 |
mrp.setText(item.getMrp()+"");
|
93 |
mrp.setText(item.getMrp()+"");
|
| 91 |
sellingPrice.setText(item.getSellingPrice()+"");
|
94 |
sellingPrice.setText(item.getSellingPrice()+"");
|
| 92 |
/*mop.setText(item.getMop()+"");
|
95 |
/*mop.setText(item.getMop()+"");
|
| 93 |
dealerPrice.setText(item.getDealerPrice()+"");
|
96 |
dealerPrice.setText(item.getDealerPrice()+"");
|
| 94 |
transferPrice.setText(item.getTransferPrice()+"");*/
|
97 |
transferPrice.setText(item.getTransferPrice()+"");*/
|
| 95 |
weight.setText(item.getWeight()+"");
|
98 |
weight.setText(item.getWeight()+"");
|
| 96 |
|
99 |
|
| 97 |
addedOn.setText(getDisplayableDate(item.getAddedOn()));
|
100 |
addedOn.setText(getDisplayableDate(item.getAddedOn()));
|
| 98 |
startDate.setText(getDisplayableDate(item.getStartDate()));
|
101 |
startDate.setText(getDisplayableDate(item.getStartDate()));
|
| 99 |
retireDate.setText(getDisplayableDate(item.getRetireDate()));
|
102 |
retireDate.setText(getDisplayableDate(item.getRetireDate()));
|
| 100 |
updatedOn.setText(getDisplayableDate(item.getUpdatedOn()));
|
103 |
updatedOn.setText(getDisplayableDate(item.getUpdatedOn()));
|
| 101 |
|
- |
|
| 102 |
bestDealsText.setText(item.getBestDealsText());
|
- |
|
| 103 |
bestDealsValue.setText(item.getBestDealsValue()+"");
|
- |
|
| 104 |
|
- |
|
| 105 |
itemStatus.setText(item.getItemStatus());
|
- |
|
| 106 |
|
- |
|
| 107 |
updateAvailabilityTable(item.getAvailability());
|
- |
|
| 108 |
|
- |
|
| 109 |
updatePricingTable(item.getVendorPricings());
|
- |
|
| 110 |
}
|
- |
|
| 111 |
|
- |
|
| 112 |
private void initAvailabilityHeader(){
|
- |
|
| 113 |
// Initialize the header.
|
- |
|
| 114 |
headerAvailability.getColumnFormatter().setWidth(0, "128px");
|
- |
|
| 115 |
headerAvailability.getColumnFormatter().setWidth(1, "128px");
|
- |
|
| 116 |
|
104 |
|
| 117 |
headerAvailability.setText(0, 0, "Warehouse Id");
|
105 |
bestDealsText.setText(item.getBestDealsText());
|
| 118 |
headerAvailability.setText(0, 1, "Availability");
|
106 |
bestDealsValue.setText(item.getBestDealsValue()+"");
|
| - |
|
107 |
|
| - |
|
108 |
bestSellingRank.setText(item.getBestSellingRank()+"");
|
| - |
|
109 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 119 |
|
110 |
|
| - |
|
111 |
itemStatus.setText(item.getItemStatus());
|
| - |
|
112 |
|
| - |
|
113 |
updateAvailabilityTable(item.getAvailability());
|
| - |
|
114 |
|
| - |
|
115 |
updatePricingTable(item.getVendorPricings());
|
| 120 |
}
|
116 |
}
|
| 121 |
|
117 |
|
| 122 |
private void initPricingHeader(){
|
118 |
private void initAvailabilityHeader(){
|
| 123 |
// Initialize the header.
|
119 |
// Initialize the header.
|
| 124 |
headerPricing.getColumnFormatter().setWidth(0, "128px");
|
- |
|
| 125 |
headerPricing.getColumnFormatter().setWidth(1, "128px");
|
120 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
| 126 |
headerPricing.getColumnFormatter().setWidth(2, "128px");
|
121 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "128px");
|
| 127 |
headerPricing.getColumnFormatter().setWidth(3, "128px");
|
122 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
| 128 |
|
123 |
|
| 129 |
headerPricing.setText(0, 0, "Vendor Id");
|
124 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
|
| 130 |
headerPricing.setText(0, 1, "MOP");
|
- |
|
| 131 |
headerPricing.setText(0, 2, "Dealer Price");
|
125 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
| 132 |
headerPricing.setText(0, 3, "Transfer Price");
|
126 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
| - |
|
127 |
|
| 133 |
}
|
128 |
}
|
| - |
|
129 |
|
| - |
|
130 |
private void initPricingHeader(){
|
| - |
|
131 |
// Initialize the header.
|
| - |
|
132 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| - |
|
133 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| - |
|
134 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
| - |
|
135 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
| - |
|
136 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
| - |
|
137 |
|
| - |
|
138 |
headerPricing.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
| - |
|
139 |
headerPricing.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
|
| - |
|
140 |
headerPricing.setText(0, TABLE_INDEX_MOP, "MOP");
|
| - |
|
141 |
headerPricing.setText(0, TABLE_INDEX_DP, "Dealer Price");
|
| - |
|
142 |
headerPricing.setText(0, TABLE_INDEX_TP, "Transfer Price");
|
| 134 |
|
143 |
}
|
| - |
|
144 |
|
| 135 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
145 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
| 136 |
availabilityTable.removeAllRows();
|
146 |
availabilityTable.removeAllRows();
|
| 137 |
if(availabilityMap == null) {
|
147 |
if(availabilityMap == null) {
|
| 138 |
return;
|
148 |
return;
|
| 139 |
}
|
149 |
}
|
| 140 |
availabilityTable.getColumnFormatter().setWidth(0, "128px");
|
150 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
| - |
|
151 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "128px");
|
| 141 |
availabilityTable.getColumnFormatter().setWidth(1, "128px");
|
152 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
| 142 |
|
153 |
|
| 143 |
|
154 |
|
| 144 |
int i=0;
|
155 |
int i=0;
|
| 145 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()){
|
156 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()){
|
| 146 |
int col = 0;
|
157 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, availability.getKey() + "");
|
| 147 |
availabilityTable.setText(i, col++, availability.getKey() + "");
|
158 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
| 148 |
availabilityTable.setText(i, col++, availability.getValue() + "");
|
159 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
| 149 |
i++;
|
160 |
i++;
|
| 150 |
}
|
161 |
}
|
| 151 |
}
|
162 |
}
|
| 152 |
|
163 |
|
| 153 |
private void updatePricingTable(Map<Long, double[]> pricings){
|
164 |
private void updatePricingTable(Map<Long, double[]> pricings){
|
| 154 |
pricingTable.removeAllRows();
|
165 |
pricingTable.removeAllRows();
|
| 155 |
if(pricings == null || pricings.isEmpty()) {
|
166 |
if(pricings == null || pricings.isEmpty()) {
|
| 156 |
return;
|
167 |
return;
|
| 157 |
}
|
168 |
}
|
| 158 |
pricingTable.getColumnFormatter().setWidth(0, "128px");
|
169 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| - |
|
170 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| 159 |
pricingTable.getColumnFormatter().setWidth(1, "128px");
|
171 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
| 160 |
pricingTable.getColumnFormatter().setWidth(2, "128px");
|
172 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
| 161 |
pricingTable.getColumnFormatter().setWidth(3, "128px");
|
173 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
| 162 |
|
174 |
|
| 163 |
|
175 |
|
| 164 |
int i=0;
|
176 |
int i=0;
|
| 165 |
for(Entry<Long, double[]> pricing : pricings.entrySet()){
|
177 |
for(Entry<Long, double[]> pricing : pricings.entrySet()){
|
| 166 |
int col = 0;
|
178 |
pricingTable.setText(i, TABLE_INDEX_VENDORID, pricing.getKey() + "");
|
| 167 |
pricingTable.setText(i, col++, pricing.getKey() + "");
|
179 |
pricingTable.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(pricing.getKey()));
|
| 168 |
pricingTable.setText(i, col++, pricing.getValue()[Item.INDEX_MOP] + "");
|
180 |
pricingTable.setText(i, TABLE_INDEX_MOP, pricing.getValue()[Item.INDEX_MOP] + "");
|
| 169 |
pricingTable.setText(i, col++, pricing.getValue()[Item.INDEX_DP] + "");
|
181 |
pricingTable.setText(i, TABLE_INDEX_DP, pricing.getValue()[Item.INDEX_DP] + "");
|
| 170 |
pricingTable.setText(i, col++, pricing.getValue()[Item.INDEX_TP] + "");
|
182 |
pricingTable.setText(i, TABLE_INDEX_TP, pricing.getValue()[Item.INDEX_TP] + "");
|
| 171 |
Button editButton = new Button("Edit");
|
183 |
Button editButton = new Button("Edit");
|
| 172 |
pricingTable.setWidget(i, col++, editButton);
|
184 |
pricingTable.setWidget(i, TABLE_INDEX_TP + 1, editButton);
|
| 173 |
i++;
|
185 |
i++;
|
| 174 |
editButton.addClickHandler(new ClickHandler() {
|
186 |
editButton.addClickHandler(new ClickHandler() {
|
| 175 |
@Override
|
187 |
@Override
|
| 176 |
public void onClick(ClickEvent event) {
|
188 |
public void onClick(ClickEvent event) {
|
| 177 |
Cell cell = pricingTable.getCellForEvent(event);
|
189 |
Cell cell = pricingTable.getCellForEvent(event);
|
| 178 |
int row = cell.getRowIndex();
|
190 |
int row = cell.getRowIndex();
|
| 179 |
long vendorId = Long.parseLong(pricingTable.getText(row, 0));
|
191 |
long vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
| 180 |
updateVendorPrices(vendorId, row);
|
192 |
updateVendorPrices(vendorId, row);
|
| 181 |
}
|
193 |
}
|
| 182 |
});
|
194 |
});
|
| 183 |
}
|
195 |
}
|
| 184 |
}
|
196 |
}
|
| 185 |
|
197 |
|
| 186 |
|
198 |
|
| 187 |
//TODO: This code is duplicated between here and OrderList. Move it to a Utility class.
|
199 |
//TODO: This code is duplicated between here and OrderList. Move it to a Utility class.
|
| 188 |
private String getDisplayableDate(Long millis){
|
200 |
private String getDisplayableDate(Long millis){
|
| 189 |
Date date = new Date();
|
201 |
Date date = new Date();
|
| 190 |
date.setTime(millis);
|
202 |
date.setTime(millis);
|
| 191 |
String dateString = date.toString();
|
203 |
String dateString = date.toString();
|
| 192 |
dateString = dateString.substring(0, dateString.lastIndexOf(" "));
|
204 |
dateString = dateString.substring(0, dateString.lastIndexOf(" "));
|
| 193 |
dateString = dateString.substring(0, dateString.lastIndexOf(" "));
|
205 |
dateString = dateString.substring(0, dateString.lastIndexOf(" "));
|
| 194 |
return dateString;
|
206 |
return dateString;
|
| 195 |
}
|
207 |
}
|
| 196 |
|
208 |
|
| 197 |
public void setItemUpdateListener(ItemUpdateListener itemUpdatelistener) {
|
209 |
public void setItemUpdateListener(ItemUpdateListener itemUpdatelistener) {
|
| 198 |
this.itemUpdateListener = itemUpdatelistener;
|
210 |
this.itemUpdateListener = itemUpdatelistener;
|
| 199 |
}
|
211 |
}
|
| 200 |
|
212 |
|
| 201 |
@UiHandler("submit")
|
213 |
@UiHandler("submit")
|
| 202 |
void onSubmitPressed(ClickEvent clickEvent) {
|
214 |
void onSubmitPressed(ClickEvent clickEvent) {
|
| 203 |
//long id = Long.parseLong(this.itemId.getText());
|
215 |
//long id = Long.parseLong(this.itemId.getText());
|
| 204 |
try {
|
216 |
try {
|
| - |
|
217 |
if(!isItemChanged()) {
|
| - |
|
218 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
| - |
|
219 |
return;
|
| - |
|
220 |
}
|
| 205 |
updateItem();
|
221 |
updateItem();
|
| - |
|
222 |
if(!validatePrices()) {
|
| - |
|
223 |
return;
|
| - |
|
224 |
}
|
| - |
|
225 |
//updateItem();
|
| 206 |
} catch(NumberFormatException ex) {
|
226 |
} catch(NumberFormatException ex) {
|
| 207 |
return;
|
227 |
return;
|
| 208 |
}
|
228 |
}
|
| 209 |
itemUpdateListener.onItemUpdate(item);
|
229 |
itemUpdateListener.onItemUpdate(newItem);
|
| 210 |
GWT.log("Item updated. Id = " + item.getId());
|
230 |
GWT.log("Item updated. Id = " + item.getId());
|
| - |
|
231 |
item = newItem;
|
| 211 |
}
|
232 |
}
|
| 212 |
|
233 |
|
| 213 |
void updateItem() throws NumberFormatException {
|
234 |
private void updateItem() throws NumberFormatException {
|
| - |
|
235 |
newItem = new Item();
|
| - |
|
236 |
newItem.setId(Long.parseLong(itemId.getText()));
|
| 214 |
item.setProductGroup(productGroup.getText().trim());
|
237 |
newItem.setProductGroup(productGroup.getText().trim());
|
| 215 |
item.setBrand(brand.getText().trim());
|
238 |
newItem.setBrand(brand.getText().trim());
|
| 216 |
item.setModelName(modelName.getText().trim());
|
239 |
newItem.setModelNumber(modelNumber.getText().trim());
|
| 217 |
item.setModelNumber(modelNumber.getText().trim());
|
240 |
newItem.setModelName(modelName.getText().trim());
|
| 218 |
item.setColor(color.getText().trim());
|
241 |
newItem.setColor(color.getText().trim());
|
| - |
|
242 |
newItem.setCategory(Long.parseLong(category.getText()));
|
| - |
|
243 |
newItem.setComments(comments.getText().trim());
|
| - |
|
244 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
| - |
|
245 |
newItem.setFeatureId(item.getFeatureId());
|
| - |
|
246 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
| - |
|
247 |
newItem.setMrp(Double.parseDouble(mrp.getText().trim()));
|
| - |
|
248 |
newItem.setSellingPrice(Double.parseDouble(sellingPrice.getText().trim()));
|
| - |
|
249 |
newItem.setWeight(Double.parseDouble(weight.getText().trim()));
|
| - |
|
250 |
newItem.setAddedOn(item.getAddedOn());
|
| - |
|
251 |
newItem.setStartDate(item.getStartDate());
|
| - |
|
252 |
newItem.setRetireDate(item.getRetireDate());
|
| - |
|
253 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
| - |
|
254 |
newItem.setItemStatus(item.getItemStatus());
|
| - |
|
255 |
newItem.setOtherInfo(item.getOtherInfo());
|
| - |
|
256 |
newItem.setBestDealsText(bestDealsText.getText().trim());
|
| - |
|
257 |
newItem.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
| - |
|
258 |
newItem.setBestSellingRank(Long.parseLong(bestSellingRank.getText().trim()));
|
| - |
|
259 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
| - |
|
260 |
newItem.setAvailability(item.getAvailability());
|
| - |
|
261 |
Map<Long, double[]> vendorPrices = new HashMap<Long, double[]>();
|
| - |
|
262 |
double[] arr;
|
| - |
|
263 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
| - |
|
264 |
arr = new double[3];
|
| - |
|
265 |
arr[Item.INDEX_MOP] = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP));
|
| - |
|
266 |
arr[Item.INDEX_DP] = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP));
|
| - |
|
267 |
arr[Item.INDEX_TP] = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP));
|
| - |
|
268 |
vendorPrices.put(Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID)), arr);
|
| - |
|
269 |
newItem.setMop(arr[Item.INDEX_MOP]);
|
| - |
|
270 |
newItem.setDealerPrice(arr[Item.INDEX_DP]);
|
| - |
|
271 |
newItem.setTransferPrice(arr[Item.INDEX_TP]);
|
| 219 |
|
272 |
}
|
| 220 |
item.setComments(comments.getText().trim());
|
273 |
newItem.setVendorPricings(vendorPrices);
|
| 221 |
|
274 |
|
| - |
|
275 |
/*item.setProductGroup(productGroup.getText().trim());
|
| - |
|
276 |
item.setBrand(brand.getText().trim());
|
| - |
|
277 |
item.setModelName(modelName.getText().trim());
|
| - |
|
278 |
item.setModelNumber(modelNumber.getText().trim());
|
| - |
|
279 |
item.setColor(color.getText().trim());
|
| - |
|
280 |
item.setComments(comments.getText().trim());
|
| - |
|
281 |
item.setMrp(Double.parseDouble(this.mrp.getText()));
|
| - |
|
282 |
item.setSellingPrice(Double.parseDouble(this.sellingPrice.getText()));
|
| - |
|
283 |
item.setWeight(Double.parseDouble(this.weight.getText()));
|
| - |
|
284 |
item.setBestDealsText(bestDealsText.getText().trim());
|
| - |
|
285 |
item.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
| - |
|
286 |
item.setBestSellingRank(Long.parseLong(bestSellingRank.getText().trim()));
|
| - |
|
287 |
item.setDefaultForEntity(defaultForEntity.getValue());
|
| - |
|
288 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
| - |
|
289 |
long vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
| - |
|
290 |
double mop = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP));
|
| - |
|
291 |
double dp = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP));
|
| - |
|
292 |
double tp = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP));
|
| - |
|
293 |
item.getVendorPricings().get(vendorId)[Item.INDEX_MOP] = mop;
|
| - |
|
294 |
item.getVendorPricings().get(vendorId)[Item.INDEX_DP] = dp;
|
| - |
|
295 |
item.getVendorPricings().get(vendorId)[Item.INDEX_TP] = tp;
|
| - |
|
296 |
item.setMop(mop);
|
| - |
|
297 |
item.setDealerPrice(dp);
|
| - |
|
298 |
item.setTransferPrice(tp);
|
| - |
|
299 |
}*/
|
| - |
|
300 |
}
|
| - |
|
301 |
|
| - |
|
302 |
private void updateVendorPrices(final long vendorId, final int row) {
|
| - |
|
303 |
String mop = pricingTable.getText(row, TABLE_INDEX_MOP);
|
| - |
|
304 |
String dp = pricingTable.getText(row, TABLE_INDEX_DP);
|
| - |
|
305 |
String tp = pricingTable.getText(row, TABLE_INDEX_TP);
|
| - |
|
306 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
| - |
|
307 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| - |
|
308 |
@Override
|
| - |
|
309 |
public void onPriceUpdate(double mop, double dp, double tp) {
|
| - |
|
310 |
pricingTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
| - |
|
311 |
pricingTable.setText(row, TABLE_INDEX_DP, dp + "");
|
| - |
|
312 |
pricingTable.setText(row, TABLE_INDEX_TP, tp + "");
|
| - |
|
313 |
/*item.getVendorPricings().get(vendorId)[Item.INDEX_MOP] = mop;
|
| - |
|
314 |
item.getVendorPricings().get(vendorId)[Item.INDEX_DP] = dp;
|
| - |
|
315 |
item.getVendorPricings().get(vendorId)[Item.INDEX_TP] = tp;
|
| - |
|
316 |
item.setMop(mop);
|
| - |
|
317 |
item.setDealerPrice(dp);
|
| - |
|
318 |
item.setTransferPrice(tp);*/
|
| - |
|
319 |
}
|
| - |
|
320 |
});
|
| - |
|
321 |
pricesDialog.show();
|
| - |
|
322 |
}
|
| - |
|
323 |
|
| - |
|
324 |
private boolean isItemChanged() {
|
| - |
|
325 |
if(!productGroup.getText().trim().equals(item.getProductGroup())) {
|
| - |
|
326 |
return true;
|
| - |
|
327 |
}
|
| - |
|
328 |
if(!brand.getText().trim().equals(item.getBrand())) {
|
| - |
|
329 |
return true;
|
| - |
|
330 |
}
|
| - |
|
331 |
if(!modelNumber.getText().trim().equals(item.getModelNumber())) {
|
| - |
|
332 |
return true;
|
| - |
|
333 |
}
|
| - |
|
334 |
if(!modelName.getText().trim().equals(item.getModelName())) {
|
| - |
|
335 |
return true;
|
| - |
|
336 |
}
|
| - |
|
337 |
if(!color.getText().trim().equals(item.getColor())) {
|
| - |
|
338 |
return true;
|
| - |
|
339 |
}
|
| - |
|
340 |
if(!comments.getText().trim().equals(item.getComments())) {
|
| - |
|
341 |
return true;
|
| - |
|
342 |
}
|
| 222 |
try {
|
343 |
try {
|
| 223 |
item.setMrp(Double.parseDouble(this.mrp.getText()));
|
344 |
if(item.getMrp() != Double.parseDouble(mrp.getText().trim())) {
|
| - |
|
345 |
return true;
|
| - |
|
346 |
}
|
| 224 |
} catch(NumberFormatException ex) {
|
347 |
} catch(NumberFormatException ex) {
|
| 225 |
Window.alert("Invalid MRP format");
|
348 |
Window.alert("Invalid MRP format");
|
| 226 |
throw new NumberFormatException();
|
349 |
throw new NumberFormatException();
|
| 227 |
}
|
350 |
}
|
| 228 |
try {
|
351 |
try {
|
| 229 |
item.setSellingPrice(Double.parseDouble(this.sellingPrice.getText()));
|
352 |
if(item.getSellingPrice() != Double.parseDouble(sellingPrice.getText().trim())) {
|
| - |
|
353 |
return true;
|
| - |
|
354 |
}
|
| 230 |
} catch(NumberFormatException ex) {
|
355 |
} catch(NumberFormatException ex) {
|
| 231 |
Window.alert("Invalid Selling Price format");
|
356 |
Window.alert("Invalid Selling Price format");
|
| 232 |
throw new NumberFormatException();
|
357 |
throw new NumberFormatException();
|
| 233 |
}
|
358 |
}
|
| 234 |
try {
|
359 |
try {
|
| 235 |
item.setWeight(Double.parseDouble(this.weight.getText()));
|
360 |
if(item.getWeight() != Double.parseDouble(weight.getText().trim())) {
|
| - |
|
361 |
return true;
|
| - |
|
362 |
}
|
| 236 |
} catch(NumberFormatException ex) {
|
363 |
} catch(NumberFormatException ex) {
|
| 237 |
Window.alert("Invalid Weight format");
|
364 |
Window.alert("Invalid Weight format");
|
| 238 |
throw new NumberFormatException();
|
365 |
throw new NumberFormatException();
|
| 239 |
}
|
366 |
}
|
| 240 |
|
- |
|
| 241 |
item.setBestDealsText(bestDealsText.getText().trim());
|
367 |
if(!bestDealsText.getText().trim().equals(item.getBestDealsText())) {
|
| - |
|
368 |
return true;
|
| - |
|
369 |
}
|
| 242 |
try {
|
370 |
try {
|
| 243 |
item.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
371 |
if(item.getBestDealsValue() != Double.parseDouble(bestDealsValue.getText().trim())) {
|
| - |
|
372 |
return true;
|
| - |
|
373 |
}
|
| 244 |
} catch(NumberFormatException ex) {
|
374 |
} catch(NumberFormatException ex) {
|
| 245 |
Window.alert("Invalid Best Deals Value format");
|
375 |
Window.alert("Invalid Best Deals Value format");
|
| 246 |
throw new NumberFormatException();
|
376 |
throw new NumberFormatException();
|
| 247 |
}
|
377 |
}
|
| 248 |
}
|
- |
|
| 249 |
|
- |
|
| 250 |
private void updateVendorPrices(final long vendorId, final int row) {
|
- |
|
| 251 |
String mop = pricingTable.getText(row, 1);
|
- |
|
| 252 |
String dp = pricingTable.getText(row, 2);
|
- |
|
| 253 |
String tp = pricingTable.getText(row, 3);
|
- |
|
| 254 |
VendorPricesDialog vpd = new VendorPricesDialog(mop, dp, tp);
|
- |
|
| 255 |
vpd.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
- |
|
| 256 |
@Override
|
378 |
try{
|
| 257 |
public void onPriceUpdate(double mop, double dp, double tp) {
|
- |
|
| 258 |
pricingTable.setText(row, 1, mop + "");
|
- |
|
| 259 |
pricingTable.setText(row, 2, dp + "");
|
- |
|
| 260 |
pricingTable.setText(row, 3, tp + "");
|
- |
|
| 261 |
item.getVendorPricings().get(vendorId)[Item.INDEX_MOP] = mop;
|
379 |
if(item.getBestSellingRank() != Long.parseLong(bestSellingRank.getText().trim())) {
|
| 262 |
item.getVendorPricings().get(vendorId)[Item.INDEX_DP] = dp;
|
- |
|
| 263 |
item.getVendorPricings().get(vendorId)[Item.INDEX_TP] = tp;
|
- |
|
| 264 |
item.setMop(mop);
|
380 |
return true;
|
| 265 |
item.setDealerPrice(dp);
|
- |
|
| 266 |
item.setTransferPrice(tp);
|
- |
|
| 267 |
}
|
381 |
}
|
| - |
|
382 |
} catch (NumberFormatException ex) {
|
| - |
|
383 |
Window.alert("Invalid Best Selling Rank format");
|
| - |
|
384 |
throw new NumberFormatException();
|
| 268 |
});
|
385 |
}
|
| - |
|
386 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
| - |
|
387 |
return true;
|
| - |
|
388 |
}
|
| 269 |
vpd.show();
|
389 |
|
| - |
|
390 |
double[] vendorPrices;
|
| - |
|
391 |
long vendorId;
|
| - |
|
392 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
| - |
|
393 |
vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
| - |
|
394 |
vendorPrices = item.getVendorPricings().get(vendorId);
|
| - |
|
395 |
if(vendorPrices[Item.INDEX_MOP] != Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP))) {
|
| - |
|
396 |
return true;
|
| - |
|
397 |
}
|
| - |
|
398 |
if(vendorPrices[Item.INDEX_DP] != Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP))) {
|
| - |
|
399 |
return true;
|
| - |
|
400 |
}
|
| - |
|
401 |
if(vendorPrices[Item.INDEX_TP] != Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP))) {
|
| - |
|
402 |
return true;
|
| - |
|
403 |
}
|
| - |
|
404 |
}
|
| - |
|
405 |
return false;
|
| - |
|
406 |
}
|
| - |
|
407 |
|
| - |
|
408 |
private boolean validatePrices() {
|
| - |
|
409 |
if(newItem.getSellingPrice() > newItem.getMrp()) {
|
| - |
|
410 |
Window.alert("Selling price cannot be more than MRP");
|
| - |
|
411 |
return false;
|
| - |
|
412 |
}
|
| - |
|
413 |
for(Entry<Long, double[]> v : newItem.getVendorPricings().entrySet()) {
|
| - |
|
414 |
if(newItem.getMrp() < v.getValue()[Item.INDEX_MOP]) {
|
| - |
|
415 |
Window.alert("MRP cannot be less than MOP. Vendor: " + v.getKey());
|
| - |
|
416 |
return false;
|
| - |
|
417 |
}
|
| - |
|
418 |
if(v.getValue()[Item.INDEX_TP] > v.getValue()[Item.INDEX_MOP]) {
|
| - |
|
419 |
Window.alert("Transfer Price cannot be more than MOP. Vendor: " + v.getKey());
|
| - |
|
420 |
return false;
|
| - |
|
421 |
}
|
| - |
|
422 |
}
|
| - |
|
423 |
return true;
|
| 270 |
}
|
424 |
}
|
| 271 |
|
425 |
|
| 272 |
/*
|
426 |
/*
|
| 273 |
@UiHandler("sellingPrice")
|
427 |
@UiHandler("sellingPrice")
|
| 274 |
void onSPUpdate(KeyPressEvent keyPressEvent) {
|
428 |
void onSPUpdate(KeyPressEvent keyPressEvent) {
|
| 275 |
if(Double.parseDouble(sellingPrice.getText()) != item.getSellingPrice()) {
|
429 |
if(Double.parseDouble(sellingPrice.getText()) != item.getSellingPrice()) {
|
| 276 |
sellingPrice.getElement().addClassName(style.fieldChanged());
|
430 |
sellingPrice.getElement().addClassName(style.fieldChanged());
|
| 277 |
} else {
|
431 |
} else {
|
| 278 |
sellingPrice.getElement().addClassName(style.greenLabel());
|
432 |
sellingPrice.getElement().addClassName(style.greenLabel());
|
| 279 |
}
|
433 |
}
|
| 280 |
}
|
434 |
}
|
| 281 |
|
435 |
|
| 282 |
@UiHandler("mop")
|
436 |
@UiHandler("mop")
|
| 283 |
void onMOPUpdate(KeyPressEvent keyPressEvent) {
|
437 |
void onMOPUpdate(KeyPressEvent keyPressEvent) {
|
| 284 |
if(Double.parseDouble(mop.getText()) != item.getMop()) {
|
438 |
if(Double.parseDouble(mop.getText()) != item.getMop()) {
|
| 285 |
mop.getElement().addClassName(style.fieldChanged());
|
439 |
mop.getElement().addClassName(style.fieldChanged());
|
| 286 |
} else {
|
440 |
} else {
|
| 287 |
mop.getElement().addClassName(style.greenLabel());
|
441 |
mop.getElement().addClassName(style.greenLabel());
|
| 288 |
}
|
442 |
}
|
| 289 |
}
|
443 |
}
|
| 290 |
|
444 |
|
| 291 |
@UiHandler("dealerPrice")
|
445 |
@UiHandler("dealerPrice")
|
| 292 |
void onDPUpdate(KeyPressEvent keyPressEvent) {
|
446 |
void onDPUpdate(KeyPressEvent keyPressEvent) {
|
| 293 |
if(Double.parseDouble(dealerPrice.getText()) != item.getDealerPrice()) {
|
447 |
if(Double.parseDouble(dealerPrice.getText()) != item.getDealerPrice()) {
|
| 294 |
dealerPrice.getElement().addClassName(style.fieldChanged());
|
448 |
dealerPrice.getElement().addClassName(style.fieldChanged());
|
| 295 |
} else {
|
449 |
} else {
|
| 296 |
dealerPrice.getElement().addClassName(style.greenLabel());
|
450 |
dealerPrice.getElement().addClassName(style.greenLabel());
|
| 297 |
}
|
451 |
}
|
| 298 |
}
|
452 |
}
|
| 299 |
|
453 |
|
| 300 |
@UiHandler("transferPrice")
|
454 |
@UiHandler("transferPrice")
|
| 301 |
void onTPUpdate(KeyPressEvent keyPressEvent) {
|
455 |
void onTPUpdate(KeyPressEvent keyPressEvent) {
|
| 302 |
if(Double.parseDouble(transferPrice.getText()) != item.getTransferPrice()) {
|
456 |
if(Double.parseDouble(transferPrice.getText()) != item.getTransferPrice()) {
|
| 303 |
transferPrice.getElement().addClassName(style.fieldChanged());
|
457 |
transferPrice.getElement().addClassName(style.fieldChanged());
|
| 304 |
} else {
|
458 |
} else {
|
| 305 |
transferPrice.getElement().addClassName(style.greenLabel());
|
459 |
transferPrice.getElement().addClassName(style.greenLabel());
|
| 306 |
}
|
460 |
}
|
| 307 |
}
|
461 |
}
|
| 308 |
|
462 |
|
| 309 |
@UiHandler("weight")
|
463 |
@UiHandler("weight")
|
| 310 |
void onWeightUpdate(KeyPressEvent keyPressEvent) {
|
464 |
void onWeightUpdate(KeyPressEvent keyPressEvent) {
|
| 311 |
if(Double.parseDouble(weight.getText()) != item.getWeight()) {
|
465 |
if(Double.parseDouble(weight.getText()) != item.getWeight()) {
|
| 312 |
weight.getElement().addClassName(style.fieldChanged());
|
466 |
weight.getElement().addClassName(style.fieldChanged());
|
| 313 |
} else {
|
467 |
} else {
|
| 314 |
weight.getElement().addClassName(style.greenLabel());
|
468 |
weight.getElement().addClassName(style.greenLabel());
|
| 315 |
}
|
469 |
}
|
| 316 |
}
|
470 |
}
|
| 317 |
|
471 |
|
| 318 |
void applyDefaultStyles() {
|
472 |
void applyDefaultStyles() {
|
| 319 |
sellingPrice.getElement().addClassName(style.greenLabel());
|
473 |
sellingPrice.getElement().addClassName(style.greenLabel());
|
| 320 |
mop.getElement().addClassName(style.greenLabel());
|
474 |
mop.getElement().addClassName(style.greenLabel());
|
| 321 |
dealerPrice.getElement().addClassName(style.greenLabel());
|
475 |
dealerPrice.getElement().addClassName(style.greenLabel());
|
| 322 |
transferPrice.getElement().addClassName(style.greenLabel());
|
476 |
transferPrice.getElement().addClassName(style.greenLabel());
|
| 323 |
weight.getElement().addClassName(style.greenLabel());
|
477 |
weight.getElement().addClassName(style.greenLabel());
|
| 324 |
}*/
|
478 |
}*/
|
| 325 |
|
479 |
|
| 326 |
}
|
480 |
}
|