| 1 |  |  package org.kuali.student.lum.common.client.lo; | 
  | 2 |  |   | 
  | 3 |  |  import com.google.gwt.event.dom.client.ClickEvent; | 
  | 4 |  |  import com.google.gwt.event.dom.client.ClickHandler; | 
  | 5 |  |  import com.google.gwt.user.client.Event; | 
  | 6 |  |  import com.google.gwt.user.client.ui.Button; | 
  | 7 |  |  import com.google.gwt.user.client.ui.HorizontalPanel; | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |  class OutlineManagerToolbar extends HorizontalPanel { | 
  | 13 | 0 |          Button moveUpButton = new Button(); | 
  | 14 |  |   | 
  | 15 | 0 |          Button moveDownButton = new Button(); | 
  | 16 |  |   | 
  | 17 | 0 |          Button indentButton = new Button(); | 
  | 18 |  |   | 
  | 19 | 0 |          Button outdentButton = new Button(); | 
  | 20 |  |   | 
  | 21 | 0 |          Button deleteButton = new Button(); | 
  | 22 |  |   | 
  | 23 |  |   | 
  | 24 | 0 |          Button addPeerButton = new Button(); | 
  | 25 |  |   | 
  | 26 | 0 |          Button addChildButton = new Button(); | 
  | 27 |  |   | 
  | 28 |  |          OutlineNodeModel outlineModel; | 
  | 29 |  |   | 
  | 30 | 0 |          OutlineManagerToolbar() { | 
  | 31 |  |   | 
  | 32 | 0 |                  HorizontalPanel buttonPanel = new HorizontalPanel(); | 
  | 33 |  |   | 
  | 34 | 0 |                  this.setStyleName("KS-LOOutlineManagerToolbar"); | 
  | 35 | 0 |                  super.add(buttonPanel); | 
  | 36 | 0 |                  buttonPanel.add(moveUpButton); | 
  | 37 | 0 |                  buttonPanel.add(moveDownButton); | 
  | 38 | 0 |                  buttonPanel.add(indentButton); | 
  | 39 | 0 |                  buttonPanel.add(outdentButton); | 
  | 40 | 0 |                  buttonPanel.add(deleteButton); | 
  | 41 | 0 |                  buttonPanel.addStyleName("KS-LOButtonPanel"); | 
  | 42 |  |   | 
  | 43 | 0 |                  sinkEvents(Event.ONMOUSEMOVE); | 
  | 44 | 0 |                  sinkEvents(Event.ONMOUSEOUT); | 
  | 45 |  |   | 
  | 46 | 0 |                  moveUpButton.sinkEvents(Event.ONMOUSEMOVE); | 
  | 47 | 0 |                  moveUpButton.sinkEvents(Event.ONMOUSEOUT); | 
  | 48 | 0 |                  moveUpButton.setTitle("Move learning objective up"); | 
  | 49 | 0 |                  moveUpButton.addStyleName("KS-LOMoveUpButton"); | 
  | 50 | 0 |                  moveDownButton.addStyleName("KS-LOMoveDownButton"); | 
  | 51 | 0 |                  moveDownButton.setTitle("Move learning objective down"); | 
  | 52 | 0 |                  deleteButton.setText("Delete"); | 
  | 53 | 0 |                  deleteButton.setTitle("Delete"); | 
  | 54 | 0 |                  deleteButton.addStyleName("KS-LODeleteButton"); | 
  | 55 | 0 |                  indentButton.addStyleName("KS-LOIndentButton"); | 
  | 56 | 0 |                  indentButton.setTitle("Indent learning objective"); | 
  | 57 | 0 |                  outdentButton.addStyleName("KS-LOOutdentButton"); | 
  | 58 | 0 |                  outdentButton.setTitle("Outdent learning objective"); | 
  | 59 |  |   | 
  | 60 | 0 |                  moveUpButton.addClickHandler(new ClickHandler() { | 
  | 61 |  |                          public void onClick(ClickEvent event) { | 
  | 62 | 0 |                                  outlineModel.moveUpCurrent(); | 
  | 63 |  |   | 
  | 64 | 0 |                          } | 
  | 65 |  |                  }); | 
  | 66 | 0 |                  moveDownButton.addClickHandler(new ClickHandler() { | 
  | 67 |  |                          public void onClick(ClickEvent event) { | 
  | 68 | 0 |                                  outlineModel.moveDownCurrent(); | 
  | 69 | 0 |                          } | 
  | 70 |  |                  }); | 
  | 71 | 0 |                  indentButton.addClickHandler(new ClickHandler() { | 
  | 72 |  |                          public void onClick(ClickEvent event) { | 
  | 73 | 0 |                                  outlineModel.indentCurrent(); | 
  | 74 | 0 |                          } | 
  | 75 |  |                  }); | 
  | 76 | 0 |                  outdentButton.addClickHandler(new ClickHandler() { | 
  | 77 |  |                          public void onClick(ClickEvent event) { | 
  | 78 | 0 |                                  outlineModel.outdentCurrent(); | 
  | 79 | 0 |                          } | 
  | 80 |  |                  }); | 
  | 81 | 0 |                  deleteButton.addClickHandler(new ClickHandler() { | 
  | 82 |  |                          public void onClick(ClickEvent event) { | 
  | 83 | 0 |                                  outlineModel.deleteCurrent(); | 
  | 84 | 0 |                          } | 
  | 85 |  |                  }); | 
  | 86 | 0 |                  addPeerButton.addClickHandler(new ClickHandler() { | 
  | 87 |  |                          public void onClick(ClickEvent event) { | 
  | 88 | 0 |                                  outlineModel.addPeer(); | 
  | 89 | 0 |                          } | 
  | 90 |  |                  }); | 
  | 91 | 0 |                  addChildButton.addClickHandler(new ClickHandler() { | 
  | 92 |  |                          public void onClick(ClickEvent event) { | 
  | 93 | 0 |                                  outlineModel.addChild(); | 
  | 94 | 0 |                          } | 
  | 95 |  |                  }); | 
  | 96 | 0 |          } | 
  | 97 |  |   | 
  | 98 |  |          public void setModel(OutlineNodeModel model) { | 
  | 99 | 0 |                  outlineModel = model; | 
  | 100 | 0 |          } | 
  | 101 |  |   | 
  | 102 |  |          public void updateButtonStates() { | 
  | 103 | 0 |                  if(  this.outlineModel.isMoveUpable()){ | 
  | 104 | 0 |                          moveUpButton.setEnabled(true); | 
  | 105 | 0 |                          moveUpButton.removeStyleName("KS-LOMoveUpButtonDisabled"); | 
  | 106 | 0 |                          moveUpButton.addStyleName("KS-LOMoveUpButton"); | 
  | 107 |  |                  }else{ | 
  | 108 | 0 |                          moveUpButton.setEnabled(false); | 
  | 109 | 0 |                          moveUpButton.removeStyleName("KS-LOMoveUpButton"); | 
  | 110 | 0 |                          moveUpButton.addStyleName("KS-LOMoveUpButtonDisabled"); | 
  | 111 |  |                  } | 
  | 112 | 0 |                  if(this.outlineModel.isDeletable()){ | 
  | 113 | 0 |                          deleteButton.setEnabled(true); | 
  | 114 | 0 |                          deleteButton.removeStyleName("KS-LODeleteButtonDisabled"); | 
  | 115 | 0 |                          deleteButton.addStyleName("KS-LODeleteButton"); | 
  | 116 |  |                  } else{ | 
  | 117 | 0 |                          deleteButton.setEnabled(false); | 
  | 118 | 0 |                          deleteButton.removeStyleName("KS-LODeleteButton"); | 
  | 119 | 0 |                          deleteButton.addStyleName("KS-LODeleteButtonDisabled"); | 
  | 120 |  |                  } | 
  | 121 | 0 |                  if(this.outlineModel.isIndentable()){ | 
  | 122 | 0 |                          indentButton.setEnabled(true); | 
  | 123 | 0 |                          indentButton.removeStyleName("KS-LOIndentButtonDisabled"); | 
  | 124 | 0 |                          indentButton.addStyleName("KS-LOIndentButton"); | 
  | 125 |  |                  }else{ | 
  | 126 | 0 |                          indentButton.setEnabled(false); | 
  | 127 | 0 |                          indentButton.removeStyleName("KS-LOIndentButton"); | 
  | 128 | 0 |                          indentButton.addStyleName("KS-LOIndentButtonDisabled"); | 
  | 129 |  |                  } | 
  | 130 | 0 |                  if(this.outlineModel.isMoveDownable()){ | 
  | 131 | 0 |                          moveDownButton.setEnabled(true); | 
  | 132 | 0 |                          moveDownButton.removeStyleName("KS-LOMoveDownButtonDisabled"); | 
  | 133 | 0 |                          moveDownButton.addStyleName("KS-LOMoveDownButton"); | 
  | 134 |  |                  }else{ | 
  | 135 | 0 |                          moveDownButton.setEnabled(false); | 
  | 136 | 0 |                          moveDownButton.removeStyleName("KS-LOMoveDownButton"); | 
  | 137 | 0 |                          moveDownButton.addStyleName("KS-LOMoveDownButtonDisabled"); | 
  | 138 |  |                  } | 
  | 139 | 0 |                  if(this.outlineModel.isOutdentable()){ | 
  | 140 | 0 |                          outdentButton.setEnabled(true); | 
  | 141 | 0 |                          outdentButton.removeStyleName("KS-LOOutdentButtonDisabled"); | 
  | 142 | 0 |                          outdentButton.addStyleName("KS-LOOutdentButton"); | 
  | 143 |  |                  }else{ | 
  | 144 | 0 |                          outdentButton.setEnabled(false); | 
  | 145 | 0 |                          outdentButton.removeStyleName("KS-LOOutdentButton"); | 
  | 146 | 0 |                          outdentButton.addStyleName("KS-LOOutdentButtonDisabled"); | 
  | 147 |  |                  } | 
  | 148 | 0 |          } | 
  | 149 |  |  } |