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 | 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 | |
|
36 | 0 | layout.setStyleName("ks-page-sub-navigation"); |
37 | 0 | container.add(layout); |
38 | 0 | layout.add(new HTMLPanel("<div class=\"clear\"> </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 | |
|
67 | |
|
68 | |
|
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\"> </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 | |
} |