Coverage Report - org.kuali.student.lum.common.client.lo.CategoryManagement
 
Classes in this File Line Coverage Branch Coverage Complexity
CategoryManagement
0%
0/107
0%
0/12
1.356
CategoryManagement$1
0%
0/6
N/A
1.356
CategoryManagement$10
0%
0/5
0%
0/2
1.356
CategoryManagement$10$1
0%
0/9
N/A
1.356
CategoryManagement$2
0%
0/7
N/A
1.356
CategoryManagement$3
0%
0/7
N/A
1.356
CategoryManagement$4
0%
0/3
N/A
1.356
CategoryManagement$5
0%
0/3
N/A
1.356
CategoryManagement$6
0%
0/3
N/A
1.356
CategoryManagement$7
0%
0/3
N/A
1.356
CategoryManagement$8
0%
0/5
N/A
1.356
CategoryManagement$9
0%
0/5
0%
0/2
1.356
CategoryManagement$9$1
0%
0/8
N/A
1.356
CategoryManagement$CreateCategoryDialog
0%
0/51
0%
0/2
1.356
CategoryManagement$CreateCategoryDialog$1
0%
0/5
N/A
1.356
CategoryManagement$CreateCategoryDialog$1$1
0%
0/9
0%
0/4
1.356
CategoryManagement$CreateCategoryDialog$2
0%
0/3
N/A
1.356
CategoryManagement$DeleteConfirmationDialog
0%
0/47
N/A
1.356
CategoryManagement$DeleteConfirmationDialog$1
0%
0/5
N/A
1.356
CategoryManagement$DeleteConfirmationDialog$1$1
0%
0/10
0%
0/4
1.356
CategoryManagement$DeleteConfirmationDialog$2
0%
0/3
N/A
1.356
CategoryManagement$UpdateCategoryDialog
0%
0/53
0%
0/2
1.356
CategoryManagement$UpdateCategoryDialog$1
0%
0/5
N/A
1.356
CategoryManagement$UpdateCategoryDialog$1$1
0%
0/10
0%
0/4
1.356
CategoryManagement$UpdateCategoryDialog$2
0%
0/3
N/A
1.356
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.lum.common.client.lo;
 17  
 
 18  
 import com.google.gwt.core.client.GWT;
 19  
 import com.google.gwt.event.dom.client.ClickEvent;
 20  
 import com.google.gwt.event.dom.client.ClickHandler;
 21  
 import com.google.gwt.event.dom.client.KeyUpEvent;
 22  
 import com.google.gwt.event.dom.client.KeyUpHandler;
 23  
 import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
 24  
 import com.google.gwt.user.client.Window;
 25  
 import com.google.gwt.user.client.ui.Anchor;
 26  
 import com.google.gwt.user.client.ui.Composite;
 27  
 import com.google.gwt.user.client.ui.FlexTable;
 28  
 import com.google.gwt.user.client.ui.HorizontalPanel;
 29  
 import com.google.gwt.user.client.ui.VerticalPanel;
 30  
 import org.kuali.student.common.ui.client.application.KSAsyncCallback;
 31  
 import org.kuali.student.common.ui.client.service.DataSaveResult;
 32  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 33  
 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
 34  
 import org.kuali.student.common.ui.client.widgets.KSDropDown;
 35  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 36  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 37  
 import org.kuali.student.common.ui.client.widgets.KSTextBox;
 38  
 import org.kuali.student.common.ui.client.widgets.list.impl.SimpleListItems;
 39  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotification;
 40  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotifier;
 41  
 import org.kuali.student.common.ui.client.widgets.searchtable.ResultRow;
 42  
 import org.kuali.student.core.assembly.data.Data;
 43  
 import org.kuali.student.lum.common.client.lo.rpc.LoCategoryRpcService;
 44  
 import org.kuali.student.lum.common.client.lo.rpc.LoCategoryRpcServiceAsync;
 45  
 import org.kuali.student.lum.lo.dto.LoCategoryInfo;
 46  
 import org.kuali.student.lum.lo.dto.LoCategoryTypeInfo;
 47  
 
 48  
 import java.util.ArrayList;
 49  
 import java.util.List;
 50  
 
 51  0
 public class CategoryManagement extends Composite {
 52  0
     private KSButton addButton = new KSButton("Create");
 53  0
     private KSButton deleteButton = new KSButton("Delete");
 54  0
     private KSButton updateButton = new KSButton("Edit");
 55  
    
 56  0
     KSCheckBox accreditationCheckBox = new KSCheckBox("Accreditation");
 57  0
     KSCheckBox skillCheckBox = new KSCheckBox("Skill");
 58  0
     KSCheckBox subjectCheckBox = new KSCheckBox("Subject");
 59  0
     KSTextBox wordsInCategoryTextBox = new KSTextBox();
 60  
         
 61  0
     static LoCategoryRpcServiceAsync loCatRpcServiceAsync = GWT.create(LoCategoryRpcService.class);
 62  
 
 63  0
     CategoryManagementTable categoryManagementTable = null;
 64  
    
 65  0
     VerticalPanel mainPanel = new VerticalPanel();
 66  0
     KSLabel messageLabel = new KSLabel();
 67  
     
 68  
     List<LoCategoryTypeInfo> categoryTypeList;
 69  
     private void initCategoryManagement() {
 70  0
         super.initWidget(mainPanel);
 71  0
         mainPanel.addStyleName("KSLOCategoryManagementMainPanel");
 72  
  
 73  0
         HorizontalPanel titlePanel = new HorizontalPanel();
 74  
         
 75  0
         KSLabel funnelImg = new KSLabel("");
 76  0
         funnelImg.addStyleName("KS-LOFunnelImg");
 77  0
         titlePanel.add(funnelImg);
 78  
         
 79  0
         KSLabel filterLabel = new KSLabel("Filter");
 80  0
         filterLabel.addStyleName("KSLOCategoryManagementFilterLabel");
 81  0
         titlePanel.add(filterLabel);
 82  
         
 83  0
         mainPanel.add(titlePanel);
 84  
         
 85  0
         addButton.setStyleName("KS-LOSecondaryButton");
 86  0
         deleteButton.setStyleName("KS-LOSecondaryButton");
 87  0
         updateButton.setStyleName("KS-LOSecondaryButton");
 88  
      
 89  0
         accreditationCheckBox.setValue(true);
 90  0
         skillCheckBox.setValue(true);
 91  0
         subjectCheckBox.setValue(true);
 92  
         
 93  0
         HorizontalPanel linkButtonPanel = new HorizontalPanel();
 94  0
         linkButtonPanel.addStyleName("KSLOCategoryManagementFilterPanel");
 95  
         
 96  0
         KSLabel spacer = new KSLabel("");
 97  0
         spacer.setWidth("60px");
 98  0
         KSLabel divider = new KSLabel("|");
 99  
         
 100  0
         Anchor selectAllLink = new Anchor("Select All");
 101  0
         selectAllLink.addStyleName("KS-LOSelectAllHyperlink");
 102  0
         linkButtonPanel.add(selectAllLink);
 103  0
         selectAllLink.addClickHandler(new ClickHandler(){
 104  
             @Override
 105  
             public void onClick(ClickEvent event) {
 106  0
                 accreditationCheckBox.setValue(true);
 107  0
                 skillCheckBox.setValue(true);
 108  0
                 subjectCheckBox.setValue(true);
 109  0
                 filterCategoryByType();
 110  0
             }
 111  
         });
 112  
          
 113  0
         linkButtonPanel.add(divider);
 114  
         
 115  0
         Anchor clearLink = new Anchor("Clear");
 116  0
         clearLink.addStyleName("KS-LOClearHyperlink");
 117  0
         linkButtonPanel.add(clearLink);
 118  0
         clearLink.addClickHandler(new ClickHandler(){
 119  
             @Override
 120  
             public void onClick(ClickEvent event) {
 121  0
                 accreditationCheckBox.setValue(false);
 122  0
                 skillCheckBox.setValue(false);
 123  0
                 subjectCheckBox.setValue(false);
 124  0
                 wordsInCategoryTextBox.setText(null);
 125  0
                 filterCategoryByType();
 126  0
             }
 127  
         });
 128  0
         linkButtonPanel.add(spacer);
 129  0
         linkButtonPanel.add(addButton);
 130  0
         linkButtonPanel.add(updateButton);
 131  0
         linkButtonPanel.add(deleteButton);
 132  0
         mainPanel.add(linkButtonPanel);
 133  
         
 134  0
         HorizontalPanel filterTablePanel = new HorizontalPanel();
 135  0
         VerticalPanel filterPanel = new VerticalPanel();
 136  0
         filterPanel.addStyleName("KSLOCategoryManagementFilterPanel");
 137  
        
 138  0
         filterPanel.add(accreditationCheckBox);
 139  0
         filterPanel.add(skillCheckBox);
 140  0
         filterPanel.add(subjectCheckBox);
 141  0
         HorizontalPanel spacer1 = new HorizontalPanel();
 142  0
         spacer1.setStyleName("KS-LOSpacer");
 143  0
         filterPanel.add(spacer1);
 144  0
         KSLabel wordsInCategory = new KSLabel("By words in category");
 145  0
         wordsInCategory.setStyleName("KS-LODialogFieldLabel");
 146  0
         filterPanel.add(wordsInCategory);
 147  0
         filterPanel.add(wordsInCategoryTextBox);
 148  
         
 149  0
         filterTablePanel.add(filterPanel);
 150  0
         if(this.categoryManagementTable == null) {
 151  0
             categoryManagementTable = new CategoryManagementTable();
 152  
         }
 153  0
         filterTablePanel.add(categoryManagementTable);
 154  0
         mainPanel.add(filterTablePanel);
 155  
         
 156  0
         mainPanel.add(messageLabel);
 157  
 
 158  0
         loCatRpcServiceAsync.getLoCategoryTypes(new KSAsyncCallback<List<LoCategoryTypeInfo>>() {
 159  
             @Override
 160  
             public void handleFailure(Throwable caught) {
 161  0
                 GWT.log("getLoCategoryTypes failed", caught);
 162  0
                 Window.alert("Get LoCategory Types failed");
 163  0
             }
 164  
             @Override
 165  
             public void onSuccess(List<LoCategoryTypeInfo> results) {
 166  0
                 categoryTypeList = results;
 167  0
                 categoryManagementTable.loadTable();
 168  0
             }
 169  
         });
 170  
 
 171  0
         wordsInCategoryTextBox.addKeyUpHandler(new KeyUpHandler() {
 172  
             @Override
 173  
             public void onKeyUp(KeyUpEvent event) {
 174  0
                 filterCategoryByWords();
 175  0
             }
 176  
 
 177  
         });
 178  0
         subjectCheckBox.addClickHandler(new ClickHandler() {
 179  
             @Override
 180  
             public void onClick(ClickEvent event) {
 181  0
                 filterCategoryByType();
 182  0
             }
 183  
         });
 184  0
         skillCheckBox.addClickHandler(new ClickHandler() {
 185  
             @Override
 186  
             public void onClick(ClickEvent event) {
 187  0
                 filterCategoryByType();
 188  0
             }
 189  
         });
 190  0
         accreditationCheckBox.addClickHandler(new ClickHandler() {
 191  
             @Override
 192  
             public void onClick(ClickEvent event) {
 193  0
                 filterCategoryByType();
 194  0
             }
 195  
         });
 196  
 
 197  0
         addButton.addClickHandler(new ClickHandler() {
 198  
             @Override
 199  
             public void onClick(ClickEvent event) {
 200  0
                 CreateCategoryDialog dialog = new CreateCategoryDialog();
 201  0
                 dialog.setCategoryType(categoryTypeList);
 202  0
                 dialog.show();
 203  0
             }
 204  
         });
 205  0
         deleteButton.addClickHandler(new ClickHandler() {
 206  
             @Override
 207  
             public void onClick(ClickEvent event) {
 208  
                 
 209  0
                 String id = categoryManagementTable.getSelectedLoCategoryInfoId();
 210  0
                 if(id != null){
 211  0
                         loCatRpcServiceAsync.getData(id, new KSAsyncCallback<Data>() {
 212  
                             @Override
 213  
                             public void handleFailure(Throwable caught) {
 214  0
                                 GWT.log("getSelectedLoCategoryInfo failed", caught);
 215  0
                                 Window.alert("Get Selected Lo Category failed");
 216  0
                             }
 217  
 
 218  
                         @Override
 219  
                         public void onSuccess(Data result) {
 220  0
                             DeleteConfirmationDialog dialog = new DeleteConfirmationDialog();
 221  0
                             dialog.setCategory(CategoryDataUtil.toLoCategoryInfo(result));
 222  0
                             dialog.show();
 223  0
                         }
 224  
                         });
 225  
                 }
 226  
 
 227  0
             }
 228  
         });
 229  0
         updateButton.addClickHandler(new ClickHandler() {
 230  
             @Override
 231  
             public void onClick(ClickEvent event) {
 232  0
                 String id = categoryManagementTable.getSelectedLoCategoryInfoId();
 233  0
                 if(id != null){
 234  0
                         loCatRpcServiceAsync.getData(id, new KSAsyncCallback<Data>() {
 235  
                             @Override
 236  
                             public void handleFailure(Throwable caught) {
 237  0
                                 GWT.log("getSelectedLoCategoryInfo failed", caught);
 238  0
                                 Window.alert("Get Selected Lo Category failed");
 239  0
                             }
 240  
                         @Override
 241  
                         public void onSuccess(Data result) {
 242  0
                                 UpdateCategoryDialog dialog = new UpdateCategoryDialog();
 243  0
                                 dialog.setCategory(CategoryDataUtil.toLoCategoryInfo(result));
 244  0
                                 dialog.setCategoryType(categoryTypeList);
 245  0
                                 dialog.show();
 246  0
                             }
 247  
                         });
 248  
                 }
 249  0
             }
 250  
         });
 251  0
     }
 252  
 
 253  0
     public CategoryManagement() {
 254  0
         initCategoryManagement();
 255  0
     }
 256  
     
 257  0
     public CategoryManagement(boolean hideInactiveCategories,SelectionPolicy selectionPolicy) {
 258  0
         this.categoryManagementTable = new CategoryManagementTable(hideInactiveCategories, selectionPolicy);
 259  0
         initCategoryManagement();
 260  0
     }
 261  
     public List<LoCategoryInfo> getSelectedCategoryList(){
 262  0
         return categoryManagementTable.getSelectedLoCategoryInfos();
 263  
     }
 264  
                
 265  
     private void filterCategoryByType() {
 266  
 
 267  0
         List<ResultRow> bufferList = new ArrayList<ResultRow>();
 268  0
         if(subjectCheckBox.getValue() == true){
 269  0
             bufferList.addAll(categoryManagementTable.getRowsByType("subject"));
 270  
         }
 271  0
         if(skillCheckBox.getValue() == true){
 272  0
             bufferList.addAll(categoryManagementTable.getRowsByType("skill"));
 273  
         }
 274  0
         if(accreditationCheckBox.getValue() == true){
 275  0
             bufferList.addAll(categoryManagementTable.getRowsByType("accreditation"));
 276  
         }
 277  0
         categoryManagementTable.redraw(bufferList);
 278  
 
 279  0
     }
 280  
     
 281  
     private void filterCategoryByWords() {
 282  
 
 283  0
         List<ResultRow> bufferList = new ArrayList<ResultRow>();
 284  0
         String input = wordsInCategoryTextBox.getText();
 285  0
         if(input != null && (!input.isEmpty())){
 286  0
             List<ResultRow> tmpList = categoryManagementTable.getRowsLikeName(input);
 287  0
             bufferList.addAll(tmpList);
 288  0
             categoryManagementTable.redraw(bufferList);
 289  0
         } else {
 290  0
             filterCategoryByType();
 291  
         }       
 292  0
     }
 293  
 
 294  
     public void setDeleteButtonEnabled(boolean b) {
 295  0
         deleteButton.setVisible(b);
 296  0
     }
 297  
 
 298  
     public void setUpdateButtonEnabled(boolean b) {
 299  0
         updateButton.setVisible(b);
 300  0
     }
 301  
 
 302  
     public void setInsertButtonEnabled(boolean b) {
 303  0
         addButton.setVisible(b);
 304  0
     }
 305  
     class DeleteConfirmationDialog extends KSLightBox {
 306  0
             FlexTable layoutTable = new FlexTable();
 307  0
         KSLabel categoryNameLabel = new KSLabel();
 308  0
         KSLabel categoryTypeLabel = new KSLabel();
 309  0
         HorizontalPanel spacer = new HorizontalPanel();
 310  
         LoCategoryInfo categoryInfo;
 311  
         
 312  0
         public DeleteConfirmationDialog() {
 313  0
                 this.setSize(540, 200);
 314  0
                 spacer.setStyleName("KS-LOSpacer");
 315  0
             VerticalPanel mainPanel = new VerticalPanel();
 316  
             
 317  0
             KSLabel titleLabel = new KSLabel("Delete Category");
 318  0
             titleLabel.setStyleName("KS-LODialogTitle");
 319  0
             mainPanel.add(spacer);
 320  0
             mainPanel.add(titleLabel);
 321  0
             HorizontalPanel spacer1 = new HorizontalPanel();
 322  0
             spacer1.setStyleName("KS-LOSpacer");
 323  0
             mainPanel.add(spacer1);
 324  0
             mainPanel.add(new KSLabel("You are about to delete the following:"));
 325  0
             HorizontalPanel spacer2 = new HorizontalPanel();
 326  0
             spacer2.setStyleName("KS-LOSpacer"); 
 327  0
             mainPanel.add(spacer2);
 328  0
             KSLabel catLabel = new KSLabel("Category");
 329  0
             mainPanel.add(layoutTable);
 330  0
             layoutTable.setWidget(0, 0, catLabel);
 331  0
             layoutTable.setWidget(0, 1, categoryNameLabel);
 332  0
             KSLabel typeLabel = new KSLabel("Type");
 333  0
             layoutTable.setWidget(1, 0, typeLabel);
 334  0
             layoutTable.setWidget(1, 1, categoryTypeLabel);
 335  0
             layoutTable.getFlexCellFormatter().setStyleName(0, 0, "KS-LODialogLabel");
 336  0
             layoutTable.getFlexCellFormatter().setStyleName(1, 0, "KS-LODialogLabel");
 337  
             
 338  0
                 HorizontalPanel spacer3 = new HorizontalPanel();
 339  0
             spacer3.setStyleName("KS-LOSpacer"); 
 340  0
             mainPanel.add(spacer3);
 341  0
             KSButton deleteButton = new KSButton("Delete");
 342  0
             Anchor cancelButton = new Anchor();
 343  0
             cancelButton.setStyleName("KS-LODialogCancel");
 344  0
             cancelButton.setText("Cancel");
 345  0
             HorizontalPanel buttonPanel = new HorizontalPanel();
 346  0
             buttonPanel.add(deleteButton);
 347  
 
 348  0
             deleteButton.addClickHandler(new ClickHandler() {
 349  
                 @Override
 350  
                 public void onClick(ClickEvent event) {
 351  
                     // not really deleting; rather 'retiring' LoCategory, but switching state to "inactive"
 352  0
                         categoryInfo.setState("inactive");
 353  0
                     loCatRpcServiceAsync.saveData(CategoryDataUtil.toData(categoryInfo), new KSAsyncCallback<DataSaveResult>(){
 354  
                         @Override
 355  
                         public void handleFailure(Throwable caught) {
 356  0
                             GWT.log("updateLoCategory failed ", caught);
 357  0
                             Window.alert("Switch LoCategory state to inactive failed ");
 358  0
                         }
 359  
                         @Override
 360  
                         public void onSuccess(DataSaveResult result) {
 361  
 //                            KSBlockingProgressIndicator.removeTask(saving);
 362  
 
 363  0
                             if(result.getValidationResults()!=null && !result.getValidationResults().isEmpty()){
 364  0
                                 Window.alert("Update LO Category failed: " + result.getValidationResults().get(0).getMessage());
 365  
                            }else{
 366  0
                             KSNotifier.add(new KSNotification("Update LO Category Successful", false, 3000));
 367  0
                             categoryManagementTable.loadTable();
 368  0
                             filterCategoryByType();
 369  
                             }
 370  0
                         }
 371  
                     });
 372  
 
 373  0
                     DeleteConfirmationDialog.this.hide();
 374  0
                 }
 375  
             });
 376  
 
 377  0
             buttonPanel.add(cancelButton);
 378  0
             cancelButton.addClickHandler(new ClickHandler() {
 379  
                 @Override
 380  
                 public void onClick(ClickEvent event) {
 381  0
                     DeleteConfirmationDialog.this.hide();
 382  0
                 }
 383  
 
 384  
             });
 385  0
             mainPanel.add(buttonPanel);
 386  0
             super.setWidget(mainPanel);
 387  0
         }
 388  
 
 389  
         public void setCategory(LoCategoryInfo cate) {
 390  0
             categoryInfo = cate;
 391  0
             categoryNameLabel.setText(categoryInfo.getName());
 392  0
             categoryTypeLabel.setText(categoryInfo.getType());
 393  0
         }
 394  
     }
 395  
     class UpdateCategoryDialog extends KSLightBox {
 396  0
         FlexTable layoutTable = new FlexTable();
 397  0
         KSTextBox nameTextBox = new KSTextBox();
 398  0
         KSDropDown typeListBox = new KSDropDown();
 399  0
         KSButton okButton = new KSButton("Save");
 400  0
         Anchor cancelButton = new Anchor("Cancel");
 401  
         LoCategoryInfo categoryInfo;
 402  0
         HorizontalPanel spacer = new HorizontalPanel();
 403  
 
 404  0
         public UpdateCategoryDialog() {
 405  0
                 this.setSize(540, 200);
 406  0
                 spacer.setStyleName("KS-LOSpacer");
 407  0
                 cancelButton.setStyleName("KS-LODialogCancel");
 408  0
                 typeListBox.setHeight("21px");
 409  0
                 KSLabel catLabel = new KSLabel("Category");
 410  0
                 catLabel.setStyleName("KS-LODialogFieldLabel");
 411  0
                 KSLabel typeLabel = new KSLabel("Type");
 412  0
                 typeLabel.setStyleName("KS-LODialogFieldLabel");
 413  0
             layoutTable.setWidget(0, 0, catLabel);
 414  0
             layoutTable.setWidget(0, 1, typeLabel);
 415  0
             layoutTable.setWidget(1, 0, nameTextBox);
 416  0
             layoutTable.setWidget(1, 1, typeListBox);
 417  
 
 418  0
             HorizontalPanel buttonPanel = new HorizontalPanel();
 419  0
             buttonPanel.add(okButton);
 420  0
             buttonPanel.add(cancelButton);
 421  
 
 422  0
             VerticalPanel mainPanel = new VerticalPanel();
 423  0
             mainPanel.add(spacer);
 424  0
             KSLabel titleLabel = new KSLabel("Edit Category");
 425  0
             titleLabel.setStyleName("KS-LODialogTitle");
 426  0
             mainPanel.add(titleLabel);
 427  0
             HorizontalPanel spacer1 = new HorizontalPanel();
 428  0
             spacer1.setStyleName("KS-LOSpacer");
 429  0
             mainPanel.add(spacer1);
 430  0
             mainPanel.add(layoutTable);
 431  0
             HorizontalPanel spacer2 = new HorizontalPanel();
 432  0
             spacer2.setStyleName("KS-LOSpacer");
 433  0
             mainPanel.add(spacer2);
 434  0
             mainPanel.add(buttonPanel);
 435  0
             super.setWidget(mainPanel);
 436  0
             okButton.addClickHandler(new ClickHandler() {
 437  
                 @Override
 438  
                 public void onClick(ClickEvent event) {
 439  0
                     LoCategoryInfo cate = getCategory();
 440  
 
 441  0
                     loCatRpcServiceAsync.saveData(CategoryDataUtil.toData(cate), new KSAsyncCallback<DataSaveResult>(){
 442  
                         @Override
 443  
                         public void handleFailure(Throwable caught) {
 444  0
                             GWT.log("updateLoCategory failed ", caught);
 445  0
                             Window.alert("Update LoCategory failed ");
 446  0
                         }
 447  
                         @Override
 448  
                         public void onSuccess(DataSaveResult result) {
 449  0
                             if(result.getValidationResults()!=null && !result.getValidationResults().isEmpty()){
 450  0
                                 Window.alert("Update LO Category failed: " + result.getValidationResults().get(0).getMessage());
 451  
                            }else{
 452  0
                             KSNotifier.add(new KSNotification("Update LO Category Successful", false, 3000));
 453  0
                             categoryManagementTable.loadTable();
 454  0
                             filterCategoryByType();
 455  
                             }
 456  0
                         }
 457  
                     });
 458  
 
 459  0
                     UpdateCategoryDialog.this.hide();
 460  0
                 }
 461  
 
 462  
             });
 463  
 
 464  0
             cancelButton.addClickHandler(new ClickHandler() {
 465  
 
 466  
                 @Override
 467  
                 public void onClick(ClickEvent event) {
 468  0
                     UpdateCategoryDialog.this.hide();
 469  0
                 }
 470  
 
 471  
             });
 472  0
             super.setWidget(mainPanel);
 473  0
         }
 474  
 
 475  
         public void setCategoryType(List<LoCategoryTypeInfo> categoryTypeList) {
 476  0
             typeListBox.clear();
 477  0
             SimpleListItems categoryTypes = new SimpleListItems();
 478  0
             for (LoCategoryTypeInfo type : categoryTypeList) {
 479  0
                 categoryTypes.addItem(type.getId(), type.getDesc());
 480  
             }
 481  0
             typeListBox.setListItems(categoryTypes);
 482  0
         }
 483  
 
 484  
         public void setCategory(LoCategoryInfo cate) {
 485  0
             categoryInfo = cate;
 486  0
             nameTextBox.setText(categoryInfo.getName());
 487  0
             typeListBox.selectItem(categoryInfo.getType());
 488  0
         }
 489  
 
 490  
         public LoCategoryInfo getCategory() {
 491  0
             categoryInfo.setName(nameTextBox.getText());
 492  
             //categoryInfo.setType(typeListBox.getItemText(typeListBox.getSelectedIndex()));
 493  0
             categoryInfo.setType(typeListBox.getSelectedItem());
 494  0
             return categoryInfo;
 495  
         }
 496  
     }
 497  
 
 498  
     class CreateCategoryDialog extends KSLightBox {
 499  0
         FlexTable layoutTable = new FlexTable();
 500  0
         KSButton okButton = new KSButton("Save");
 501  0
         Anchor cancelButton = new Anchor("Cancel");
 502  0
         KSTextBox nameTextBox = new KSTextBox(); 
 503  0
         KSDropDown typeListBox = new KSDropDown();
 504  0
         HorizontalPanel spacer = new HorizontalPanel();
 505  
         
 506  0
         public CreateCategoryDialog() {
 507  0
                 this.setSize(540, 200);
 508  0
                 spacer.setStyleName("KS-LOSpacer");
 509  0
                 cancelButton.setStyleName("KS-LODialogCancel");
 510  0
                 typeListBox.setHeight("21px");
 511  0
                 KSLabel catLabel = new KSLabel("Category");
 512  0
                 catLabel.setStyleName("KS-LODialogFieldLabel");
 513  0
                 KSLabel typeLabel = new KSLabel("Type");
 514  0
                 typeLabel.setStyleName("KS-LODialogFieldLabel");
 515  0
             layoutTable.setWidget(0, 0, catLabel);
 516  0
             layoutTable.setWidget(0, 1, typeLabel);
 517  0
             layoutTable.setWidget(1, 0, nameTextBox);
 518  0
             layoutTable.setWidget(1, 1, typeListBox);
 519  
             
 520  0
             HorizontalPanel buttonPanel = new HorizontalPanel();
 521  0
             buttonPanel.add(okButton);
 522  0
             buttonPanel.add(cancelButton);
 523  
             
 524  0
             VerticalPanel mainPanel = new VerticalPanel();
 525  0
             mainPanel.add(spacer);
 526  0
             KSLabel titleLabel = new KSLabel("Create New Category");
 527  0
             titleLabel.setStyleName("KS-LODialogTitle");
 528  0
             HorizontalPanel spacer1 = new HorizontalPanel();
 529  0
             spacer1.setStyleName("KS-LOSpacer");
 530  
             
 531  0
             mainPanel.add(titleLabel);
 532  0
             mainPanel.add(spacer1);
 533  0
             mainPanel.add(layoutTable);
 534  0
             HorizontalPanel spacer2 = new HorizontalPanel();
 535  0
             spacer2.setStyleName("KS-LOSpacer");
 536  0
             mainPanel.add(spacer2);
 537  0
             mainPanel.add(buttonPanel);
 538  0
             super.setWidget(mainPanel);
 539  0
             okButton.addClickHandler(new ClickHandler() {
 540  
                 @Override
 541  
                 public void onClick(ClickEvent event) {
 542  0
                     LoCategoryInfo cate = getCategory();
 543  0
                     loCatRpcServiceAsync.saveData(CategoryDataUtil.toData(cate), new KSAsyncCallback<DataSaveResult>(){
 544  
                         @Override
 545  
                         public void handleFailure(Throwable caught) {
 546  0
                             Window.alert("Create LO Category failed: " + caught.getMessage());
 547  0
                         }
 548  
                         @Override
 549  
                         public void onSuccess(DataSaveResult result) {
 550  0
                             if(result.getValidationResults()!=null && !result.getValidationResults().isEmpty()){
 551  0
                                 Window.alert("Create LO Category failed: " + result.getValidationResults().get(0).getMessage());
 552  
                            }else{
 553  0
                             KSNotifier.add(new KSNotification("Create LO Category Successful", false, 3000));
 554  0
                             categoryManagementTable.loadTable();
 555  0
                             filterCategoryByType();
 556  
                             }
 557  0
                         }
 558  
                     });
 559  
 
 560  0
                     CreateCategoryDialog.this.hide();
 561  0
                 }
 562  
             });
 563  0
             cancelButton.addClickHandler(new ClickHandler() {
 564  
 
 565  
                 @Override
 566  
                 public void onClick(ClickEvent event) {
 567  0
                     CreateCategoryDialog.this.hide();
 568  0
                 }
 569  
 
 570  
             });
 571  0
         }
 572  
 
 573  
         public void setCategoryType(List<LoCategoryTypeInfo> categoryTypeList) {
 574  0
             typeListBox.clear();
 575  0
             SimpleListItems categoryTypes = new SimpleListItems();
 576  0
             for (LoCategoryTypeInfo type : categoryTypeList) {
 577  0
                 categoryTypes.addItem(type.getId(), type.getDesc());
 578  
             }
 579  0
             typeListBox.setListItems(categoryTypes);
 580  0
         }
 581  
 
 582  
         public LoCategoryInfo getCategory() {
 583  0
             LoCategoryInfo info = new LoCategoryInfo();
 584  0
             info.setName(nameTextBox.getText());
 585  0
             info.setType(typeListBox.getSelectedItem());
 586  0
             info.setState("active");
 587  0
             info.setLoRepository("kuali.loRepository.key.singleUse");
 588  
             // FIXME [KSCOR-225] user needs to specify what LoRepository they want category to tagged with
 589  0
             return info;
 590  
         }
 591  
     }
 592  
 
 593  
 }
 594  
 
 595