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.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        // TODO Auto-generated method stub
161        return null;
162
163     */
164    public Label getProjectLabel() {
165
166        return m_projectLabel;
167
168    }
169
170    /**
171     * Gets the resource.
172     *
173     * @return the resource
174     */
175    public CmsResource getResource() {
176
177        return m_resource;
178    }
179
180    /**
181     * Gets the resource icon.<p>
182     *
183     * @return the resource icon
184     */
185    public CmsResourceIcon getResourceIcon() {
186
187        return m_icon;
188    }
189
190    /**
191     * Gets the site label.
192     *
193     * @return the site label
194     */
195    public Label getSiteLabel() {
196
197        return m_siteLabel;
198    }
199
200    /**
201     * Gets the top label.<p>
202     *
203     * @return the top label
204     */
205    public Label getTopLine() {
206
207        return m_topText;
208    }
209
210    /**
211     * Sets the buttons.
212     *
213     * @param buttons the buttons
214     */
215    public void setButtons(CmsEditableGroupButtons buttons) {
216
217        m_buttons = buttons;
218        setButtonWidget(m_buttons);
219    }
220
221    /**
222     * Replaces the button component.<p>
223     *
224     * @param button the new button component
225     */
226    public void setButtonWidget(Component button) {
227
228        addComponent(button, BUTTON_CONTAINER);
229    }
230
231    /**
232     * Sets the bookmark entry.
233     *
234     * @param entry the bookmark entry
235     */
236    public void setEntry(CmsFavoriteEntry entry) {
237
238        m_entry = entry;
239    }
240
241    /**
242     * Sets the resource
243     *
244     * @param resource the resource to set
245     */
246    public void setResource(CmsResource resource) {
247
248        m_resource = resource;
249
250    }
251
252}