Subversion Repositories SmartDukaan

Rev

Rev 1962 | Rev 2027 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1962 Rev 1992
Line 25... Line 25...
25
    private final LoginServiceAsync loginService = GWT.create(LoginService.class);
25
    private final LoginServiceAsync loginService = GWT.create(LoginService.class);
26
 
26
 
27
    @UiField
27
    @UiField
28
    TopPanel topPanel;
28
    TopPanel topPanel;
29
    @UiField
29
    @UiField
-
 
30
    Shortcuts shortcuts;
-
 
31
    /*@UiField
-
 
32
    Filters filters;*/
-
 
33
    @UiField
30
    ItemList itemList;
34
    ItemList itemList;
31
    @UiField
35
    @UiField
32
    ItemDetails itemDetails;
36
    ItemDetails itemDetails;
-
 
37
 
33
    @UiField
38
    
34
    Shortcuts shortcuts;
-
 
35
 
39
 
36
    RootLayoutPanel root;
40
    RootLayoutPanel root;
37
    LoginScreen login;
41
    LoginScreen login;
38
 
42
 
39
    public void onModuleLoad() {
43
    public void onModuleLoad() {
40
 
44
 
41
        root = RootLayoutPanel.get();
45
        root = RootLayoutPanel.get();
42
        login = new LoginScreen();
46
        login = new LoginScreen();
-
 
47
        //initMainDB("Testing");
43
        root.add(login);
48
        root.add(login);
44
        login.setLoginListener(new LoginScreen.LoginListener() {
49
        login.setLoginListener(new LoginScreen.LoginListener() {
45
            @Override
50
            @Override
46
            public void onLoginPressed(String username, String password) {
51
            public void onLoginPressed(String username, String password) {
47
                authenticateUser(username, password);
52
                authenticateUser(username, password);
48
                /*
-
 
49
                 * if (username.equals("ankur") && password.equals("ankur")) {
-
 
50
                 * root.clear(); initMainDB(username); }
-
 
51
                 */
-
 
52
            }
53
            }
53
        });
54
        });
54
    }
55
    }
55
 
56
 
56
    private void authenticateUser(String username, String password) {
57
    private void authenticateUser(String username, String password) {
Line 78... Line 79...
78
            public void onItemSelected(Item item) {
79
            public void onItemSelected(Item item) {
79
                itemDetails.setItemDetails(item);
80
                itemDetails.setItemDetails(item);
80
            }
81
            }
81
        });
82
        });
82
 
83
 
83
        itemDetails.setPriceUpdateListener(new ItemDetails.PriceUpdateListener() {
84
        itemDetails.setItemUpdateListener(new ItemDetails.ItemUpdateListener() {
84
            @Override
85
            @Override
85
            public void onPriceUpdate(long itemId, double sellingPrice) {
86
            public void onItemUpdate(Item item) {
86
                catalogService.updatePrice(itemId, sellingPrice, new AsyncCallback<Void>() {
87
                catalogService.updateItem(item, new AsyncCallback<Boolean>() {
87
                    @Override
88
                    @Override
88
                    public void onSuccess(Void result) {
89
                    public void onSuccess(Boolean result) {
-
 
90
                        if(result)
89
                        // TODO: refresh item list and disable submit button
91
                            Window.alert("Item updated successfully.");
-
 
92
                        else
90
                        Window.alert("Price updated successfully...Hurray !!!");
93
                            Window.alert("Error updating item :(");
91
                    }
94
                    }
92
 
95
 
93
                    @Override
96
                    @Override
94
                    public void onFailure(Throwable caught) {
97
                    public void onFailure(Throwable caught) {
95
                        Window.alert("Error while updating price");
98
                        Window.alert("Error while updating item");
96
                    }
99
                    }
97
                });
100
                });
98
            }
101
            }
99
        });
102
        });
100
        topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
103
        topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
Line 104... Line 107...
104
                root.add(login);
107
                root.add(login);
105
            }
108
            }
106
        });
109
        });
107
        root.clear();
110
        root.clear();
108
        root.add(dashboard);
111
        root.add(dashboard);
-
 
112
        
-
 
113
        shortcuts.getCatalogTree().setTreeListener(new CatalogTree.TreeListener() {
-
 
114
            @Override
-
 
115
            public void onTreeItemClicked() {
-
 
116
                // TODO Auto-generated method stub
-
 
117
                
-
 
118
            }
-
 
119
        });
109
    }
120
    }
110
}
121
}