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 org.opencms.gwt.shared.sort.I_CmsHasPath; 031import org.opencms.gwt.shared.sort.I_CmsHasTitle; 032import org.opencms.relations.CmsCategory; 033import org.opencms.util.CmsUUID; 034 035import com.google.gwt.user.client.rpc.IsSerializable; 036 037/** 038 * A specific bean holding all info to be displayed in the categories tab.<p> 039 * 040 * @since 8.0.0 041 */ 042public class CmsCategoryBean implements I_CmsHasTitle, I_CmsHasPath, IsSerializable, I_CmsHasIconClasses { 043 044 /** The big category type icon classes. */ 045 public static final String BIG_ICON_CLASSES = CmsGwtConstants.TYPE_ICON_CLASS + " oc-icon-24-category"; 046 047 /** The small category type icon classes. */ 048 public static final String SMALL_ICON_CLASSES = CmsGwtConstants.TYPE_ICON_CLASS + " oc-icon-16-category"; 049 050 /** The category's base path. */ 051 private String m_basePath; 052 053 /** The category description. */ 054 private String m_description; 055 056 /** The category id. */ 057 private CmsUUID m_id; 058 059 /** The category path. */ 060 private String m_path; 061 062 /** The category's root path. */ 063 private String m_rootPath; 064 065 /** The category's site path. */ 066 private String m_sitePath; 067 068 /** The category title. */ 069 private String m_title; 070 071 /** 072 * Constructor.<p> 073 * 074 * @param category the server-side category 075 */ 076 public CmsCategoryBean(CmsCategory category) { 077 078 this( 079 category.getId(), 080 category.getTitle(), 081 category.getDescription(), 082 category.getPath(), 083 category.getBasePath(), 084 category.getRootPath()); 085 } 086 087 /** 088 * Constructor.<p> 089 * 090 * @param categoryTreeEntry the category tree entry to copy 091 */ 092 public CmsCategoryBean(CmsCategoryTreeEntry categoryTreeEntry) { 093 094 this( 095 categoryTreeEntry.getId(), 096 categoryTreeEntry.getTitle(), 097 categoryTreeEntry.getDescription(), 098 categoryTreeEntry.getPath(), 099 categoryTreeEntry.getBasePath(), 100 categoryTreeEntry.getRootPath()); 101 m_sitePath = categoryTreeEntry.getSitePath(); 102 } 103 104 /** 105 * The constructor.<p> 106 * 107 * @param id the category id 108 * @param title the title to set 109 * @param description the subtitle to set 110 * @param path the category path 111 * @param basePath the category base path 112 * @param rootPath the category root path 113 */ 114 public CmsCategoryBean( 115 CmsUUID id, 116 String title, 117 String description, 118 String path, 119 String basePath, 120 String rootPath) { 121 122 m_id = id; 123 m_title = title; 124 m_description = description; 125 m_path = path; 126 m_basePath = basePath; 127 m_rootPath = rootPath; 128 } 129 130 /** 131 * Constructor for serialization only.<p> 132 */ 133 protected CmsCategoryBean() { 134 135 // noting to do 136 } 137 138 /** 139 * Returns the base path.<p> 140 * 141 * @return the base path 142 */ 143 public String getBasePath() { 144 145 return m_basePath; 146 } 147 148 /** 149 * @see org.opencms.gwt.shared.I_CmsHasIconClasses#getBigIconClasses() 150 */ 151 public String getBigIconClasses() { 152 153 return BIG_ICON_CLASSES; 154 } 155 156 /** 157 * Returns the description.<p> 158 * 159 * @return the description 160 */ 161 public String getDescription() { 162 163 return m_description; 164 } 165 166 /** 167 * Returns the id.<p> 168 * 169 * @return the id 170 */ 171 public CmsUUID getId() { 172 173 return m_id; 174 } 175 176 /** 177 * Returns the category path.<p> 178 * 179 * @return the category path 180 */ 181 public String getPath() { 182 183 return m_path; 184 } 185 186 /** 187 * Returns the root path.<p> 188 * 189 * @return the root path 190 */ 191 public String getRootPath() { 192 193 return m_rootPath; 194 } 195 196 /** 197 * Returns the category site path.<p> 198 * 199 * @return the category site path 200 */ 201 public String getSitePath() { 202 203 return m_sitePath; 204 } 205 206 /** 207 * @see org.opencms.gwt.shared.I_CmsHasIconClasses#getSmallIconClasses() 208 */ 209 public String getSmallIconClasses() { 210 211 return SMALL_ICON_CLASSES; 212 } 213 214 /** 215 * Returns the title.<p> 216 * 217 * @return the title 218 */ 219 public String getTitle() { 220 221 return m_title; 222 } 223 224 /** 225 * Returns if the category matches the given filter.<p> 226 * 227 * @param filter the filter to match 228 * 229 * @return <code>true</code> if the gallery matches the given filter.<p> 230 */ 231 public boolean matchesFilter(String filter) { 232 233 filter = filter.toLowerCase(); 234 return m_title.toLowerCase().contains(filter) || m_path.toLowerCase().contains(filter); 235 } 236 237 /** 238 * Sets the description.<p> 239 * 240 * @param description the description to set 241 */ 242 public void setDescription(String description) { 243 244 m_description = description; 245 } 246 247 /** 248 * Sets the category path.<p> 249 * 250 * @param path the category path to set 251 */ 252 public void setPath(String path) { 253 254 m_path = path; 255 } 256 257 /** 258 * Sets the category site path.<p> 259 * 260 * @param sitePath category site path 261 */ 262 public void setSitePath(String sitePath) { 263 264 m_sitePath = sitePath; 265 } 266 267 /** 268 * Sets the title.<p> 269 * 270 * @param title the title to set 271 */ 272 public void setTitle(String title) { 273 274 m_title = title; 275 } 276}