Subversion Repositories SmartDukaan

Rev

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

Rev 3463 Rev 3473
Line 1... Line 1...
1
package in.shop2020.hotspot.dashbaord.client.inbox;
1
package in.shop2020.hotspot.dashbaord.client.inbox;
2
 
2
 
3
import in.shop2020.hotspot.dashbaord.client.event.AddWeightEvent;
3
import in.shop2020.hotspot.dashbaord.client.event.AddWeightEvent;
4
import in.shop2020.hotspot.dashbaord.client.event.RejectOrderEvent;
-
 
5
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
4
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
6
 
5
 
7
import org.enunes.gwt.mvp.client.EventBus;
6
import org.enunes.gwt.mvp.client.EventBus;
8
 
7
 
9
import com.google.gwt.event.dom.client.ClickEvent;
8
import com.google.gwt.event.dom.client.ClickEvent;
Line 14... Line 13...
14
import com.google.gwt.user.client.ui.Label;
13
import com.google.gwt.user.client.ui.Label;
15
import com.google.gwt.user.client.ui.TextBox;
14
import com.google.gwt.user.client.ui.TextBox;
16
import com.google.gwt.user.client.ui.VerticalPanel;
15
import com.google.gwt.user.client.ui.VerticalPanel;
17
 
16
 
18
public class AddWeightBox extends DialogBox {
17
public class AddWeightBox extends DialogBox {
-
 
18
    private Label errorLabel = new Label("");
-
 
19
    
19
    private Label weightLabel = new Label("Weight");
20
    private Label weightLabel = new Label("Weight");
20
    
21
    
21
    private TextBox weightBox = new TextBox();
22
    private TextBox weightBox = new TextBox();
22
    
23
    
23
    private Button submitbutton = new Button("Submit");
24
    private Button submitbutton = new Button("Submit");
Line 26... Line 27...
26
    
27
    
27
    private VerticalPanel vpanel = new VerticalPanel();
28
    private VerticalPanel vpanel = new VerticalPanel();
28
    
29
    
29
    
30
    
30
    public AddWeightBox(final EventBus eventBus, final Order order){
31
    public AddWeightBox(final EventBus eventBus, final Order order){
-
 
32
        vpanel.add(errorLabel);
-
 
33
        
31
        hpanel = new HorizontalPanel();
34
        hpanel = new HorizontalPanel();
32
        hpanel.setSpacing(5);
35
        hpanel.setSpacing(5);
33
        hpanel.add(weightLabel);
36
        hpanel.add(weightLabel);
34
        hpanel.add(weightBox);
37
        hpanel.add(weightBox);
35
        hpanel.setCellWidth(weightLabel, "50px");
38
        hpanel.setCellWidth(weightLabel, "50px");
Line 45... Line 48...
45
        
48
        
46
        submitbutton.addClickHandler(new ClickHandler() {
49
        submitbutton.addClickHandler(new ClickHandler() {
47
            
50
            
48
            @Override
51
            @Override
49
            public void onClick(ClickEvent event) {
52
            public void onClick(ClickEvent event) {
50
                hide();
-
 
51
                String weightStr = weightBox.getText();
53
                String weightStr = weightBox.getText();
-
 
54
                try{
52
                double weight = Double.parseDouble(weightStr);
55
                    double weight = Double.parseDouble(weightStr);
53
                eventBus.fireEvent(new AddWeightEvent(order, weight));
56
                    eventBus.fireEvent(new AddWeightEvent(order, weight));
-
 
57
                }catch(NumberFormatException nfe){
-
 
58
                    errorLabel.setText("Invalid Weight.");
-
 
59
                    return;
-
 
60
                }
54
                clear();
61
                clear();
-
 
62
                hide();
55
            }
63
            }
56
        });
64
        });
57
    }
65
    }
58
    
66
    
59
    public void clear(){
67
    public void clear(){