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.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 069 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 070 m_panel.setCaption(label); 071 CmsReportWidget reportWidget = new CmsReportWidget(reportThread); 072 reportWidget.setSizeFull(); 073 m_reportContainer.addComponent(reportWidget); 074 if (reportThread != null) { 075 addAttachListener(new AttachListener() { 076 077 private static final long serialVersionUID = 1L; 078 079 public void attach(AttachEvent event) { 080 081 if (reportThread.getState() == Thread.State.NEW) { 082 reportThread.start(); 083 } 084 } 085 }); 086 } 087 setSpacing(true); 088 m_ok.addClickListener(new ClickListener() { 089 090 private static final long serialVersionUID = 1L; 091 092 public void buttonClick(ClickEvent event) { 093 094 callback.run(); 095 } 096 097 }); 098 setData(Collections.singletonMap(A_CmsAttributeAwareApp.ATTR_MAIN_HEIGHT_FULL, Boolean.TRUE)); 099 } 100 101}