| 2105 |
ankur.sing |
1 |
|
| 1992 |
ankur.sing |
2 |
package in.shop2020.catalog.dashboard.client;
|
|
|
3 |
|
| 2105 |
ankur.sing |
4 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
|
|
5 |
|
|
|
6 |
import java.util.Map.Entry;
|
|
|
7 |
|
| 1992 |
ankur.sing |
8 |
import com.google.gwt.core.client.GWT;
|
|
|
9 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
10 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
11 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
12 |
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
13 |
import com.google.gwt.user.client.Window;
|
|
|
14 |
import com.google.gwt.user.client.ui.Button;
|
|
|
15 |
import com.google.gwt.user.client.ui.DialogBox;
|
| 2105 |
ankur.sing |
16 |
import com.google.gwt.user.client.ui.ListBox;
|
| 1992 |
ankur.sing |
17 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
18 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
19 |
|
| 2427 |
ankur.sing |
20 |
/**
|
|
|
21 |
* This dialog is used to add/edit item related prices (DealerPrice, MOP, TransferPrice) for a vendor.
|
|
|
22 |
*
|
|
|
23 |
*/
|
| 1992 |
ankur.sing |
24 |
public class VendorPricesDialog extends DialogBox {
|
|
|
25 |
|
| 2427 |
ankur.sing |
26 |
interface Binder extends UiBinder<Widget, VendorPricesDialog> { }
|
|
|
27 |
private static final Binder binder = GWT.create(Binder.class);
|
| 1992 |
ankur.sing |
28 |
|
| 2427 |
ankur.sing |
29 |
/**
|
|
|
30 |
* Listener for update button click.
|
|
|
31 |
*/
|
|
|
32 |
public interface VendorPriceUpdateListener{
|
| 6759 |
amar.kumar |
33 |
boolean onUpdate(double mop, double dp, double tp, double nlc, long vendorId);
|
| 2427 |
ankur.sing |
34 |
}
|
| 1992 |
ankur.sing |
35 |
|
| 2427 |
ankur.sing |
36 |
private VendorPriceUpdateListener vendorPriceUpdateListener;
|
| 1992 |
ankur.sing |
37 |
|
| 2427 |
ankur.sing |
38 |
@UiField Button closeButton, updateButton;
|
| 6759 |
amar.kumar |
39 |
@UiField TextBox mop, dealerPrice, transferPrice, nlc;
|
| 2427 |
ankur.sing |
40 |
@UiField ListBox vendor;
|
|
|
41 |
|
|
|
42 |
public VendorPricesDialog() {
|
|
|
43 |
setText("Vendor Prices");
|
|
|
44 |
setWidget(binder.createAndBindUi(this));
|
|
|
45 |
setAnimationEnabled(true);
|
|
|
46 |
center();
|
|
|
47 |
for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
|
|
|
48 |
vendor.addItem(e.getValue());
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
|
| 6759 |
amar.kumar |
52 |
public VendorPricesDialog(String mop, String dp, String tp, String nlc) {
|
| 2427 |
ankur.sing |
53 |
this();
|
| 6759 |
amar.kumar |
54 |
setPrices(mop, dp, tp, nlc);
|
| 2427 |
ankur.sing |
55 |
}
|
|
|
56 |
|
| 6759 |
amar.kumar |
57 |
public void setPrices(String mop, String dp, String tp, String nlc) {
|
| 2427 |
ankur.sing |
58 |
this.mop.setText(mop);
|
|
|
59 |
this.dealerPrice.setText(dp);
|
|
|
60 |
this.transferPrice.setText(tp);
|
| 6759 |
amar.kumar |
61 |
this.nlc.setText(nlc);
|
| 2427 |
ankur.sing |
62 |
this.vendor.setEnabled(false);
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
/**
|
|
|
66 |
* listener for click on update button is set in ItemDetails and ItemForm
|
|
|
67 |
* @param vPriceUpdateListener
|
|
|
68 |
*/
|
|
|
69 |
public void setVendorPriceUpdateListener(VendorPriceUpdateListener vPriceUpdateListener) {
|
|
|
70 |
this.vendorPriceUpdateListener = vPriceUpdateListener;
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
@UiHandler("closeButton")
|
|
|
74 |
void onCloseClicked(ClickEvent event) {
|
|
|
75 |
hide();
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
@UiHandler("updateButton")
|
|
|
79 |
void onEditClicked(ClickEvent event) {
|
| 6759 |
amar.kumar |
80 |
double mop, dp, tp, nlc;
|
| 2427 |
ankur.sing |
81 |
try {
|
|
|
82 |
mop = Double.parseDouble(this.mop.getText());
|
|
|
83 |
dp = Double.parseDouble(this.dealerPrice.getText());
|
|
|
84 |
tp = Double.parseDouble(this.transferPrice.getText());
|
| 6759 |
amar.kumar |
85 |
nlc = Double.parseDouble(this.nlc.getText());
|
| 2427 |
ankur.sing |
86 |
} catch(NumberFormatException ex) {
|
|
|
87 |
Window.alert("Price format is not valid.");
|
|
|
88 |
return;
|
|
|
89 |
}
|
|
|
90 |
long vendorId = Utils.getVendorId(this.vendor.getItemText(this.vendor.getSelectedIndex()));
|
| 6759 |
amar.kumar |
91 |
if(vendorPriceUpdateListener.onUpdate(mop, dp, tp, nlc, vendorId)) {
|
| 2427 |
ankur.sing |
92 |
hide();
|
|
|
93 |
}
|
|
|
94 |
}
|
| 1992 |
ankur.sing |
95 |
}
|