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