| 1992 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import com.google.gwt.core.client.GWT;
|
|
|
4 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
5 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
6 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
7 |
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
8 |
import com.google.gwt.user.client.Window;
|
|
|
9 |
import com.google.gwt.user.client.ui.Button;
|
|
|
10 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
11 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
12 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
public class VendorPricesDialog extends DialogBox {
|
|
|
16 |
|
|
|
17 |
interface Binder extends UiBinder<Widget, VendorPricesDialog> { }
|
|
|
18 |
private static final Binder binder = GWT.create(Binder.class);
|
|
|
19 |
|
|
|
20 |
public interface VendorPriceUpdateListener{
|
|
|
21 |
void onPriceUpdate(double mop, double dp, double tp);
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
private VendorPriceUpdateListener vendorPriceUpdateListener;
|
|
|
25 |
|
|
|
26 |
@UiField Button closeButton, updateButton;
|
|
|
27 |
@UiField TextBox mop, dealerPrice, transferPrice;
|
|
|
28 |
|
|
|
29 |
public VendorPricesDialog(String mop, String dp, String tp) {
|
|
|
30 |
setText("Vendor Prices");
|
|
|
31 |
setWidget(binder.createAndBindUi(this));
|
|
|
32 |
this.mop.setText(mop);
|
|
|
33 |
this.dealerPrice.setText(dp);
|
|
|
34 |
this.transferPrice.setText(tp);
|
|
|
35 |
setAnimationEnabled(true);
|
|
|
36 |
//setGlassEnabled(true);
|
|
|
37 |
center();
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/*@Override
|
|
|
41 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) {
|
|
|
42 |
super.onPreviewNativeEvent(preview);
|
|
|
43 |
|
|
|
44 |
NativeEvent evt = preview.getNativeEvent();
|
|
|
45 |
if (evt.getType().equals("keydown")) {
|
|
|
46 |
// Use the popup's key preview hooks to close the dialog when either
|
|
|
47 |
// enter or escape is pressed.
|
|
|
48 |
switch (evt.getKeyCode()) {
|
|
|
49 |
case KeyCodes.KEY_ENTER:
|
|
|
50 |
case KeyCodes.KEY_ESCAPE:
|
|
|
51 |
hide();
|
|
|
52 |
break;
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
}*/
|
|
|
56 |
|
|
|
57 |
public void setVendorPriceUpdateListener(VendorPriceUpdateListener vPriceUpdateListener) {
|
|
|
58 |
this.vendorPriceUpdateListener = vPriceUpdateListener;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
@UiHandler("closeButton")
|
|
|
62 |
void onCloseClicked(ClickEvent event) {
|
|
|
63 |
hide();
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
@UiHandler("updateButton")
|
|
|
67 |
void onEditClicked(ClickEvent event) {
|
|
|
68 |
double mop;
|
|
|
69 |
double dp;
|
|
|
70 |
double tp;
|
|
|
71 |
try {
|
|
|
72 |
mop = Double.parseDouble(this.mop.getText());
|
|
|
73 |
dp = Double.parseDouble(this.dealerPrice.getText());
|
|
|
74 |
tp = Double.parseDouble(this.transferPrice.getText());
|
|
|
75 |
} catch(NumberFormatException ex) {
|
|
|
76 |
Window.alert("Price format is not valid.");
|
|
|
77 |
return;
|
|
|
78 |
}
|
|
|
79 |
vendorPriceUpdateListener.onPriceUpdate(mop, dp, tp);
|
|
|
80 |
hide();
|
|
|
81 |
}
|
|
|
82 |
}
|