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.ade.containerpage.shared;
029
030import org.opencms.util.CmsUUID;
031
032import com.google.gwt.user.client.rpc.IsSerializable;
033
034/**
035 * Element view info.<p>
036 */
037public class CmsElementViewInfo implements IsSerializable {
038
039    /** The element view id. */
040    private CmsUUID m_elementViewId;
041
042    /** The parent view (may be null). */
043    private CmsElementViewInfo m_parent;
044
045    /** The title. */
046    private String m_title;
047
048    /**
049     * Constructor.<p>
050     *
051     * @param title the title
052     * @param elementViewId the element view id
053     */
054    public CmsElementViewInfo(String title, CmsUUID elementViewId) {
055
056        m_title = title;
057        m_elementViewId = elementViewId;
058    }
059
060    /**
061     * Constructor, for serialization only.<p>
062     */
063    protected CmsElementViewInfo() {
064
065    }
066
067    /**
068     * Returns the element view id.<p>
069     *
070     * @return the element view id
071     */
072    public CmsUUID getElementViewId() {
073
074        return m_elementViewId;
075    }
076
077    /**
078     * Gets the id of the root view of this view.<p>
079     *
080     * The root view is either this view itself if it doesn't have a parent view, or the parent view if it does.
081     *
082     * @return the root view
083     */
084    public CmsUUID getRootViewId() {
085
086        if (m_parent != null) {
087            return m_parent.getElementViewId();
088        } else {
089            return getElementViewId();
090        }
091    }
092
093    /**
094     * Returns the title.<p>
095     *
096     * @return the title
097     */
098    public String getTitle() {
099
100        return m_title;
101    }
102
103    /**
104     * Returns true if this is a root view.<p>
105     *
106     * @return true if this is a root view
107     */
108    public boolean isRoot() {
109
110        return m_parent == null;
111    }
112
113    /**
114     * Sets the parent view bean.<p>
115     *
116     * @param parent the parent view bean
117     */
118    public void setParent(CmsElementViewInfo parent) {
119
120        m_parent = parent;
121    }
122
123}