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.gwt.client.ui.input; 029 030import org.opencms.gwt.client.ui.I_CmsAutoHider; 031 032/** 033 * Basic interface for all widgets that can be used for form fields.<p> 034 * 035 * @since 8.0.0 036 */ 037public interface I_CmsFormWidget { 038 039 /** 040 * Field type constants.<p> 041 * 042 */ 043 public enum FieldType { 044 /** Field type constant for booleans (Java type: Boolean). */ 045 BOOLEAN, /** Field type constant for dates (Java type: Date). */ 046 DATE, /** Field type constant for numbers (Java type: Double). */ 047 NUMBER, /** Field type constant for strings (Java type: String). */ 048 STRING, /** Field type constant for lists of strings (Java type: List<String>). */ 049 STRING_LIST 050 } 051 052 /** 053 * Returns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.<p> 054 * 055 * @return the apparent value 056 */ 057 String getApparentValue(); 058 059 /** 060 * Returns the type of data this widget produces. 061 * @return the data type 062 */ 063 FieldType getFieldType(); 064 065 /** 066 * Gets the selected/entered value from the widget.<p> 067 * 068 * @return the value 069 */ 070 Object getFormValue(); 071 072 /** 073 * Gets the current value of the widget as a string.<p> 074 * 075 * @return the current value of the widget 076 */ 077 String getFormValueAsString(); 078 079 /** 080 * Returns <code>true</code> if this widget is enabled.<p> 081 * 082 * @return <code>true</code> if this widget is enabled 083 */ 084 boolean isEnabled(); 085 086 /** 087 * Resets the widget to its default state. 088 */ 089 void reset(); 090 091 /** 092 * Call this when auto hiding parents are shown.<p> 093 * 094 * @param autoHideParent the auto hide parent 095 */ 096 void setAutoHideParent(I_CmsAutoHider autoHideParent); 097 098 /** 099 * Enables or disables the widget.<p> 100 * 101 * @param enabled if true, the widget will be enabled, else disabled 102 */ 103 void setEnabled(boolean enabled); 104 105 /** 106 * Sets the error message for this widget.<p> 107 * 108 * If the error message is null, no error message will be displayed. 109 * 110 * @param errorMessage an error message or null 111 */ 112 void setErrorMessage(String errorMessage); 113 114 /** 115 * Sets the current value of the widget as a string.<p> 116 * 117 * @param value the new value of the widget 118 */ 119 void setFormValueAsString(String value); 120 121}