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.dbmanager; 029 030import org.opencms.ui.A_CmsUI; 031import org.opencms.ui.CmsVaadinUtils; 032import org.opencms.ui.FontOpenCms; 033import org.opencms.ui.components.CmsBasicDialog; 034import org.opencms.ui.report.CmsReportWidget; 035 036import com.vaadin.v7.shared.ui.label.ContentMode; 037import com.vaadin.ui.Button; 038import com.vaadin.ui.Button.ClickEvent; 039import com.vaadin.v7.ui.HorizontalLayout; 040import com.vaadin.v7.ui.Label; 041import com.vaadin.v7.ui.VerticalLayout; 042 043/** 044 * Class for the synchronization dialog.<p> 045 */ 046public class CmsDbSynchDialog extends CmsBasicDialog { 047 048 /**vaadin serial id.*/ 049 private static final long serialVersionUID = -1818182416175306822L; 050 051 /**cancel button.*/ 052 Button m_cancelButton; 053 054 /**Runnable for close action.*/ 055 Runnable m_closeRunnable; 056 057 /**Vaadin component.*/ 058 HorizontalLayout m_confirm; 059 060 /**icon. */ 061 Label m_icon; 062 063 /**Ok button. */ 064 Button m_okButton; 065 066 /**Vaadin component. */ 067 VerticalLayout m_report; 068 069 /** 070 * public constructor.<p> 071 * 072 * @param closeRunnable gets called on cancel 073 */ 074 public CmsDbSynchDialog(Runnable closeRunnable) { 075 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 076 077 m_report.setVisible(false); 078 m_closeRunnable = closeRunnable; 079 080 //Setup icon 081 m_icon.setContentMode(ContentMode.HTML); 082 m_icon.setValue(FontOpenCms.WARNING.getHtml()); 083 084 m_okButton.addClickListener(new Button.ClickListener() { 085 086 private static final long serialVersionUID = 7329358907650680436L; 087 088 public void buttonClick(ClickEvent event) { 089 090 showReport(); 091 092 } 093 }); 094 095 m_cancelButton.addClickListener(new Button.ClickListener() { 096 097 private static final long serialVersionUID = 4143312166220501488L; 098 099 public void buttonClick(ClickEvent event) { 100 101 m_closeRunnable.run(); 102 103 } 104 }); 105 } 106 107 /** 108 * shows the synchronization report.<p> 109 */ 110 protected void showReport() { 111 112 m_confirm.setVisible(false); 113 m_report.setVisible(true); 114 CmsSynchronizeThread thread = new CmsSynchronizeThread(A_CmsUI.getCmsObject()); 115 thread.start(); 116 CmsReportWidget widget = new CmsReportWidget(thread); 117 widget.setHeight("500px"); 118 widget.setWidth("100%"); 119 m_report.addComponent(widget); 120 m_okButton.setEnabled(false); 121 } 122}