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.galleries.shared; 029 030import java.util.ArrayList; 031import java.util.List; 032 033/** 034 * Gallery tree entry class. To organize gallery folders as a tree.<p> 035 * 036 * @since 8.0.1 037 */ 038public class CmsGalleryTreeEntry extends CmsGalleryFolderBean { 039 040 /** List of child entries. */ 041 private List<CmsGalleryTreeEntry> m_children; 042 043 /** The parent entry. */ 044 private CmsGalleryTreeEntry m_parent; 045 046 /** 047 * Constructor.<p> 048 * Copy the fields of the given master.<p> 049 * 050 * @param master master to copy 051 */ 052 public CmsGalleryTreeEntry(CmsGalleryFolderBean master) { 053 054 setContentTypes(master.getContentTypes()); 055 setEditable(master.isEditable()); 056 setPath(master.getPath()); 057 setTitle(master.getTitle()); 058 setResourceType(master.getType()); 059 setBigIconClasses(master.getBigIconClasses()); 060 } 061 062 /** 063 * Adds a new child entry.<p> 064 * 065 * @param child the child entry to add 066 */ 067 public void addChild(CmsGalleryTreeEntry child) { 068 069 if (m_children == null) { 070 m_children = new ArrayList<CmsGalleryTreeEntry>(); 071 } 072 m_children.add(child); 073 child.setParent(this); 074 } 075 076 /** 077 * Returns the list of child entries.<p> 078 * 079 * @return the list of child entries 080 */ 081 public List<CmsGalleryTreeEntry> getChildren() { 082 083 return m_children; 084 } 085 086 /** 087 * Returns the parent entry or <code>null</code> if there is none.<p> 088 * 089 * @return the parent entry 090 */ 091 public CmsGalleryTreeEntry getParent() { 092 093 return m_parent; 094 } 095 096 /** 097 * Sets the child entry list.<p> 098 * 099 * @param children the list of child entries 100 */ 101 public void setChildren(List<CmsGalleryTreeEntry> children) { 102 103 m_children = children; 104 for (CmsGalleryTreeEntry child : m_children) { 105 child.setParent(this); 106 } 107 } 108 109 /** 110 * Sets the parent entry.<p> 111 * 112 * @param parent the parent entry 113 */ 114 protected void setParent(CmsGalleryTreeEntry parent) { 115 116 m_parent = parent; 117 } 118}