001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://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: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://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.ui.favorites; 029 030import org.opencms.file.CmsResource; 031import org.opencms.main.CmsLog; 032import org.opencms.ui.CmsVaadinUtils; 033import org.opencms.ui.components.CmsResourceIcon; 034import org.opencms.ui.components.editablegroup.CmsEditableGroupButtons; 035import org.opencms.ui.components.editablegroup.I_CmsEditableGroupRow; 036 037import org.apache.commons.logging.Log; 038 039import com.vaadin.ui.Component; 040import com.vaadin.ui.CustomLayout; 041import com.vaadin.ui.Label; 042 043/** 044 * Resource info box.<p> 045 */ 046public class CmsFavInfo extends CustomLayout implements I_CmsEditableGroupRow { 047 048 /** Button container location id. */ 049 private static final String BUTTON_CONTAINER = "buttonContainer"; 050 051 /** Logger instance for this class. */ 052 private static final Log LOG = CmsLog.getLog(CmsFavInfo.class); 053 054 /** The serial version id. */ 055 private static final long serialVersionUID = -1715926038770100307L; 056 057 /** The sub title label. */ 058 private Label m_bottomText = new Label(); 059 060 /** The button label. */ 061 private Label m_buttonLabel = new Label(); 062 063 /** 064 * The buttons for changing the position. 065 */ 066 private CmsEditableGroupButtons m_buttons; 067 068 /** The favorite entry. */ 069 private CmsFavoriteEntry m_entry; 070 071 /** The resource icon. */ 072 private CmsResourceIcon m_icon = new CmsResourceIcon(); 073 074 /** The project label. */ 075 private Label m_projectLabel = new Label(); 076 077 /** The resource. */ 078 private CmsResource m_resource; 079 080 /** The site label. */ 081 private Label m_siteLabel = new Label(); 082 083 /** The title label. */ 084 private Label m_topText = new Label(); 085 086 /** 087 * Constructor.<p> 088 * 089 * @param entry the favorite entry whose data to display 090 */ 091 public CmsFavInfo(CmsFavoriteEntry entry) { 092 093 super(); 094 try { 095 initTemplateContentsFromInputStream(CmsVaadinUtils.readCustomLayout(CmsFavInfo.class, "favinfo.html")); 096 addComponent(m_topText, "topLabel"); 097 addComponent(m_bottomText, "bottomLabel"); 098 addComponent(m_icon, "icon"); 099 addComponent(m_buttonLabel, "buttonContainer"); 100 addComponent(m_projectLabel, "projectLabel"); 101 addComponent(m_siteLabel, "siteLabel"); 102 103 } catch (Exception e) { 104 LOG.error(e.getLocalizedMessage(), e); 105 } 106 m_entry = entry; 107 addStyleName("o-pointer"); 108 } 109 110 /** 111 * Gets the bottom label.<p> 112 * 113 * @return the bottom label 114 */ 115 public Label getBottomLine() { 116 117 return m_bottomText; 118 } 119 120 /** 121 * @see org.opencms.ui.components.editablegroup.I_CmsEditableGroupRow#getButtonBar() 122 */ 123 public CmsEditableGroupButtons getButtonBar() { 124 125 return m_buttons; 126 } 127 128 /** 129 * Gets the button label.<p> 130 * 131 * @return the button label 132 */ 133 public Component getButtonWidget() { 134 135 return getComponent("buttonContainer"); 136 } 137 138 /** 139 * @see org.opencms.ui.components.editablegroup.I_CmsEditableGroupRow#getComponent() 140 */ 141 public Component getComponent() { 142 143 return this; 144 } 145 146 /** 147 * Gets the favorite entry. 148 * 149 * @return the favorite entry 150 */ 151 public CmsFavoriteEntry getEntry() { 152 153 return m_entry; 154 } 155 156 /** 157 * Gets the project label. 158 * 159 * @return the project label 160 */ 161 public Label getProjectLabel() { 162 163 return m_projectLabel; 164 165 } 166 167 /** 168 * Gets the resource. 169 * 170 * @return the resource 171 */ 172 public CmsResource getResource() { 173 174 return m_resource; 175 } 176 177 /** 178 * Gets the resource icon.<p> 179 * 180 * @return the resource icon 181 */ 182 public CmsResourceIcon getResourceIcon() { 183 184 return m_icon; 185 } 186 187 /** 188 * Gets the site label. 189 * 190 * @return the site label 191 */ 192 public Label getSiteLabel() { 193 194 return m_siteLabel; 195 } 196 197 /** 198 * Gets the top label.<p> 199 * 200 * @return the top label 201 */ 202 public Label getTopLine() { 203 204 return m_topText; 205 } 206 207 /** 208 * Sets the buttons. 209 * 210 * @param buttons the buttons 211 */ 212 public void setButtons(CmsEditableGroupButtons buttons) { 213 214 m_buttons = buttons; 215 setButtonWidget(m_buttons); 216 } 217 218 /** 219 * Replaces the button component.<p> 220 * 221 * @param button the new button component 222 */ 223 public void setButtonWidget(Component button) { 224 225 addComponent(button, BUTTON_CONTAINER); 226 } 227 228 /** 229 * Sets the bookmark entry. 230 * 231 * @param entry the bookmark entry 232 */ 233 public void setEntry(CmsFavoriteEntry entry) { 234 235 m_entry = entry; 236 } 237 238 /** 239 * Sets the resource 240 * 241 * @param resource the resource to set 242 */ 243 public void setResource(CmsResource resource) { 244 245 m_resource = resource; 246 247 } 248 249}