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.components;
029
030import org.opencms.ui.shared.components.CmsBreadCrumbState;
031
032import java.util.Map;
033import java.util.Map.Entry;
034
035import com.vaadin.shared.communication.SharedState;
036import com.vaadin.ui.AbstractComponent;
037
038/**
039 * The bread crumb component.<p>
040 */
041public class CmsBreadCrumb extends AbstractComponent {
042
043    /** The serial version id. */
044    private static final long serialVersionUID = 5348912019194395575L;
045
046    /**
047     * @see com.vaadin.server.AbstractClientConnector#getStateType()
048     */
049    @Override
050    public Class<? extends SharedState> getStateType() {
051
052        return CmsBreadCrumbState.class;
053    }
054
055    /**
056     * Sets the bread crumb entries.<p>
057     *
058     * @param entries the bread crumb entries
059     */
060    public void setEntries(Map<String, String> entries) {
061
062        String[][] entriesArray = null;
063        if ((entries != null) && !entries.isEmpty()) {
064            entriesArray = new String[entries.size()][];
065            int i = 0;
066            for (Entry<String, String> entry : entries.entrySet()) {
067                entriesArray[i] = new String[] {entry.getKey(), entry.getValue()};
068                i++;
069            }
070        }
071
072        getState().setEntries(entriesArray);
073    }
074
075    /**
076     * @see com.vaadin.ui.AbstractComponent#getState()
077     */
078    @Override
079    protected CmsBreadCrumbState getState() {
080
081        return (CmsBreadCrumbState)super.getState();
082    }
083
084    /**
085     * @see com.vaadin.ui.AbstractComponent#getState(boolean)
086     */
087    @Override
088    protected CmsBreadCrumbState getState(boolean markAsDirty) {
089
090        return (CmsBreadCrumbState)super.getState(markAsDirty);
091    }
092
093}