View Javadoc
1   /**
2    * This file Copyright (c) 2011-2018 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.ui.form.field.definition;
35  
36  import info.magnolia.ui.form.field.transformer.Transformer;
37  import info.magnolia.ui.form.validator.definition.FieldValidatorDefinition;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * Describes a field in a dialog.
44   *
45   * @deprecated since 6.2 - use {@link info.magnolia.ui.field.ConfiguredFieldDefinition} instead.
46   *
47   * @see <a href="https://documentation.magnolia-cms.com/display/DOCS62/Upgrading+to+Magnolia+6.2.x">Upgrading to Magnolia 6.2.x</a>
48   */
49  @Deprecated
50  public class ConfiguredFieldDefinition implements FieldDefinition {
51  
52      private String name;
53  
54      private String label;
55  
56      private String i18nBasename;
57  
58      private boolean i18n = false;
59  
60      private String description; // not relevant for controlType=static
61  
62      private String type; // JCR Property type name see javax.jcr.PropertyType
63  
64      private boolean required = false; // Not relevant for checkbox
65  
66      private String requiredErrorMessage = "validation.message.required";
67  
68      private boolean readOnly = false; // Specify if the property has to be saved
69  
70      private String defaultValue; // Specify the default value
71  
72      private String styleName;
73  
74      private List<FieldValidatorDefinition> validators = new ArrayList<FieldValidatorDefinition>();
75  
76      private Class<? extends Transformer<?>> transformerClass;
77  
78      private Class<?> converterClass;
79  
80      /**
81       * Defined only to eliminate to-bean transformation related warnings.
82       *
83       * <p>Note: this field is only specified in the configured definition and doesn't provide a getter as it is
84       * not part of the field definition contract. The use case is simplification of field definitions themselves and
85       * to prevent N2B/M2B mechanisms to report problems of kind "unknown property".</p>
86       * @see info.magnolia.ui.form.fieldtype.resolver.FieldTypeResolver
87       */
88      private String fieldType;
89  
90      @Override
91      public String getName() {
92          return name;
93      }
94  
95      @Override
96      public String getLabel() {
97          return label;
98      }
99  
100     /**
101      * @deprecated since 5.1. Use {@link info.magnolia.i18nsystem.I18nizer} mechanism instead.
102      */
103     @Override
104     @Deprecated
105     public String getI18nBasename() {
106         return i18nBasename;
107     }
108 
109     @Override
110     public String getDescription() {
111         return description;
112     }
113 
114     @Override
115     public String getType() {
116         return type;
117     }
118 
119     @Override
120     public boolean isRequired() {
121         return required;
122     }
123 
124     @Override
125     public String getRequiredErrorMessage() {
126         return requiredErrorMessage;
127     }
128 
129     @Override
130     public List<FieldValidatorDefinition> getValidators() {
131         return validators;
132     }
133 
134     @Override
135     public String getDefaultValue() {
136         return this.defaultValue;
137     }
138 
139     @Override
140     public boolean isReadOnly() {
141         return this.readOnly;
142     }
143 
144     @Override
145     public boolean isI18n() {
146         return i18n;
147     }
148 
149     @Override
150     public String getStyleName() {
151         return styleName;
152     }
153 
154     public void setStyleName(String styleName) {
155         this.styleName = styleName;
156     }
157 
158     public void setI18n(boolean i18n) {
159         this.i18n = i18n;
160     }
161 
162     public void setRequiredErrorMessage(String requiredErrorMessage) {
163         this.requiredErrorMessage = requiredErrorMessage;
164     }
165 
166     public void setReadOnly(boolean readOnly) {
167         this.readOnly = readOnly;
168     }
169 
170     public void setName(String name) {
171         this.name = name;
172     }
173 
174     public void setLabel(String label) {
175         this.label = label;
176     }
177 
178     /**
179      * @deprecated since 5.1. Use {@link info.magnolia.i18nsystem.I18nizer} mechanism instead.
180      */
181     @Deprecated
182     public void setI18nBasename(String i18nBasename) {
183         this.i18nBasename = i18nBasename;
184     }
185 
186     public void setDescription(String description) {
187         this.description = description;
188     }
189 
190     public void setType(String type) {
191         this.type = type;
192     }
193 
194     public void setRequired(boolean required) {
195         this.required = required;
196     }
197 
198     public void setValidators(List<FieldValidatorDefinition> validators) {
199         this.validators = validators;
200     }
201 
202     public void addValidator(FieldValidatorDefinition validator) {
203         validators.add(validator);
204     }
205 
206     public void setDefaultValue(String defaultValue) {
207         this.defaultValue = defaultValue;
208     }
209 
210     @Override
211     public Class<? extends Transformer<?>> getTransformerClass() {
212         return transformerClass;
213     }
214 
215     public void setTransformerClass(Class<? extends Transformer<?>> transformerClass) {
216         this.transformerClass = transformerClass;
217     }
218 
219     @Override
220     public Class<?> getConverterClass() {
221         return converterClass;
222     }
223 
224     public void setConverterClass(Class<?> converterClass) {
225         this.converterClass = converterClass;
226     }
227 
228     public String getFieldType() {
229         return fieldType;
230     }
231 
232     public void setFieldType(String fieldType) {
233         this.fieldType = fieldType;
234     }
235 }