19 package org.turro.menu;
21 import java.util.Collection;
22 import org.turro.about.AboutTurro;
23 import org.turro.action.ExternalMenus;
24 import org.turro.auth.Authentication;
25 import org.turro.command.Command;
26 import org.turro.elephant.zkoss.Modal;
27 import org.turro.security.Permission;
28 import org.turro.zul.frame.Framework;
29 import org.turro.zul.portal.PortalWindows;
30 import org.zkoss.zk.ui.Executions;
31 import org.zkoss.zk.ui.event.Event;
32 import org.zkoss.zk.ui.event.EventListener;
33 import org.zkoss.zk.ui.util.Clients;
34 import org.zkoss.zul.Menubar;
46 initComponents(toolbar);
51 return addMenu(label,
null,
null);
55 return addMenu(label, src,
null);
59 return addMenu(label,
null, permission);
65 if(permission !=
null) m.setVisible(permission.
check());
74 externals.forEach((esm) -> {
80 private void addMenus() {
86 .
addMenuitem(
"Calendar",
"calendar",
"/calendar/calendar.zul",
true)
89 .
addMenuitem(
"Profile",
"contact", (EventListener) (Event event) -> {
94 .
addMenuitem(
"Web home page",
"home", (EventListener) (Event event) -> {
95 Clients.evalJavaScript(
"exitWanted=true;");
96 Executions.sendRedirect(
"/");
98 .addMenuitem(
"User home page",
"user-home", (EventListener) (Event event) -> {
99 Clients.evalJavaScript(
"exitWanted=true;");
100 Executions.sendRedirect(
"/user");
102 .
addMenu(
"Dashboards", Permission.from(() -> {
103 return !Framework.getCurrent().getPortalWindows().isEmpty();
106 .addCollecction(portalWindows.keySet(), (esm, key) -> {
107 esm.addMenuitem(portalWindows.get(key).getLabel(), (EventListener) (Event event) -> {
108 Framework.getCurrent().addContent(portalWindows.get(key));
112 .
addMenuitem(
"Logout",
"exit",
new EventListener() {
114 public void onEvent(Event event)
throws Exception {
115 Clients.evalJavaScript(
"exitWanted=true;");
116 Authentication.doLogout(
"/");
119 .addToolbarSeparator(
true)
127 .
addMenuitem(
"Reload content",
"reload", (EventListener) (Event event) -> {
128 Framework.getCurrent().invalidateSelected();
130 .addMenuitem(
"Password generator",
"locked", (EventListener) (Event event) -> {
131 Modal.doModal(ElephantMenu.makeInclude(
"/www/passgen.zul"), (Command)
null);
135 .
addMenuitem(
"About",
"brightside", (EventListener) (Event event) -> {
136 new AboutTurro().show();
140 private void initComponents(ElephantToolbar toolbar) {
142 this.toolbar = toolbar;
static int doModal(String file)
static Framework getCurrent()
PortalWindows getPortalWindows()