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.logfile; 029 030import org.opencms.ui.CmsVaadinUtils; 031import org.opencms.ui.components.CmsBasicDialog; 032 033import java.nio.charset.Charset; 034import java.util.Iterator; 035import java.util.SortedMap; 036 037import javax.servlet.http.HttpSession; 038 039import com.vaadin.ui.Button; 040import com.vaadin.ui.Button.ClickEvent; 041import com.vaadin.ui.Button.ClickListener; 042import com.vaadin.v7.ui.ComboBox; 043import com.vaadin.v7.ui.TextField; 044import com.vaadin.ui.Window; 045 046/** 047 * Class for the log file view settings dialog.<p> 048 */ 049public class CmsLogFileViewSettings extends CmsBasicDialog { 050 051 /**vaadin serial id.*/ 052 private static final long serialVersionUID = 3564444938636162445L; 053 054 /**Vaadin component. */ 055 ComboBox m_charset; 056 057 /**Vaadin component. */ 058 TextField m_size; 059 060 /**Vaadin component.*/ 061 private Button m_cancel; 062 063 /**Vaadin component.*/ 064 private Button m_ok; 065 066 /** 067 * public constructor.<p> 068 * 069 * @param window where the dialog is shown in 070 */ 071 public CmsLogFileViewSettings(final Window window) { 072 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 073 074 m_size.setValue( 075 (String)CmsVaadinUtils.getRequest().getSession().getAttribute(CmsLogFileView.ATTR_FILE_VIEW_SIZE)); 076 077 SortedMap<String, Charset> csMap = Charset.availableCharsets(); 078 Charset cs; 079 Iterator<Charset> it = csMap.values().iterator(); 080 while (it.hasNext()) { 081 cs = it.next(); 082 m_charset.addItem(cs); 083 } 084 085 m_charset.select(CmsVaadinUtils.getRequest().getSession().getAttribute(CmsLogFileView.ATTR_FILE_VIEW_CHARSET)); 086 087 m_cancel.addClickListener(new ClickListener() { 088 089 private static final long serialVersionUID = -3277236106838992809L; 090 091 public void buttonClick(ClickEvent event) { 092 093 window.close(); 094 095 } 096 }); 097 098 m_ok.addClickListener(new ClickListener() { 099 100 private static final long serialVersionUID = 3179892867228610166L; 101 102 public void buttonClick(ClickEvent event) { 103 104 HttpSession session = CmsVaadinUtils.getRequest().getSession(); 105 session.setAttribute(CmsLogFileView.ATTR_FILE_VIEW_CHARSET, m_charset.getValue()); 106 session.setAttribute(CmsLogFileView.ATTR_FILE_VIEW_SIZE, m_size.getValue()); 107 window.close(); 108 109 } 110 }); 111 } 112}