18 package org.turro.zul.frame;
21 import java.util.Stack;
22 import org.turro.zul.portal.PortalContainer;
23 import org.zkoss.zk.ui.event.Event;
24 import org.zkoss.zk.ui.event.EventListener;
25 import org.zkoss.zk.ui.event.Events;
26 import org.zkoss.zul.*;
35 private Tabpanels panels;
36 private Stack<Tabpanel> selections =
new Stack<>();
39 setSclass(
"bbcontbox");
48 public void addContent(String label, String src, Map<String, Object> dynProps) {
49 Tab tab =
new Tab(label);
50 tab.setClosable(
true);
51 tabs.appendChild(tab);
52 Tabpanel panel =
new Tabpanel();
53 panel.setSclass(
"bbcontpanel");
54 panels.appendChild(panel);
55 Include inc =
new Include(src);
57 inc.setHeight(
"100%");
59 if(dynProps !=
null) {
60 for(Map.Entry<String, Object> entry : dynProps.entrySet()) {
61 if(entry.getValue() !=
null) {
62 inc.setDynamicProperty(entry.getKey(), entry.getValue());
66 panel.appendChild(inc);
67 setSelectedPanel(panel);
68 selections.push(panel);
69 tab.addEventListener(Events.ON_CLOSE,
new EventListener() {
71 public void onEvent(Event event)
throws Exception {
72 Tabpanel panel = ((Tab) event.getTarget()).getLinkedPanel();
73 selections.remove(panel);
80 Tab tab =
new Tab(container.
getLabel());
81 tab.setClosable(
true);
82 tabs.appendChild(tab);
83 Tabpanel panel =
new Tabpanel();
84 panel.setSclass(
"bbcontpanel");
85 panels.appendChild(panel);
88 panel.appendChild(
new Toolbar());
89 panel.appendChild(container);
90 setSelectedPanel(panel);
91 selections.push(panel);
93 tab.addEventListener(Events.ON_CLOSE,
new EventListener() {
95 public void onEvent(Event event)
throws Exception {
96 Tabpanel panel = ((Tab) event.getTarget()).getLinkedPanel();
97 selections.remove(panel);
104 Tabpanel panel = getSelectedPanel();
106 panel.getFirstChild().invalidate();
111 Tabpanel panel = getSelectedPanel();
113 Tab tab = panel.getLinkedTab();
114 tabs.removeChild(tab);
115 panels.removeChild(panel);
116 selections.remove(panel);
118 selectDefaultPanel();
122 Tabpanel panel = getSelectedPanel();
124 Tab tab = panel.getLinkedTab();
130 Tabpanel panel = getSelectedPanel();
132 Tab tab = panel.getLinkedTab();
133 tab.setTooltiptext(text);
137 private void createContainers() {
139 tabs.setSclass(
"bbconttabs");
141 panels =
new Tabpanels();
142 panels.setSclass(
"bbcontpanels");
144 addEventListener(Events.ON_SELECT,
new EventListener() {
146 public void onEvent(Event event)
throws Exception {
147 Tabpanel panel = ((Tab) event.getTarget()).getLinkedPanel();
148 selections.remove(panel);
149 selections.push(panel);
154 private void selectDefaultPanel() {
155 if(!selections.empty()) {
156 Tabpanel tp = selections.pop();
157 if(tp !=
null) setSelectedPanel(tp);
158 Tabpanel tps = getSelectedPanel();
160 selections.remove(tps);
161 selections.push(tps);
void setSelectedTooltiptext(String text)
void addContent(String label, String src, Map< String, Object > dynProps)
void addContent(String label, String src)
void invalidateSelected()
void addContent(PortalContainer container)
void setSelectedLabel(String text)