001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://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: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://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.cacheadmin; 029 030import org.opencms.file.types.CmsResourceTypeImage; 031import org.opencms.main.OpenCms; 032import org.opencms.ui.CmsVaadinUtils; 033import org.opencms.ui.apps.Messages; 034import org.opencms.workplace.explorer.CmsResourceUtil; 035 036import java.util.List; 037 038import com.vaadin.server.Resource; 039import com.vaadin.v7.data.Item; 040import com.vaadin.v7.data.util.IndexedContainer; 041import com.vaadin.v7.ui.Table; 042 043/** 044 * Table showing information about variations of images.<p> 045 */ 046public class CmsImageVariationsTable extends Table { 047 048 /**vaadin serial id.*/ 049 private static final long serialVersionUID = 4050556105747017491L; 050 051 /**The icon property.*/ 052 protected static final String PROP_ICON = "icon"; 053 054 /**The name property. */ 055 protected static final String PROP_NAME = "name"; 056 057 /**The dimension property. */ 058 protected static final String PROP_DIMENSION = "dimension"; 059 060 /**The length property. */ 061 protected static final String PROP_LENGTH = "length"; 062 063 /** The last modification time property. */ 064 protected static final String PROP_LAST_MODIFIED = "lastModified"; 065 066 /**Indexed container.*/ 067 private IndexedContainer m_container; 068 069 /** 070 * public constructor.<p> 071 * @param resource to show variations from 072 */ 073 public CmsImageVariationsTable(String resource) { 074 075 m_container = new IndexedContainer(); 076 077 m_container.addContainerProperty( 078 PROP_ICON, 079 Resource.class, 080 CmsResourceUtil.getBigIconResource( 081 OpenCms.getWorkplaceManager().getExplorerTypeSetting(CmsResourceTypeImage.getStaticTypeName()), 082 null)); 083 m_container.addContainerProperty(PROP_NAME, String.class, ""); 084 m_container.addContainerProperty(PROP_DIMENSION, String.class, ""); 085 m_container.addContainerProperty(PROP_LENGTH, String.class, ""); 086 m_container.addContainerProperty(PROP_LAST_MODIFIED, String.class, ""); 087 088 List<CmsVariationBean> variations = CmsImageCacheTable.HELPER.getVariations(resource); 089 for (CmsVariationBean var : variations) { 090 Item item = m_container.addItem(var); 091 item.getItemProperty(PROP_NAME).setValue(var.getName()); 092 item.getItemProperty(PROP_DIMENSION).setValue(var.getDimensions()); 093 item.getItemProperty(PROP_LENGTH).setValue(var.getLength()); 094 item.getItemProperty(PROP_LAST_MODIFIED).setValue(var.getDateLastModified()); 095 } 096 097 setContainerDataSource(m_container); 098 099 setColumnHeader(null, ""); 100 setColumnHeader(PROP_DIMENSION, CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGECACHE_LIST_COLS_SIZE_0)); 101 setColumnHeader(PROP_NAME, CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGECACHE_LIST_COLS_RESOURCE_0)); 102 setColumnHeader(PROP_LENGTH, CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGECACHE_LIST_COLS_LENGTH_0)); 103 setColumnHeader( 104 PROP_LAST_MODIFIED, 105 CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGECACHE_LIST_COLS_LAST_MODIFIED_0)); 106 107 setItemIconPropertyId(PROP_ICON); 108 setRowHeaderMode(RowHeaderMode.ICON_ONLY); 109 setWidth("100%"); 110 setHeight("500px"); 111 setVisibleColumns(PROP_NAME, PROP_DIMENSION, PROP_LENGTH, PROP_LAST_MODIFIED); 112 113 } 114}