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.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 com.vaadin.ui.Button; 038import com.vaadin.ui.Button.ClickEvent; 039import com.vaadin.ui.Button.ClickListener; 040import com.vaadin.ui.Window; 041import com.vaadin.v7.ui.ComboBox; 042import com.vaadin.v7.ui.TextField; 043 044import jakarta.servlet.http.HttpSession; 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 073 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 074 075 m_size.setValue( 076 (String)CmsVaadinUtils.getRequest().getSession().getAttribute(CmsLogFileView.ATTR_FILE_VIEW_SIZE)); 077 078 SortedMap<String, Charset> csMap = Charset.availableCharsets(); 079 Charset cs; 080 Iterator<Charset> it = csMap.values().iterator(); 081 while (it.hasNext()) { 082 cs = it.next(); 083 m_charset.addItem(cs); 084 } 085 086 m_charset.select(CmsVaadinUtils.getRequest().getSession().getAttribute(CmsLogFileView.ATTR_FILE_VIEW_CHARSET)); 087 088 m_cancel.addClickListener(new ClickListener() { 089 090 private static final long serialVersionUID = -3277236106838992809L; 091 092 public void buttonClick(ClickEvent event) { 093 094 window.close(); 095 096 } 097 }); 098 099 m_ok.addClickListener(new ClickListener() { 100 101 private static final long serialVersionUID = 3179892867228610166L; 102 103 public void buttonClick(ClickEvent event) { 104 105 HttpSession session = CmsVaadinUtils.getRequest().getSession(); 106 session.setAttribute(CmsLogFileView.ATTR_FILE_VIEW_CHARSET, m_charset.getValue()); 107 session.setAttribute(CmsLogFileView.ATTR_FILE_VIEW_SIZE, m_size.getValue()); 108 window.close(); 109 110 } 111 }); 112 } 113}