Coverage Report - org.kuali.student.common.ui.client.widgets.search.LinkPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
LinkPanel
0%
0/14
N/A
1
LinkPanel$1
N/A
N/A
1
LinkPanel$PanelInfo
0%
0/18
N/A
1
LinkPanel$PanelInfo$1
0%
0/4
N/A
1
LinkPanel$PanelInfo$NavLink
0%
0/1
N/A
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.widgets.search;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.HashMap;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 
 23  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 24  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
 25  
 import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel;
 26  
 import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel;
 27  
 
 28  
 import com.google.gwt.event.dom.client.ClickEvent;
 29  
 import com.google.gwt.event.dom.client.ClickHandler;
 30  
 import com.google.gwt.user.client.ui.Composite;
 31  
 import com.google.gwt.user.client.ui.SimplePanel;
 32  
 import com.google.gwt.user.client.ui.Widget;
 33  
 
 34  0
 public class LinkPanel extends Composite{
 35  
 
 36  0
         private Map<Enum<?>, PanelInfo> panels = new HashMap<Enum<?>, PanelInfo>();
 37  0
         private SimplePanel container = new SimplePanel();
 38  
 
 39  
         private class PanelInfo extends Composite{
 40  0
                 private VerticalFlowPanel layout = new VerticalFlowPanel();
 41  0
                 private HorizontalBlockFlowPanel linkPanel = new HorizontalBlockFlowPanel();
 42  
                 private Enum<?> key;
 43  
                 private Widget content;
 44  0
                 private List<NavLink> links = new ArrayList<NavLink>();
 45  0
                 private class NavLink{
 46  
                         protected String linkName;
 47  
                         protected Enum<?> linkToKey;
 48  
                 }
 49  
 
 50  0
                 public PanelInfo(Enum<?> key, Widget content){
 51  0
                         this.key = key;
 52  0
                         this.content = content;
 53  0
                         layout.add(content);
 54  0
                         layout.add(linkPanel);
 55  0
                         this.initWidget(layout);
 56  0
                 }
 57  
 
 58  
                 public KSButton addLink(String linkText, final Enum<?> linkedPanelKey){
 59  0
                         NavLink link = new NavLink();
 60  0
                         link.linkName = linkText;
 61  0
                         link.linkToKey = linkedPanelKey;
 62  0
                         links.add(link);
 63  
                         //KSLabel linkWidget = new KSLabel(linkText);
 64  0
                         KSButton linkWidget = new KSButton(linkText, ButtonStyle.DEFAULT_ANCHOR);
 65  0
                         linkWidget.addClickHandler(new ClickHandler(){
 66  
 
 67  
                                 @Override
 68  
                                 public void onClick(ClickEvent event) {
 69  0
                                         Widget newPanel = panels.get(linkedPanelKey);
 70  0
                                         container.setWidget(newPanel);
 71  0
                                 }
 72  
                         });
 73  
 
 74  0
                         linkPanel.add(linkWidget);
 75  0
                         return linkWidget;
 76  
                 }
 77  
         }
 78  
 
 79  0
         public LinkPanel(Enum<?> defaultPanelKey, Widget content){
 80  0
                 PanelInfo info = new PanelInfo(defaultPanelKey, content);
 81  0
                 panels.put(defaultPanelKey, info);
 82  0
                 container.setWidget(info);
 83  0
                 this.initWidget(container);
 84  0
         }
 85  
 
 86  
         public void addPanel(Enum<?> panelKey, Widget content){
 87  0
                 PanelInfo info = new PanelInfo(panelKey, content);
 88  0
                 panels.put(panelKey, info);
 89  0
         }
 90  
 
 91  
         public KSButton addLinkToPanel(Enum<?> panelKey, String linkText, Enum<?> linkedPanelKey){
 92  0
                 PanelInfo info = panels.get(panelKey);
 93  0
                 return info.addLink(linkText, linkedPanelKey);
 94  
         }
 95  
 }