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 setGroup(master.getGroup()); 058 setTitle(master.getTitle()); 059 setResourceType(master.getType()); 060 setBigIconClasses(master.getBigIconClasses()); 061 } 062 063 /** 064 * Adds a new child entry.<p> 065 * 066 * @param child the child entry to add 067 */ 068 public void addChild(CmsGalleryTreeEntry child) { 069 070 if (m_children == null) { 071 m_children = new ArrayList<CmsGalleryTreeEntry>(); 072 } 073 m_children.add(child); 074 child.setParent(this); 075 } 076 077 /** 078 * Returns the list of child entries.<p> 079 * 080 * @return the list of child entries 081 */ 082 public List<CmsGalleryTreeEntry> getChildren() { 083 084 return m_children; 085 } 086 087 /** 088 * Returns the parent entry or <code>null</code> if there is none.<p> 089 * 090 * @return the parent entry 091 */ 092 public CmsGalleryTreeEntry getParent() { 093 094 return m_parent; 095 } 096 097 /** 098 * Sets the child entry list.<p> 099 * 100 * @param children the list of child entries 101 */ 102 public void setChildren(List<CmsGalleryTreeEntry> children) { 103 104 m_children = children; 105 for (CmsGalleryTreeEntry child : m_children) { 106 child.setParent(this); 107 } 108 } 109 110 /** 111 * Sets the parent entry.<p> 112 * 113 * @param parent the parent entry 114 */ 115 protected void setParent(CmsGalleryTreeEntry parent) { 116 117 m_parent = parent; 118 } 119}