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.user; 029 030import org.opencms.file.CmsUser; 031import org.opencms.ui.CmsVaadinUtils; 032import org.opencms.ui.apps.Messages; 033import org.opencms.util.CmsUUID; 034 035import java.util.HashMap; 036import java.util.List; 037import java.util.Map; 038 039import com.vaadin.data.HasValue.ValueChangeEvent; 040import com.vaadin.data.HasValue.ValueChangeListener; 041import com.vaadin.ui.Button; 042import com.vaadin.ui.CheckBox; 043import com.vaadin.ui.Window; 044import com.vaadin.v7.ui.Label; 045 046/** 047 * Only export dialog.<p> 048 */ 049public class CmsUserCsvExportDialog extends A_CmsImportExportUserDialog { 050 051 /**List of all user to export. */ 052 private List<CmsUser> m_user; 053 054 /**vaadin component. */ 055 private Button m_cancel; 056 057 /**vaadin component. */ 058 private Button m_download; 059 060 /**vaadin component. */ 061 private Label m_elementToExportOU; 062 063 /**vaadin component. */ 064 private Label m_elementToExportGroup; 065 066 /**vaadin component. */ 067 private Label m_elementToExportRole; 068 069 /**Include technical fields flag. */ 070 private CheckBox m_includeTechnicalFields; 071 072 /**vaadin component. */ 073 private Label m_elementExtendedDataUser; 074 075 /**vaadin component. */ 076 private Label m_elementExtendedDataRole; 077 078 /**vaadin component. */ 079 private Label m_elementToExportCount; 080 081 /** 082 * constructor.<p> 083 * 084 * @param userToExport user list 085 * @param ou ouname 086 * @param type state type 087 * @param elementName name of element 088 * @param extendedData extended Data 089 * @param window window 090 */ 091 CmsUserCsvExportDialog( 092 List<CmsUser> userToExport, 093 String ou, 094 I_CmsOuTreeType type, 095 String elementName, 096 boolean extendedData, 097 Window window, 098 boolean includeTechnicalFields) { 099 100 window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_EXPORT_0)); 101 102 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 103 m_includeTechnicalFields.addValueChangeListener(new ValueChangeListener<Boolean>() { 104 105 public void valueChange(ValueChangeEvent event) { 106 107 initDownloadButton(); 108 109 } 110 111 }); 112 m_includeTechnicalFields.setVisible(includeTechnicalFields); 113 m_user = userToExport; 114 super.init(ou, window); 115 m_elementToExportOU.setVisible(type.isUser()); 116 m_elementToExportGroup.setVisible(type.isGroup()); 117 m_elementToExportRole.setVisible(type.isRole()); 118 119 m_elementExtendedDataUser.setVisible(extendedData && type.isUser()); 120 m_elementExtendedDataRole.setVisible(extendedData && type.isRole()); 121 122 m_elementToExportOU.setValue( 123 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_EXPORT_OU_1, elementName)); 124 m_elementToExportGroup.setValue( 125 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_EXPORT_GROUP_1, elementName)); 126 m_elementToExportRole.setValue( 127 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_EXPORT_ROLE_1, elementName)); 128 129 m_elementToExportCount.setValue( 130 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_EXPORT_COUNT_1, userToExport.size())); 131 132 } 133 134 /** 135 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#getCloseButton() 136 */ 137 @Override 138 Button getCloseButton() { 139 140 return m_cancel; 141 } 142 143 /** 144 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#getDownloadButton() 145 */ 146 @Override 147 Button getDownloadButton() { 148 149 return m_download; 150 } 151 152 /** 153 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#getUserToExport() 154 */ 155 @Override 156 Map<CmsUUID, CmsUser> getUserToExport() { 157 158 Map<CmsUUID, CmsUser> userMap = new HashMap<CmsUUID, CmsUser>(); 159 for (CmsUser user : m_user) { 160 userMap.put(user.getId(), user); 161 } 162 return userMap; 163 } 164 165 /** 166 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#isExportWithTechnicalFields() 167 */ 168 @Override 169 boolean isExportWithTechnicalFields() { 170 171 return m_includeTechnicalFields.getValue().booleanValue(); 172 } 173 174}