Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.DelayedToolView
 
Classes in this File Line Coverage Branch Coverage Complexity
DelayedToolView
0%
0/34
0%
0/4
1.125
DelayedToolView$1
0%
0/9
N/A
1.125
 
 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.configurable.mvc;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.kuali.student.common.ui.client.mvc.Callback;
 21  
 import org.kuali.student.common.ui.client.mvc.Controller;
 22  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 23  
 import org.kuali.student.common.ui.client.mvc.dto.ReferenceModel;
 24  
 
 25  
 import com.google.gwt.user.client.Window;
 26  
 import com.google.gwt.user.client.ui.LazyPanel;
 27  
 import com.google.gwt.user.client.ui.Widget;
 28  
 
 29  
 /**
 30  
  * 
 31  
  * @author Kuali Student Team
 32  
  *
 33  
  */
 34  0
 public abstract class DelayedToolView extends LazyPanel implements ToolView{
 35  
     private Controller controller;    
 36  
     private Enum<?> viewEnum;
 37  
     private String viewName;    //View name is being used as menu item label   
 38  
 
 39  
     private HasReferenceId reference;
 40  
     
 41  0
     private ModelRequestCallback<ReferenceModel> modelRequestCallback = 
 42  0
         new ModelRequestCallback<ReferenceModel>(){
 43  
             public void onModelReady(ReferenceModel model) {
 44  0
                 reference.setReferenceId(model.getReferenceId());
 45  0
                 reference.setReferenceTypeKey(model.getReferenceTypeKey());
 46  0
                 reference.setReferenceType(model.getReferenceType());
 47  0
                 reference.setReferenceState(model.getReferenceState());
 48  0
                 DelayedToolView.this.setVisible(true);       
 49  0
             }
 50  
     
 51  
             public void onRequestFail(Throwable cause) {
 52  0
                 Window.alert(cause.toString());
 53  0
             }
 54  
     };
 55  
     
 56  
     
 57  
     /**
 58  
      * @param controller
 59  
      * @param name
 60  
      */
 61  0
     public DelayedToolView(Controller controller, Enum<?> viewEnum, String viewName) {
 62  0
         this.controller = controller;
 63  0
         this.viewName = viewName;
 64  0
         this.viewEnum = viewEnum;
 65  0
     }
 66  
 
 67  
 
 68  0
     public DelayedToolView(Enum<?> viewEnum, String viewName) {
 69  0
         this.controller = null;
 70  0
         this.viewEnum = viewEnum;
 71  0
         this.viewName = viewName;
 72  0
     }
 73  
    
 74  
     @Override
 75  
     public void beforeShow(final Callback<Boolean> onReadyCallback){
 76  0
         if (getWidget() instanceof HasReferenceId){
 77  0
             reference = (HasReferenceId)getWidget();
 78  0
             controller.requestModel(ReferenceModel.class, modelRequestCallback);
 79  0
         } else if (this instanceof HasReferenceId){
 80  0
             reference = (HasReferenceId)this;
 81  0
             controller.requestModel(ReferenceModel.class, modelRequestCallback);            
 82  
         } else {
 83  0
             this.setVisible(true);
 84  
         }
 85  
         // FIXME ? need to wire onReadyCallback into the model request, so that we aren't indicating that we're ready before the model is available?
 86  0
         onReadyCallback.exec(true);
 87  0
     }
 88  
 
 89  
     /**
 90  
      * @see org.kuali.student.common.ui.client.mvc.View#beforeHide()
 91  
      */
 92  
     @Override
 93  
     public boolean beforeHide() {
 94  0
         return true;
 95  
     }
 96  
 
 97  
 
 98  
     /**
 99  
      * @see org.kuali.student.common.ui.client.mvc.View#getController()
 100  
      */
 101  
     @Override
 102  
     public Controller getController() {
 103  0
         return this.controller;
 104  
     }
 105  
 
 106  
 
 107  
     /**
 108  
      * @see org.kuali.student.common.ui.client.mvc.View#getName()
 109  
      */
 110  
     @Override
 111  
     public String getName() {
 112  0
         return this.viewName;
 113  
     }
 114  
 
 115  
     public Enum<?> getViewEnum() {
 116  0
         return viewEnum;
 117  
     }
 118  
 
 119  
     /**
 120  
      * @see org.kuali.student.common.ui.client.mvc.View#updateModel()
 121  
      */
 122  
     @Override
 123  
     public void updateModel() {
 124  
         //There is no model to update here, reference model is read-only        
 125  0
     }
 126  
     
 127  
     public void setController(Controller controller){
 128  0
         this.controller = controller;
 129  0
     }
 130  
 
 131  
     
 132  
     public Widget asWidget(){
 133  0
             return this;
 134  
     }
 135  
     
 136  
     @Override
 137  
     public String collectHistory(String historyStack) {
 138  0
             return null;
 139  
     }
 140  
 
 141  
 
 142  
         @Override
 143  
         protected Widget createWidget() {
 144  
                 // TODO Auto-generated method stub
 145  0
                 return null;
 146  
         }
 147  
 
 148  
         @Override
 149  
         public void onHistoryEvent(String historyStack) {
 150  
                 
 151  0
         }
 152  
 
 153  
         @Override
 154  
         public void collectBreadcrumbNames(List<String> names) {
 155  0
                 names.add(this.getName());
 156  
                 
 157  0
         }
 158  
 }