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.components; 029 030import org.opencms.report.A_CmsReportThread; 031import org.opencms.ui.CmsVaadinUtils; 032import org.opencms.ui.apps.A_CmsAttributeAwareApp; 033import org.opencms.ui.report.CmsReportWidget; 034 035import java.util.Collections; 036 037import com.vaadin.ui.Button; 038import com.vaadin.ui.Button.ClickEvent; 039import com.vaadin.ui.Button.ClickListener; 040import com.vaadin.ui.Panel; 041import com.vaadin.v7.ui.VerticalLayout; 042 043/** 044 * Page to display a report.<p> 045 */ 046public class CmsBasicReportPage extends VerticalLayout { 047 048 /** Serial version id. */ 049 private static final long serialVersionUID = 1L; 050 051 /** The OK button. */ 052 private Button m_ok; 053 054 /** The panel for the report. */ 055 private Panel m_panel; 056 057 /** The immediate parent layout of the report. */ 058 private VerticalLayout m_reportContainer; 059 060 /** 061 * Creates a new instance.<p> 062 * 063 * @param label the caption for the panel 064 * @param reportThread the report thread whose output should be displayed 065 * @param callback the callback to call when the user clicks OK 066 */ 067 public CmsBasicReportPage(String label, final A_CmsReportThread reportThread, final Runnable callback) { 068 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 069 m_panel.setCaption(label); 070 CmsReportWidget reportWidget = new CmsReportWidget(reportThread); 071 reportWidget.setSizeFull(); 072 m_reportContainer.addComponent(reportWidget); 073 if (reportThread != null) { 074 addAttachListener(new AttachListener() { 075 076 private static final long serialVersionUID = 1L; 077 078 public void attach(AttachEvent event) { 079 080 if (reportThread.getState() == Thread.State.NEW) { 081 reportThread.start(); 082 } 083 } 084 }); 085 } 086 setSpacing(true); 087 m_ok.addClickListener(new ClickListener() { 088 089 private static final long serialVersionUID = 1L; 090 091 public void buttonClick(ClickEvent event) { 092 093 callback.run(); 094 } 095 096 }); 097 setData(Collections.singletonMap(A_CmsAttributeAwareApp.ATTR_MAIN_HEIGHT_FULL, Boolean.TRUE)); 098 } 099 100}