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