Subversion Repositories SmartDukaan

Rev

Rev 2359 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2359 Rev 2427
Line 16... Line 16...
16
import com.google.gwt.user.client.ui.DialogBox;
16
import com.google.gwt.user.client.ui.DialogBox;
17
import com.google.gwt.user.client.ui.ListBox;
17
import com.google.gwt.user.client.ui.ListBox;
18
import com.google.gwt.user.client.ui.TextBox;
18
import com.google.gwt.user.client.ui.TextBox;
19
import com.google.gwt.user.client.ui.Widget;
19
import com.google.gwt.user.client.ui.Widget;
20
 
20
 
-
 
21
/**
-
 
22
 * This dialog is used to add/edit vendor item key.
21
 
23
 *
-
 
24
 */
22
public class VendorMappingDialog extends DialogBox {
25
public class VendorMappingDialog extends DialogBox {
23
 
26
 
24
    interface Binder extends UiBinder<Widget, VendorMappingDialog> { }
27
    interface Binder extends UiBinder<Widget, VendorMappingDialog> { }
25
    private static final Binder binder = GWT.create(Binder.class);
28
    private static final Binder binder = GWT.create(Binder.class);
26
 
29
 
Line 41... Line 44...
41
    
44
    
42
    public VendorMappingDialog(String ourProductGroup, String ourBrand, String ourModelNum, String ourColor) {
45
    public VendorMappingDialog(String ourProductGroup, String ourBrand, String ourModelNum, String ourColor) {
43
        setText("Vendor Item Mapping");
46
        setText("Vendor Item Mapping");
44
        setWidget(binder.createAndBindUi(this));
47
        setWidget(binder.createAndBindUi(this));
45
        setAnimationEnabled(true);
48
        setAnimationEnabled(true);
46
        //setGlassEnabled(true);
-
 
47
        center();
49
        center();
48
        for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
50
        for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
49
            vendor.addItem(e.getValue());
51
            vendor.addItem(e.getValue());
50
        }
52
        }
51
        this.ourProductGroup = ourProductGroup;
53
        this.ourProductGroup = ourProductGroup;
Line 62... Line 64...
62
    private void setKey(String itemKey) {
64
    private void setKey(String itemKey) {
63
        this.itemKey.setText(itemKey);
65
        this.itemKey.setText(itemKey);
64
        this.vendor.setEnabled(false);
66
        this.vendor.setEnabled(false);
65
    }
67
    }
66
 
68
 
-
 
69
    /**
-
 
70
     * listener for click on update button is set in ItemDetails and ItemForm
-
 
71
     * @param vMappingUpdateListener
-
 
72
     */
67
    public void setVendorMappingUpdateListener(VendorMappingUpdateListener vMappingUpdateListener) {
73
    public void setVendorMappingUpdateListener(VendorMappingUpdateListener vMappingUpdateListener) {
68
        this.vendorMappingUpdateListener = vMappingUpdateListener;
74
        this.vendorMappingUpdateListener = vMappingUpdateListener;
69
    }
75
    }
70
 
76
 
71
    @UiHandler("closeButton")
77
    @UiHandler("closeButton")
Line 73... Line 79...
73
        hide();
79
        hide();
74
    }
80
    }
75
 
81
 
76
    @UiHandler("updateButton")
82
    @UiHandler("updateButton")
77
    void onEditClicked(ClickEvent event) {
83
    void onEditClicked(ClickEvent event) {
78
        long vendorId;
-
 
79
        String key;
-
 
80
        vendorId = Utils.getVendorId(this.vendor.getItemText(this.vendor.getSelectedIndex()));
-
 
81
        key = itemKey.getText().trim();
84
        String key = itemKey.getText().trim();
82
        if(key.isEmpty()) {
85
        if(key.isEmpty()) {
83
            Window.alert("Item key cannot be empty");
86
            Window.alert("Item key cannot be empty");
84
            return;
87
            return;
85
        }
88
        }
-
 
89
        long vendorId = Utils.getVendorId(this.vendor.getItemText(this.vendor.getSelectedIndex()));
86
        if(vendorMappingUpdateListener.onUpdate(key, vendorId)) {
90
        if(vendorMappingUpdateListener.onUpdate(key, vendorId)) {
87
            hide();
91
            hide();
88
        }
92
        }
89
    }
93
    }
90
    
94
    
Line 102... Line 106...
102
        itemKey.setText(key);
106
        itemKey.setText(key);
103
     }
107
     }
104
    
108
    
105
    @UiHandler("sameAsOurs")
109
    @UiHandler("sameAsOurs")
106
    void setDefaultKeyParams(ClickEvent event) {
110
    void setDefaultKeyParams(ClickEvent event) {
107
        if(sameAsOurs.getValue()) {
111
        boolean bool = sameAsOurs.getValue();
108
            productGroup.setText(ourProductGroup);
112
        productGroup.setText(bool ? ourProductGroup : "");
109
            brand.setText(ourBrand);
113
        brand.setText(bool ? ourBrand : "");
110
            modelNumber.setText(ourModelNum);
114
        modelNumber.setText(bool ? ourModelNum : "");
111
            color.setText(ourColor);
115
        color.setText(bool ? ourColor : "");
112
        } else {
-
 
113
            productGroup.setText("");
-
 
114
            brand.setText("");
-
 
115
            modelNumber.setText("");
-
 
116
            color.setText("");
-
 
117
        }
-
 
118
    }
116
    }
119
}
117
}