Subversion Repositories SmartDukaan

Rev

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

Rev 2066 Rev 2105
Line 26... Line 26...
26
    
26
    
27
    private static final CatalogBinder binder = GWT.create(CatalogBinder.class);
27
    private static final CatalogBinder binder = GWT.create(CatalogBinder.class);
28
    private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
28
    private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
29
    private final LoginServiceAsync loginService = GWT.create(LoginService.class);
29
    private final LoginServiceAsync loginService = GWT.create(LoginService.class);
30
    
30
    
31
    @UiField
-
 
32
    TopPanel topPanel;
31
    @UiField TopPanel topPanel;
33
    @UiField
-
 
34
    Shortcuts shortcuts;
32
    @UiField Shortcuts shortcuts;
35
    /*@UiField
-
 
36
    Filters filters;*/
33
    //@UiField Filters filters;
37
    @UiField
-
 
38
    ItemList itemList;
34
    @UiField ItemList itemList;
39
    @UiField
-
 
40
    ItemDetails itemDetails;
35
    @UiField ItemDetails itemDetails;
41
    //@UiField Button addItem;
36
    @UiField ItemActions itemActions;
42
 
-
 
43
    
-
 
44
 
37
 
45
    RootLayoutPanel root;
38
    RootLayoutPanel root;
46
    LoginScreen login;
39
    LoginScreen login;
47
 
40
 
48
    public void onModuleLoad() {
41
    public void onModuleLoad() {
49
        root = RootLayoutPanel.get();
42
        root = RootLayoutPanel.get();
50
        root.getElement().setScrollLeft(10);
43
        root.getElement().setScrollLeft(10);
51
        login = new LoginScreen();
44
        login = new LoginScreen();
52
        //initMainDB("Testing");
45
        initMainDB("Testing");
53
        root.add(login);
46
        /*root.add(login);
54
        login.setLoginListener(new LoginScreen.LoginListener() {
47
        login.setLoginListener(new LoginScreen.LoginListener() {
55
            @Override
48
            @Override
56
            public void onLoginPressed(String username, String password) {
49
            public void onLoginPressed(String username, String password) {
57
                authenticateUser(username, password);
50
                authenticateUser(username, password);
58
            }
51
            }
59
        });
52
        });*/
60
    }
53
    }
61
 
54
 
62
    private void authenticateUser(String username, String password) {
55
    private void authenticateUser(String username, String password) {
63
        final String uname = username;
56
        final String uname = username;
64
        loginService.authenticateUser(username, password, new AsyncCallback<String>() {
57
        loginService.authenticateUser(username, password, new AsyncCallback<String>() {
Line 139... Line 132...
139
                } else if(itemsType == CatalogTree.BEST_SELLERS) {
132
                } else if(itemsType == CatalogTree.BEST_SELLERS) {
140
                    itemList.loadBestSellers();
133
                    itemList.loadBestSellers();
141
                } else if(itemsType == CatalogTree.LATEST_ARRIVALS) {
134
                } else if(itemsType == CatalogTree.LATEST_ARRIVALS) {
142
                    itemList.loadLatestArrivals();
135
                    itemList.loadLatestArrivals();
143
                }
136
                }
144
//                itemDetails = new ItemDetails();
137
                //itemDetails = new ItemDetails();
145
                //showDefaultCursor();
138
                //showDefaultCursor();
146
            }
139
            }
147
        });
140
        });
-
 
141
        
-
 
142
        itemActions.setAddItemListener(new ItemActions.AddItemListener() {
-
 
143
            @Override
-
 
144
            public void onAddItemPressed() {
-
 
145
                ItemForm itemForm = new ItemForm();
-
 
146
                itemForm.center();
-
 
147
                itemForm.show();
-
 
148
            }
-
 
149
        });
-
 
150
        
-
 
151
        itemActions.setPhaseoutItemListener(new ItemActions.PhaseoutItemListener() {
-
 
152
            @Override
-
 
153
            public void onPhaseoutItemPressed() {
-
 
154
                final long itemId = itemDetails.getItemId();
-
 
155
                if(itemId == 0) {
-
 
156
                    Window.alert("Please select an item to mark PHASED OUT");
-
 
157
                    return;
-
 
158
                }
-
 
159
                catalogService.phaseoutItem(itemId, new AsyncCallback<Void>() {
-
 
160
                    @Override
-
 
161
                    public void onSuccess(Void result) {
-
 
162
                        Window.alert("Item marked as PHASED OUT");
-
 
163
                    }
-
 
164
                    @Override
-
 
165
                    public void onFailure(Throwable caught) {
-
 
166
                        Window.alert("Error while marking item " + itemId + " PHASED OUT");
-
 
167
                    }
-
 
168
                });
-
 
169
            }
-
 
170
        });
-
 
171
        itemActions.setActivateItemListener(new ItemActions.ActivateItemListener() {
-
 
172
            @Override
-
 
173
            public void onActivatePressed() {
-
 
174
                final long itemId = itemDetails.getItemId();
-
 
175
                if(itemId == 0) {
-
 
176
                    Window.alert("Please select an item to mark ACTIVE");
-
 
177
                    return;
-
 
178
                }
-
 
179
                catalogService.activateItem(itemId, new AsyncCallback<Void>() {
-
 
180
                    @Override
-
 
181
                    public void onSuccess(Void result) {
-
 
182
                        Window.alert("Item marked as ACTIVE");
-
 
183
                    }
-
 
184
                    @Override
-
 
185
                    public void onFailure(Throwable caught) {
-
 
186
                        Window.alert("Error while marking item " + itemId + " ACTIVE");
-
 
187
                    }
-
 
188
                });
-
 
189
            }
-
 
190
        });
148
    }
191
    }
149
    
192
    
150
    /*public static void showWaitCursor() {
193
    /*public static void showWaitCursor() {
151
        DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait");
194
        DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait");
152
    }
195
    }