BrightSide Workbench Full Report + Source Code
zkoss/menu/ElephantMenu.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.zkoss.menu;
19 
20 import java.util.Map;
21 import org.turro.command.Command;
22 import org.turro.elephant.zkoss.Modal;
23 import org.turro.i18n.I_;
24 import org.turro.util.CompareUtil;
25 import org.turro.zul.frame.Framework;
26 import org.zkoss.zul.Menupopup;
27 
32 @Deprecated
33 public abstract class ElephantMenu implements Comparable<ElephantMenu> {
34 
35  public abstract void addMenus(ElephantMenuBar bar);
36 
37  public void addToSessionMenu(ElephantMenuBar bar, Menupopup mp) {}
38  public void addToToolsMenu(ElephantMenuBar bar, Menupopup mp) {}
39 
40  @Override
41  public int compareTo(ElephantMenu o) {
42  int result = CompareUtil.compare(getClass().getName(), o.getClass().getName());
43  return result;
44  }
45 
46  public static void showEntity(Object id, String attribute, String label, String source) {
47  showEntity(id, attribute, label, source, null);
48  }
49 
50  public static void showEntity(Object id, String attribute, String label, String source, Map<String, Object> dynProps) {
51  Framework frame = Framework.getCurrent();
52  if((id instanceof Long && ((Long)id) < 1) || id == null) {
53  frame.getDesktop().removeAttribute(attribute);
54  } else {
55  frame.getDesktop().setAttribute(attribute, id);
56  }
57  if(label.startsWith("@")) {
58  frame.addContent(label.substring(1), source, dynProps);
59  } else {
60  frame.addContent(I_.get(label) + " #" + (id == null ? "0" : id.toString()), source, dynProps);
61  }
62  frame.invalidateSelected();
63  }
64 
65  public static void showZulFile(String label, String source) {
66  showZulFile(label, source, null);
67  }
68 
69  public static void showZulFile(String label, String source, Map<String, Object> dynProps) {
70  Framework frame = Framework.getCurrent();
71  if(label.startsWith("@")) {
72  frame.addContent(label.substring(1), source, dynProps);
73  } else {
74  frame.addContent(I_.get(label), source, dynProps);
75  }
76  }
77 
78  public static void showModalZulFile(String label, String source, Command command) {
79  showModalZulFile(label, source, null, null);
80  }
81 
82  public static void showModalZulFile(String label, String source, Map args, Command command) {
83  Framework frame = Framework.getCurrent();
84  if(label.startsWith("@")) {
85  frame.showModal(label.substring(1), source, args, command);
86  } else {
87  frame.showModal(I_.get(label), source, args, command);
88  }
89  }
90 
91  public static void showPopupZulFile(String label, String source) {
92  showPopupZulFile(label, source, null);
93  }
94 
95  public static void showPopupZulFile(String label, String source, Map args) {
96  Framework frame = Framework.getCurrent();
97  if(label.startsWith("@")) {
98  frame.showPopup(label.substring(1), source, args);
99  } else {
100  frame.showPopup(I_.get(label), source, args);
101  }
102  }
103 
104  public static void showEntityModal(Object id, String attribute, String source, Command command) {
105  Framework frame = Framework.getCurrent();
106  if((id instanceof Long && ((Long)id) < 1) || id == null) {
107  frame.getDesktop().removeAttribute(attribute);
108  } else {
109  frame.getDesktop().setAttribute(attribute, id);
110  }
111  Modal.doModal(source, command);
112  }
113 
114 }
static int doModal(String file)
Definition: Modal.java:38
static String get(String msg)
Definition: I_.java:41
static void showEntityModal(Object id, String attribute, String source, Command command)
void addToSessionMenu(ElephantMenuBar bar, Menupopup mp)
static void showZulFile(String label, String source)
abstract void addMenus(ElephantMenuBar bar)
static void showZulFile(String label, String source, Map< String, Object > dynProps)
static void showEntity(Object id, String attribute, String label, String source)
static void showModalZulFile(String label, String source, Map args, Command command)
static void showModalZulFile(String label, String source, Command command)
static void showPopupZulFile(String label, String source)
static void showEntity(Object id, String attribute, String label, String source, Map< String, Object > dynProps)
static void showPopupZulFile(String label, String source, Map args)
void addToToolsMenu(ElephantMenuBar bar, Menupopup mp)
void addContent(String label, String src)
Definition: Framework.java:69
void showPopup(String label, String src, Map arg)
Definition: Framework.java:121
static Framework getCurrent()
Definition: Framework.java:204
void showModal(String label, String src, Map arg, Command command)
Definition: Framework.java:111
static void setAttribute(Object object, String key, Object value)
Definition: Framework.java:217