001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.gwt.shared; 029 030import java.util.HashMap; 031import java.util.List; 032import java.util.Map; 033 034import com.google.gwt.user.client.rpc.IsSerializable; 035 036/** 037 * A context menu entry bean.<p> 038 */ 039public class CmsContextMenuEntryBean implements IsSerializable { 040 041 /** Signals if the menu entry is active. */ 042 private boolean m_active; 043 044 /** The CSS class for the icon. */ 045 private String m_iconClass; 046 047 /** Stores the JSP path for the JSP that is called by the command. */ 048 private String m_jspPath; 049 050 /** Stores the label for the menu entry. */ 051 private String m_label; 052 053 /** The name of the menu entry. */ 054 private String m_name; 055 056 /** The map of parameters for the context menu command. */ 057 private Map<String, String> m_params = new HashMap<String, String>(); 058 059 /** The reason for de-activation of the menu entry. */ 060 private String m_reason; 061 062 /** Signals if the entry is a separator. */ 063 private boolean m_separator; 064 065 /** The items from the sub menu. */ 066 private List<CmsContextMenuEntryBean> m_subMenu; 067 068 /** Signals if the menu entry is visible. */ 069 private boolean m_visible; 070 071 /** 072 * Default Constructor.<p> 073 */ 074 public CmsContextMenuEntryBean() { 075 076 // noop 077 } 078 079 /** 080 * Constructor.<p> 081 * 082 * @param active signals if this menu entry is active 083 * @param visible signals if this menu entry is visible 084 * @param jspPath the JSP path for the command 085 * @param label the label for the menu entry 086 * @param name the name for the menu entry 087 * @param reason the reason why this item is deactivated 088 * @param separator signals if this entry is a separator 089 * @param subMenu contains the sub menu of the entry 090 */ 091 public CmsContextMenuEntryBean( 092 boolean active, 093 boolean visible, 094 String jspPath, 095 String label, 096 String name, 097 String reason, 098 boolean separator, 099 List<CmsContextMenuEntryBean> subMenu) { 100 101 m_active = active; 102 m_visible = visible; 103 m_jspPath = jspPath; 104 m_label = label; 105 m_name = name; 106 m_reason = reason; 107 m_separator = separator; 108 m_subMenu = subMenu; 109 } 110 111 /** 112 * Gets the CSS class used to display an item.<p> 113 * 114 * @return the CSS class for the icon 115 */ 116 public String getIconClass() { 117 118 return m_iconClass; 119 } 120 121 /** 122 * Returns the jsp path of the menu entry.<p> 123 * 124 * @return the jsp path 125 */ 126 public String getJspPath() { 127 128 return m_jspPath; 129 } 130 131 /** 132 * Returns the label of the menu entry.<p> 133 * 134 * @return the label 135 */ 136 public String getLabel() { 137 138 return m_label; 139 } 140 141 /** 142 * Returns the name of the entry.<p> 143 * 144 * @return the name of the entry 145 */ 146 public String getName() { 147 148 return m_name; 149 } 150 151 /** 152 * Gets the parameters for the context menu command.<p> 153 * 154 * @return the parameters 155 */ 156 public Map<String, String> getParams() { 157 158 return m_params; 159 } 160 161 /** 162 * Returns the reason for de-activation of the menu entry.<p> 163 * 164 * @return the reason 165 */ 166 public String getReason() { 167 168 return m_reason; 169 } 170 171 /** 172 * Returns the sub menu entries.<p> 173 * 174 * @return the entries of the sub menu 175 */ 176 public List<CmsContextMenuEntryBean> getSubMenu() { 177 178 return m_subMenu; 179 } 180 181 /** 182 * Returns <code>true</code> if this menu entry has a sub menu <code>false</code> otherwise.<p> 183 * 184 * @return <code>true</code> if this menu entry has a sub menu <code>false</code> otherwise 185 */ 186 public boolean hasSubMenu() { 187 188 return (m_subMenu != null) && !m_subMenu.isEmpty(); 189 } 190 191 /** 192 * Returns <code>true</code> if this menu entry is active, <code>false</code> otherwise.<p> 193 * 194 * @return <code>true</code> if this menu entry is active, <code>false</code> otherwise 195 */ 196 public boolean isActive() { 197 198 return m_active; 199 } 200 201 /** 202 * Returns <code>true</code> if this menu entry is a separator, <code>false</code> otherwise.<p> 203 * 204 * @return <code>true</code> if this menu entry is a separator, <code>false</code> otherwise 205 */ 206 public boolean isSeparator() { 207 208 return m_separator; 209 } 210 211 /** 212 * Returns <code>true</code> if this menu entry is visible, <code>false</code> otherwise.<p> 213 * 214 * @return <code>true</code> if this menu entry is visible, <code>false</code> otherwise 215 */ 216 public boolean isVisible() { 217 218 return m_visible; 219 } 220 221 /** 222 * Sets the active.<p> 223 * 224 * @param active the active to set 225 */ 226 public void setActive(boolean active) { 227 228 m_active = active; 229 } 230 231 /** 232 * Sets CSS class to display an icon.<p> 233 * 234 * @param iconClass the CSS class for the icon 235 */ 236 public void setIconClass(String iconClass) { 237 238 m_iconClass = iconClass; 239 } 240 241 /** 242 * Sets the jspPath.<p> 243 * 244 * @param jspPath the jspPath to set 245 */ 246 public void setJspPath(String jspPath) { 247 248 m_jspPath = jspPath; 249 } 250 251 /** 252 * Sets the label.<p> 253 * 254 * @param label the label to set 255 */ 256 public void setLabel(String label) { 257 258 m_label = label; 259 } 260 261 /** 262 * Sets the name of the entry.<p> 263 * 264 * @param name the name to set 265 */ 266 public void setName(String name) { 267 268 m_name = name; 269 } 270 271 /** 272 * Sets the parameters for the context menu command.<p> 273 * 274 * @param params the parameters for the context menu command 275 */ 276 public void setParams(Map<String, String> params) { 277 278 if (params != null) { 279 m_params = params; 280 } 281 } 282 283 /** 284 * Sets the reason.<p> 285 * 286 * @param reason the reason to set 287 */ 288 public void setReason(String reason) { 289 290 m_reason = reason; 291 } 292 293 /** 294 * Sets the separator.<p> 295 * 296 * @param separator the separator to set 297 */ 298 public void setSeparator(boolean separator) { 299 300 m_separator = separator; 301 } 302 303 /** 304 * Sets the subMenu.<p> 305 * 306 * @param subMenu the subMenu to set 307 */ 308 public void setSubMenu(List<CmsContextMenuEntryBean> subMenu) { 309 310 m_subMenu = subMenu; 311 } 312 313 /** 314 * Sets the visible flag.<p> 315 * 316 * @param visible the enabled to set 317 */ 318 public void setVisible(boolean visible) { 319 320 m_visible = visible; 321 } 322}