001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (C) Alkacon Software (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.ade.postupload.client.ui; 029 030import org.opencms.gwt.client.property.CmsSimplePropertyEditor; 031import org.opencms.gwt.client.property.I_CmsPropertyEditorHandler; 032import org.opencms.gwt.client.ui.css.I_CmsLayoutBundle; 033import org.opencms.gwt.client.ui.input.I_CmsFormField; 034import org.opencms.gwt.shared.property.CmsPropertyModification; 035import org.opencms.util.CmsStringUtil; 036import org.opencms.util.CmsUUID; 037import org.opencms.xml.content.CmsXmlContentProperty; 038 039import java.util.Map; 040 041import com.google.gwt.user.client.ui.Label; 042 043/** 044 * A property editor for the upload property dialog.<p> 045 */ 046public class CmsUploadPropertyEditor extends CmsSimplePropertyEditor { 047 048 private CmsUUID m_structureId; 049 /** The handler for transferring property values to other uploads. */ 050 private I_CmsUpdateAllUploadsHandler m_updateAllHandler; 051 052 /** The warning message. */ 053 private String m_warning; 054 055 /** 056 * Creates a new instance.<p> 057 * 058 * @param propConfig the property configuration 059 * @param handler the property editor handler to use 060 * @param updateAllHandler the handler to call for transferring a property value to all uploads 061 */ 062 public CmsUploadPropertyEditor( 063 CmsUUID structureId, 064 Map<String, CmsXmlContentProperty> propConfig, 065 I_CmsPropertyEditorHandler handler, 066 I_CmsUpdateAllUploadsHandler updateAllHandler) { 067 068 super(propConfig, handler); 069 m_structureId = structureId; 070 m_updateAllHandler = updateAllHandler; 071 CmsUploadPropertyEditorHandler uploadPropertyHandler = (CmsUploadPropertyEditorHandler)handler; 072 m_warning = uploadPropertyHandler.getWarning(); 073 } 074 075 /** 076 * @see org.opencms.gwt.client.property.CmsSimplePropertyEditor#isAlwaysAllowEmpty(java.lang.String) 077 */ 078 @Override 079 protected boolean isAlwaysAllowEmpty(String name) { 080 081 return false; 082 } 083 084 /** 085 * @see org.opencms.gwt.client.property.CmsSimplePropertyEditor#maybeAddCustomValidator(org.opencms.xml.content.CmsXmlContentProperty, org.opencms.gwt.client.ui.input.I_CmsFormField) 086 */ 087 @Override 088 protected void maybeAddCustomValidator(CmsXmlContentProperty propDef, I_CmsFormField field) { 089 090 if (field.getId().contains(CmsPropertyModification.FILE_NAME_PROPERTY)) { 091 field.setValidator(new CmsFilenameValidator(m_structureId, propDef)); 092 } 093 } 094 095 /** 096 * @see org.opencms.gwt.client.property.CmsSimplePropertyEditor#setupFieldContainer() 097 */ 098 @Override 099 protected void setupFieldContainer() { 100 101 CmsUploadFormFieldPanel panel = new CmsUploadFormFieldPanel(m_handler.getPageInfo(), m_updateAllHandler); 102 panel.addStyleName(I_CmsLayoutBundle.INSTANCE.propertiesCss().noPaddingTop()); 103 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(m_warning)) { 104 Label warningLabel = new Label(m_warning); 105 warningLabel.addStyleName( 106 org.opencms.ade.postupload.client.ui.css.I_CmsLayoutBundle.INSTANCE.dialogCss().warningBox()); 107 panel.addWidgetAfterListInfo(warningLabel); 108 } 109 m_form.setWidget(panel); 110 } 111 112}