View Javadoc

1   package org.kuali.student.common.ui.client.widgets;
2   
3   import java.util.List;
4   
5   import com.google.gwt.dom.client.Document;
6   import com.google.gwt.dom.client.UListElement;
7   import com.google.gwt.user.client.Element;
8   import com.google.gwt.user.client.ui.ComplexPanel;
9   import com.google.gwt.user.client.ui.Widget;
10  
11  /**
12   * 
13   * A simple list panel that uses the UL/LI tag HTML structure 
14   * 
15   * @author alubbers
16   *
17   */
18  public class ULPanel extends ComplexPanel {
19  
20      private UListElement list;
21  
22      public ULPanel() {
23          list = Document.get().createULElement();
24          setElement(list);
25      }
26  
27      @Override
28      public void add(Widget child) {
29          addChildElement(child, null);
30      }
31  
32      public void add(Widget child, String liClassName) {
33          addChildElement(child, liClassName);
34      }
35      
36      private void addChildElement(Widget child, String className) {
37          Element li = Document.get().createLIElement().cast();
38          if(className != null) {
39              li.setClassName(className);
40          }
41          list.appendChild(li);
42          super.add(child, li);
43      }
44      
45      public void setULClassName(String className) {
46          list.setClassName(className);
47      }
48  
49      /**
50       * 
51       * This method adds a collection of widgets as LI entries under this UL
52       * 
53       * @param reqCompWidgets
54       * @param className CSS class name for each LI
55       */
56      public void addAll(List<Widget> widgets, String className) {
57          for(Widget w : widgets) {
58              add(w, className);
59          }
60      }
61  }