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.annotation.deprecation.MgnlDeprecated;
37  
38  import info.magnolia.ui.form.field.transformer.Transformer;
39  import info.magnolia.ui.form.validator.definition.FieldValidatorDefinition;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * Describes a field in a dialog.
46   *
47   * @deprecated since 6.2 - use {@link info.magnolia.ui.field.ConfiguredFieldDefinition} instead.
48   *
49   * @see <a href="https://documentation.magnolia-cms.com/display/DOCS62/Upgrading+to+Magnolia+6.2.x">Upgrading to Magnolia 6.2.x</a>
50   */
51  @Deprecated
52  @MgnlDeprecated(since = "6.2", description = "Use new framework and info.magnolia.ui.field.ConfiguredFieldDefinition instead.")
53  public class ConfiguredFieldDefinition implements FieldDefinition {
54  
55      private String name;
56  
57      private String label;
58  
59      private String i18nBasename;
60  
61      private boolean i18n = false;
62  
63      private String description; // not relevant for controlType=static
64  
65      private String type; // JCR Property type name see javax.jcr.PropertyType
66  
67      private boolean required = false; // Not relevant for checkbox
68  
69      private String requiredErrorMessage = "validation.message.required";
70  
71      private boolean readOnly = false; // Specify if the property has to be saved
72  
73      private String defaultValue; // Specify the default value
74  
75      private String styleName;
76  
77      private List<FieldValidatorDefinition> validators = new ArrayList<FieldValidatorDefinition>();
78  
79      private Class<? extends Transformer<?>> transformerClass;
80  
81      private Class<?> converterClass;
82  
83      /**
84       * Defined only to eliminate to-bean transformation related warnings.
85       *
86       * <p>Note: this field is only specified in the configured definition and doesn't provide a getter as it is
87       * not part of the field definition contract. The use case is simplification of field definitions themselves and
88       * to prevent N2B/M2B mechanisms to report problems of kind "unknown property".</p>
89       * @see info.magnolia.ui.form.fieldtype.resolver.FieldTypeResolver
90       */
91      private String fieldType;
92  
93      @Override
94      public String getName() {
95          return name;
96      }
97  
98      @Override
99      public String getLabel() {
100         return label;
101     }
102 
103     /**
104      * @deprecated since 5.1. Use {@link info.magnolia.i18nsystem.I18nizer} mechanism instead.
105      */
106     @Override
107     @Deprecated
108     public String getI18nBasename() {
109         return i18nBasename;
110     }
111 
112     @Override
113     public String getDescription() {
114         return description;
115     }
116 
117     @Override
118     public String getType() {
119         return type;
120     }
121 
122     @Override
123     public boolean isRequired() {
124         return required;
125     }
126 
127     @Override
128     public String getRequiredErrorMessage() {
129         return requiredErrorMessage;
130     }
131 
132     @Override
133     public List<FieldValidatorDefinition> getValidators() {
134         return validators;
135     }
136 
137     @Override
138     public String getDefaultValue() {
139         return this.defaultValue;
140     }
141 
142     @Override
143     public boolean isReadOnly() {
144         return this.readOnly;
145     }
146 
147     @Override
148     public boolean isI18n() {
149         return i18n;
150     }
151 
152     @Override
153     public String getStyleName() {
154         return styleName;
155     }
156 
157     public void setStyleName(String styleName) {
158         this.styleName = styleName;
159     }
160 
161     public void setI18n(boolean i18n) {
162         this.i18n = i18n;
163     }
164 
165     public void setRequiredErrorMessage(String requiredErrorMessage) {
166         this.requiredErrorMessage = requiredErrorMessage;
167     }
168 
169     public void setReadOnly(boolean readOnly) {
170         this.readOnly = readOnly;
171     }
172 
173     public void setName(String name) {
174         this.name = name;
175     }
176 
177     public void setLabel(String label) {
178         this.label = label;
179     }
180 
181     /**
182      * @deprecated since 5.1. Use {@link info.magnolia.i18nsystem.I18nizer} mechanism instead.
183      */
184     @Deprecated
185     public void setI18nBasename(String i18nBasename) {
186         this.i18nBasename = i18nBasename;
187     }
188 
189     public void setDescription(String description) {
190         this.description = description;
191     }
192 
193     public void setType(String type) {
194         this.type = type;
195     }
196 
197     public void setRequired(boolean required) {
198         this.required = required;
199     }
200 
201     public void setValidators(List<FieldValidatorDefinition> validators) {
202         this.validators = validators;
203     }
204 
205     public void addValidator(FieldValidatorDefinition validator) {
206         validators.add(validator);
207     }
208 
209     public void setDefaultValue(String defaultValue) {
210         this.defaultValue = defaultValue;
211     }
212 
213     @Override
214     public Class<? extends Transformer<?>> getTransformerClass() {
215         return transformerClass;
216     }
217 
218     public void setTransformerClass(Class<? extends Transformer<?>> transformerClass) {
219         this.transformerClass = transformerClass;
220     }
221 
222     @Override
223     public Class<?> getConverterClass() {
224         return converterClass;
225     }
226 
227     public void setConverterClass(Class<?> converterClass) {
228         this.converterClass = converterClass;
229     }
230 
231     public String getFieldType() {
232         return fieldType;
233     }
234 
235     public void setFieldType(String fieldType) {
236         this.fieldType = fieldType;
237     }
238 }