1
2
3
4
5
6
7
8
9
10
11
12
13
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 public class KSBlockMenuImpl extends Composite{
29 private FlowPanel layout = new FlowPanel();
30 private FlowPanel container = new FlowPanel();
31 private List<KSListMenuImpl> menus = new ArrayList<KSListMenuImpl>();
32 private List<KSMenuItemData> data;
33
34 public KSBlockMenuImpl(){
35
36 layout.setStyleName("ks-page-sub-navigation");
37 container.add(layout);
38 layout.add(new HTMLPanel("<div class=\"clear\"> </div>"));
39 this.initWidget(container);
40 }
41
42 public void addMenu(KSListMenuImpl menu){
43 menu.setStyleName("ks-page-sub-navigation-menu");
44 layout.insert(menu, layout.getWidgetCount() -1);
45 menus.add(menu);
46 menu.addGlobalMenuItemSelectCallback(new Callback<KSMenuItemData>(){
47
48 @Override
49 public void exec(KSMenuItemData result) {
50 for(int i=0; i < KSBlockMenuImpl.this.menus.size(); i++){
51 KSBlockMenuImpl.this.menus.get(i).clearSelected();
52 }
53
54 }
55 });
56
57 }
58
59 public void setMenus(List<KSListMenuImpl> menus){
60 for(KSListMenuImpl menu: menus){
61 this.addMenu(menu);
62 }
63 }
64
65
66
67
68
69
70 public void setTopLevelItems(List<KSMenuItemData> data){
71 this.data = data;
72 refresh();
73 }
74
75 public void refresh(){
76 layout.clear();
77 menus.clear();
78 layout.add(new HTMLPanel("<div class=\"clear\"> </div>"));
79 for(KSMenuItemData item: data){
80 List<KSMenuItemData> list = new ArrayList<KSMenuItemData>();
81 list.add(item);
82 KSListMenuImpl menu = new KSListMenuImpl();
83 menu.setItems(list);
84 this.addMenu(menu);
85 }
86 }
87
88 }