Coverage Report - org.kuali.student.common.ui.client.widgets.menus.impl.KSBlockMenuImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KSBlockMenuImpl
0%
0/32
0%
0/4
1.5
KSBlockMenuImpl$1
0%
0/4
0%
0/2
1.5
 
 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.widgets.menus.impl;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.kuali.student.common.ui.client.mvc.Callback;
 22  
 import org.kuali.student.common.ui.client.widgets.menus.KSMenuItemData;
 23  
 
 24  
 import com.google.gwt.user.client.ui.Composite;
 25  
 import com.google.gwt.user.client.ui.FlowPanel;
 26  
 import com.google.gwt.user.client.ui.HTMLPanel;
 27  
 
 28  0
 public class KSBlockMenuImpl extends Composite{
 29  0
         private FlowPanel layout = new FlowPanel();
 30  0
         private FlowPanel container = new FlowPanel();
 31  0
         private List<KSListMenuImpl> menus = new ArrayList<KSListMenuImpl>();
 32  
         private List<KSMenuItemData> data;
 33  
 
 34  0
         public KSBlockMenuImpl(){
 35  
                 //layout.setStyleName("KS-Block-Menu");
 36  0
                 layout.setStyleName("ks-page-sub-navigation");
 37  0
                 container.add(layout);
 38  0
                 layout.add(new HTMLPanel("<div class=\"clear\">&nbsp;</div>"));
 39  0
                 this.initWidget(container);
 40  0
         }
 41  
 
 42  
         public void addMenu(KSListMenuImpl menu){
 43  0
                 menu.setStyleName("ks-page-sub-navigation-menu");
 44  0
                 layout.insert(menu, layout.getWidgetCount() -1);
 45  0
                 menus.add(menu);
 46  0
                 menu.addGlobalMenuItemSelectCallback(new Callback<KSMenuItemData>(){
 47  
 
 48  
                         @Override
 49  
                         public void exec(KSMenuItemData result) {
 50  0
                                 for(int i=0; i < KSBlockMenuImpl.this.menus.size(); i++){
 51  0
                                         KSBlockMenuImpl.this.menus.get(i).clearSelected();
 52  
                                 }
 53  
                                 
 54  0
                         }
 55  
                 });
 56  
 
 57  0
         }
 58  
 
 59  
         public void setMenus(List<KSListMenuImpl> menus){
 60  0
                 for(KSListMenuImpl menu: menus){
 61  0
                         this.addMenu(menu);
 62  
                 }
 63  0
         }
 64  
 
 65  
         /**
 66  
          * Use the top level menu items of a list of KSMenuItemData to generate separate menus in a block
 67  
          * layout
 68  
          * @param data
 69  
          */
 70  
         public void setTopLevelItems(List<KSMenuItemData> data){
 71  0
                 this.data = data;
 72  0
                 refresh();
 73  0
         }
 74  
         
 75  
         public void refresh(){
 76  0
                 layout.clear();
 77  0
                 menus.clear();
 78  0
                 layout.add(new HTMLPanel("<div class=\"clear\">&nbsp;</div>"));
 79  0
                 for(KSMenuItemData item: data){
 80  0
                         List<KSMenuItemData> list = new ArrayList<KSMenuItemData>();
 81  0
                         list.add(item);
 82  0
                         KSListMenuImpl menu = new KSListMenuImpl();
 83  0
                         menu.setItems(list);
 84  0
                         this.addMenu(menu);
 85  0
                 }
 86  0
         }
 87  
         
 88  
 }