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 GmbH & Co. KG, 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.widgets; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsResource; 032import org.opencms.i18n.CmsEncoder; 033import org.opencms.i18n.CmsMessages; 034import org.opencms.xml.content.I_CmsXmlContentHandler.DisplayType; 035import org.opencms.xml.types.A_CmsXmlContentValue; 036 037import java.util.List; 038import java.util.Locale; 039 040/** 041 * Provides a standard HTML form password widget, for use on a widget dialog.<p> 042 * 043 * @since 6.0.0 044 */ 045public class CmsPasswordWidget extends A_CmsWidget implements I_CmsADEWidget { 046 047 /** 048 * Creates a new password widget.<p> 049 */ 050 public CmsPasswordWidget() { 051 052 // empty constructor is required for class registration 053 this(""); 054 } 055 056 /** 057 * Creates a new password widget with the given configuration.<p> 058 * 059 * @param configuration the configuration to use 060 */ 061 public CmsPasswordWidget(String configuration) { 062 063 super(configuration); 064 } 065 066 /** 067 * @see org.opencms.widgets.I_CmsADEWidget#getConfiguration(org.opencms.file.CmsObject, org.opencms.xml.types.A_CmsXmlContentValue, org.opencms.i18n.CmsMessages, org.opencms.file.CmsResource, java.util.Locale) 068 */ 069 public String getConfiguration( 070 CmsObject cms, 071 A_CmsXmlContentValue schemaType, 072 CmsMessages messages, 073 CmsResource resource, 074 Locale contentLocale) { 075 076 return getConfiguration(); 077 } 078 079 /** 080 * @see org.opencms.widgets.I_CmsADEWidget#getDefaultDisplayType() 081 */ 082 public DisplayType getDefaultDisplayType() { 083 084 return DisplayType.singleline; 085 } 086 087 /** 088 * @see org.opencms.widgets.I_CmsADEWidget#getCssResourceLinks(org.opencms.file.CmsObject) 089 */ 090 public List<String> getCssResourceLinks(CmsObject cms) { 091 092 return null; 093 } 094 095 /** 096 * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) 097 */ 098 public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { 099 100 String id = param.getId(); 101 102 StringBuffer result = new StringBuffer(16); 103 104 result.append("<td class=\"xmlTd\"><input type=\"password\" class=\"xmlInput textInput"); 105 if (param.hasError()) { 106 result.append(" xmlInputError"); 107 } 108 result.append("\" name=\""); 109 result.append(id); 110 result.append("\" id=\""); 111 result.append(id); 112 result.append("\" value=\""); 113 result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); 114 result.append("\">"); 115 result.append("</td>"); 116 117 return result.toString(); 118 } 119 120 /** 121 * @see org.opencms.widgets.I_CmsADEWidget#getInitCall() 122 */ 123 public String getInitCall() { 124 125 return null; 126 } 127 128 /** 129 * @see org.opencms.widgets.I_CmsADEWidget#getJavaScriptResourceLinks(org.opencms.file.CmsObject) 130 */ 131 public List<String> getJavaScriptResourceLinks(CmsObject cms) { 132 133 return null; 134 } 135 136 /** 137 * @see org.opencms.widgets.I_CmsADEWidget#getWidgetName() 138 */ 139 public String getWidgetName() { 140 141 return CmsPasswordWidget.class.getName(); 142 } 143 144 /** 145 * @see org.opencms.widgets.I_CmsADEWidget#isInternal() 146 */ 147 public boolean isInternal() { 148 149 return true; 150 } 151 152 /** 153 * @see org.opencms.widgets.I_CmsWidget#newInstance() 154 */ 155 public I_CmsWidget newInstance() { 156 157 return new CmsPasswordWidget(getConfiguration()); 158 } 159}