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.ade.upload.client.ui; 029 030import org.opencms.ade.upload.client.Messages; 031import org.opencms.gwt.client.ui.input.upload.CmsFileInfo; 032import org.opencms.gwt.client.ui.input.upload.CmsFileInput; 033import org.opencms.gwt.shared.CmsListInfoBean; 034 035import java.util.HashMap; 036import java.util.Map; 037 038/** 039 * Provides the default upload dialog without multiple file selection.<p> 040 * 041 * @since 8.0.0 042 */ 043public class CmsUploadDialogImpl extends A_CmsUploadDialog { 044 045 /** The input file input fields. */ 046 private Map<String, CmsFileInput> m_inputsToUpload = new HashMap<String, CmsFileInput>(); 047 048 /** 049 * @see org.opencms.ade.upload.client.ui.A_CmsUploadDialog#createInfoBean(org.opencms.gwt.client.ui.input.upload.CmsFileInfo) 050 */ 051 @Override 052 public CmsListInfoBean createInfoBean(CmsFileInfo file) { 053 054 return new CmsListInfoBean(file.getFileName(), getResourceType(file), null); 055 } 056 057 /** 058 * @see org.opencms.ade.upload.client.ui.A_CmsUploadDialog#getFileSizeTooLargeMessage(org.opencms.gwt.client.ui.input.upload.CmsFileInfo) 059 */ 060 @Override 061 public String getFileSizeTooLargeMessage(CmsFileInfo file) { 062 063 return ""; 064 } 065 066 /** 067 * @see org.opencms.ade.upload.client.ui.A_CmsUploadDialog#isTooLarge(org.opencms.gwt.client.ui.input.upload.CmsFileInfo) 068 */ 069 @Override 070 public boolean isTooLarge(CmsFileInfo cmsFileInfo) { 071 072 return false; 073 } 074 075 /** 076 * @see org.opencms.ade.upload.client.ui.A_CmsUploadDialog#updateSummary() 077 */ 078 @Override 079 public void updateSummary() { 080 081 StringBuffer buffer = new StringBuffer(64); 082 buffer.append("<p class=\"").append( 083 org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.uploadButton().dialogMessage()).append("\">"); 084 buffer.append("<b>" + Messages.get().key(Messages.GUI_UPLOAD_SUMMARY_FILES_0) + "</b> "); 085 buffer.append( 086 Messages.get().key( 087 Messages.GUI_UPLOAD_SUMMARY_FILES_VALUE_2, 088 Integer.valueOf(getFilesToUpload().size()), 089 getFileText())); 090 buffer.append("</p>"); 091 setSummaryHTML(buffer.toString()); 092 } 093 094 /** 095 * Adds the given file input field to this dialog.<p> 096 * 097 * @param fileInput the file input field to add 098 */ 099 @Override 100 protected void addFileInput(CmsFileInput fileInput) { 101 102 // add the files selected by the user to the list of files to upload 103 if (fileInput != null) { 104 m_inputsToUpload.put(fileInput.getFiles()[0].getFileName(), fileInput); 105 } 106 super.addFileInput(fileInput); 107 } 108}