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.apps.user; 029 030import org.opencms.file.CmsGroup; 031import org.opencms.file.CmsObject; 032import org.opencms.file.CmsUser; 033import org.opencms.ui.apps.user.CmsGroupTable.TableProperty; 034 035import java.util.ArrayList; 036import java.util.List; 037 038import com.vaadin.v7.data.Item; 039import com.vaadin.v7.data.util.IndexedContainer; 040import com.vaadin.v7.ui.Table; 041 042/** 043 * Table showing all Groups of a user.<p> 044 */ 045public class CmsGroupsOfUserTable extends Table { 046 047 /** Serial version id. */ 048 private static final long serialVersionUID = 1L; 049 050 /** The app instance. */ 051 private CmsAccountsApp m_app; 052 053 /**Data container. */ 054 private IndexedContainer m_container; 055 056 /** 057 * Init method.<p> 058 * 059 * @param app the app instance 060 * @param cms CmsObject 061 * @param user CmsUser 062 * @param groups list of groups 063 */ 064 public void init(CmsAccountsApp app, CmsObject cms, CmsUser user, List<CmsGroup> groups) { 065 066 m_app = app; 067 if (m_container == null) { 068 m_container = new IndexedContainer(); 069 070 for (TableProperty prop : TableProperty.values()) { 071 m_container.addContainerProperty(prop, prop.getType(), prop.getDefault()); 072 setColumnHeader(prop, prop.getName()); 073 } 074 m_app.addGroupContainerProperties(m_container); 075 setContainerDataSource(m_container); 076 setItemIconPropertyId(TableProperty.Icon); 077 setRowHeaderMode(RowHeaderMode.ICON_ONLY); 078 079 setColumnWidth(null, 40); 080 setSelectable(false); 081 setMultiSelect(false); 082 setVisibleColumns(TableProperty.Name, TableProperty.OU); 083 084 } 085 m_container.removeAllItems(); 086 087 for (CmsGroup group : groups) { 088 Item item = m_container.addItem(group); 089 m_app.fillGroupItem(item, group, new ArrayList<CmsGroup>()); 090 } 091 092 } 093 094}