View Javadoc

1   /**
2    * This file Copyright (c) 2011-2013 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.validator.definition.FieldValidatorDefinition;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * Describes a field in a dialog.
43   */
44  public class ConfiguredFieldDefinition implements FieldDefinition {
45  
46      private String name;
47  
48      private String label;
49  
50      private String i18nBasename;
51  
52      private boolean i18n = false;
53  
54      private String description; // not relevant for controlType=static
55  
56      private String type; // JCR Property type name see javax.jcr.PropertyType
57  
58      private boolean required = false; // Not relevant for checkbox
59  
60      private String requiredErrorMessage = "validation.message.required";
61  
62      private boolean readOnly = false; // Specify if the property has to be saved
63  
64      private String defaultValue; // Specify the default value
65  
66      private String styleName;
67  
68      private List<FieldValidatorDefinition> validators = new ArrayList<FieldValidatorDefinition>();
69  
70      @Override
71      public String getName() {
72          return name;
73      }
74  
75      @Override
76      public String getLabel() {
77          return label;
78      }
79  
80      @Override
81      public String getI18nBasename() {
82          return i18nBasename;
83      }
84  
85      @Override
86      public String getDescription() {
87          return description;
88      }
89  
90      @Override
91      public String getType() {
92          return type;
93      }
94  
95      @Override
96      public boolean isRequired() {
97          return required;
98      }
99  
100     @Override
101     public String getRequiredErrorMessage() {
102         return requiredErrorMessage;
103     }
104 
105     @Override
106     public List<FieldValidatorDefinition> getValidators() {
107         return validators;
108     }
109 
110     @Override
111     public String getDefaultValue() {
112         return this.defaultValue;
113     }
114 
115     @Override
116     public boolean isReadOnly() {
117         return this.readOnly;
118     }
119 
120     @Override
121     public boolean isI18n() {
122         return i18n;
123     }
124 
125     @Override
126     public String getStyleName() {
127         return styleName;
128     }
129 
130     public void setStyleName(String styleName) {
131         this.styleName = styleName;
132     }
133 
134     public void setI18n(boolean i18n) {
135         this.i18n = i18n;
136     }
137 
138     public void setRequiredErrorMessage(String requiredErrorMessage) {
139         this.requiredErrorMessage = requiredErrorMessage;
140     }
141 
142     public void setReadOnly(boolean readOnly) {
143         this.readOnly = readOnly;
144     }
145 
146     public void setName(String name) {
147         this.name = name;
148     }
149 
150     public void setLabel(String label) {
151         this.label = label;
152     }
153 
154     public void setI18nBasename(String i18nBasename) {
155         this.i18nBasename = i18nBasename;
156     }
157 
158     public void setDescription(String description) {
159         this.description = description;
160     }
161 
162     public void setType(String type) {
163         this.type = type;
164     }
165 
166     public void setRequired(boolean required) {
167         this.required = required;
168     }
169 
170     public void setValidators(List<FieldValidatorDefinition> validators) {
171         this.validators = validators;
172     }
173 
174     public void addValidator(FieldValidatorDefinition validator) {
175         validators.add(validator);
176     }
177 
178     public void setDefaultValue(String defaultValue) {
179         this.defaultValue = defaultValue;
180     }
181 
182 }