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.linkvalidation; 029 030import org.opencms.file.CmsResource; 031import org.opencms.ui.CmsCssIcon; 032import org.opencms.ui.CmsVaadinUtils; 033import org.opencms.ui.components.CmsBasicDialog; 034import org.opencms.ui.components.CmsResourceInfo; 035 036import java.util.ArrayList; 037import java.util.Collections; 038import java.util.List; 039 040import com.vaadin.ui.Button; 041import com.vaadin.ui.Button.ClickEvent; 042import com.vaadin.ui.Button.ClickListener; 043 044/** 045 * Dialog to show list of resources.<p> 046 */ 047public class CmsResourceListDialog extends CmsBasicDialog { 048 049 /**vaadin serial id.*/ 050 private static final long serialVersionUID = 4057378669920436467L; 051 052 /**The close button. */ 053 private Button m_cancel; 054 055 /** 056 * Public constructor.<p> 057 * 058 * @param resources List of resources 059 */ 060 public CmsResourceListDialog(List<CmsResource> resources) { 061 062 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 063 if (resources.size() < 50) { 064 displayResourceInfo(resources, null); 065 setContentVisibility(false); 066 } 067 m_cancel.addClickListener(new ClickListener() { 068 069 private static final long serialVersionUID = 8446069481164202478L; 070 071 public void buttonClick(ClickEvent event) { 072 073 CmsVaadinUtils.getWindow(CmsResourceListDialog.this).close(); 074 075 } 076 077 }); 078 } 079 080 public static CmsResourceListDialog forNonExistingPaths(List<String> paths) { 081 082 CmsResourceListDialog res = new CmsResourceListDialog(Collections.EMPTY_LIST); 083 List<CmsResourceInfo> resourceInfos = new ArrayList<CmsResourceInfo>(); 084 for (String path : paths) { 085 resourceInfos.add(new CmsResourceInfo(path, path, new CmsCssIcon("oc-icon-24-default"))); 086 } 087 res.displayResourceInfoDirectly(resourceInfos); 088 return res; 089 } 090}