| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ViewComposite | 
 | 
 | 1.0;1 | 
| 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.common.ui.client.mvc; | |
| 17 | ||
| 18 |  import java.util.List; | |
| 19 | ||
| 20 |  import com.google.gwt.user.client.ui.Composite; | |
| 21 |  import com.google.gwt.user.client.ui.Widget; | |
| 22 | ||
| 23 |  /** | |
| 24 |   * Abstract class implementing the View interface, which has a handle to it's controller. | |
| 25 |   *  | |
| 26 |   * @author Kuali Student Team | |
| 27 |   */ | |
| 28 | public abstract class ViewComposite extends Composite implements View { | |
| 29 | private final Controller controller; | |
| 30 | private final String name; | |
| 31 | private final Enum<?> viewType; | |
| 32 | ||
| 33 |      /** | |
| 34 |       * Constructs a new view with an associated controller and view name | |
| 35 |       *  | |
| 36 |       * @param controller | |
| 37 |       *            the controller associated with the view | |
| 38 |       * @param name | |
| 39 |       *            the view name | |
| 40 |       */ | |
| 41 | 0 |      public ViewComposite(Controller controller, String name, Enum<?> viewType) { | 
| 42 | 0 |          this.controller = controller; | 
| 43 | 0 |          this.name = name; | 
| 44 | 0 |          this.viewType = viewType; | 
| 45 | 0 |      } | 
| 46 | ||
| 47 |      /** | |
| 48 |       * Called by controller before the view is displayed to allow lazy initialization or any other preparatory work to be | |
| 49 |       * done. | |
| 50 |       */ | |
| 51 | @Override | |
| 52 | public void beforeShow(final Callback<Boolean> onReadyCallback) { | |
| 53 |              // do nothing | |
| 54 | 0 |              onReadyCallback.exec(true); | 
| 55 | 0 |      } | 
| 56 | ||
| 57 |      /** | |
| 58 |       * Called by the controller before the view is hidden to allow the view to perform cleanup or request confirmation from | |
| 59 |       * the user, etc. Can cancel the action by returning false. | |
| 60 |       *  | |
| 61 |       * @return true if the view can be hidden, or false to cancel the action. | |
| 62 |       */ | |
| 63 | @Override | |
| 64 | public boolean beforeHide() { | |
| 65 | 0 |          return true; | 
| 66 | } | |
| 67 | ||
| 68 |      /** | |
| 69 |       * Returns the controller associated with the view | |
| 70 |       *  | |
| 71 |       * @see org.kuali.student.common.ui.client.mvc.View#getController() | |
| 72 |       */ | |
| 73 | @Override | |
| 74 |      public Controller getController() { | |
| 75 | 0 |          return controller; | 
| 76 | } | |
| 77 | ||
| 78 |      /** | |
| 79 |       * Returns the view's name | |
| 80 |       *  | |
| 81 |       * @see org.kuali.student.common.ui.client.mvc.View#getName() | |
| 82 |       */ | |
| 83 | @Override | |
| 84 |      public String getName() { | |
| 85 | 0 |          return name; | 
| 86 | } | |
| 87 | ||
| 88 |      /** | |
| 89 |       * Used to clear view - does nothing currently | |
| 90 |       *  | |
| 91 |       * @see org.kuali.student.common.ui.client.mvc.View#clear() | |
| 92 |       */ | |
| 93 | public void clear(){ | |
| 94 |          //do nothing | |
| 95 | 0 |      } | 
| 96 | ||
| 97 | ||
| 98 |      /** | |
| 99 |       * Update the model that is associated with this view. This will normally be | |
| 100 |       * called by the controller. | |
| 101 |       *   | |
| 102 |       * @see org.kuali.student.common.ui.client.mvc.View#updateModel() | |
| 103 |       */ | |
| 104 | public void updateModel(){ | |
| 105 | 0 |      } | 
| 106 | ||
| 107 | @Override | |
| 108 |          public String collectHistory(String historyStack) { | |
| 109 | 0 |                  return historyStack; | 
| 110 | } | |
| 111 | ||
| 112 | @Override | |
| 113 | public void onHistoryEvent(String historyStack) { | |
| 114 | ||
| 115 | 0 |          } | 
| 116 | ||
| 117 | @Override | |
| 118 | public void collectBreadcrumbNames(List<String> names) { | |
| 119 | 0 |                  names.add(this.getName()); | 
| 120 | 0 |          } | 
| 121 | ||
| 122 | @Override | |
| 123 |      public Enum<?> getViewEnum() { | |
| 124 | 0 |                  return viewType; | 
| 125 | ||
| 126 | }; | |
| 127 | ||
| 128 | @Override | |
| 129 |      public Widget asWidget() { | |
| 130 |              // TODO Auto-generated method stub | |
| 131 | 0 |              return this; | 
| 132 | } | |
| 133 | ||
| 134 | public boolean isExportButtonActive() { | |
| 135 | 0 |          return false; | 
| 136 | } | |
| 137 | ||
| 138 | @Override | |
| 139 | public void showExport(boolean show) { | |
| 140 |                  // Needs to be implemented on subclass where applicable | |
| 141 | 0 |          } | 
| 142 | ||
| 143 | } |