View Javadoc

1   /**
2    * This file Copyright (c) 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.config;
35  
36  import info.magnolia.ui.form.field.definition.BasicUploadFieldDefinition;
37  import info.magnolia.ui.form.validator.definition.ConfiguredFieldValidatorDefinition;
38  
39  /**
40   * Builder for building a basic file upload field definition.
41   */
42  public class BasicUploadFieldBuilder extends AbstractFieldBuilder {
43  
44      private final BasicUploadFieldDefinition definition = new BasicUploadFieldDefinition();
45  
46      public BasicUploadFieldBuilder(String name) {
47          this.definition().setName(name);
48      }
49  
50      @Override
51      public BasicUploadFieldDefinition definition() {
52          return definition;
53      }
54  
55      public BasicUploadFieldBuilder binaryNodeName(String binaryNodeName) {
56          definition().setBinaryNodeName(binaryNodeName);
57          return this;
58      }
59  
60      public BasicUploadFieldBuilder maxUploadSize(long maxUploadSize) {
61          definition().setMaxUploadSize(maxUploadSize);
62          return this;
63      }
64  
65      public BasicUploadFieldBuilder allowedMimeTypePattern(String allowedMimeTypePattern) {
66          definition().setAllowedMimeTypePattern(allowedMimeTypePattern);
67          return this;
68      }
69  
70      public BasicUploadFieldBuilder editFileName(boolean editFileName) {
71          definition().setEditFileName(editFileName);
72          return this;
73      }
74  
75      public BasicUploadFieldBuilder editFileFormat(boolean editFileFormat) {
76          definition().setEditFileFormat(editFileFormat);
77          return this;
78      }
79  
80      public BasicUploadFieldBuilder selectAnotherCaption(String selectAnotherCaption) {
81          definition().setSelectAnotherCaption(selectAnotherCaption);
82          return this;
83      }
84  
85      public BasicUploadFieldBuilder userInterruption(String userInterruption) {
86          definition().setUserInterruption(userInterruption);
87          return this;
88      }
89  
90      public BasicUploadFieldBuilder fileDetailNameCaption(String fileDetailNameCaption) {
91          definition().setFileDetailNameCaption(fileDetailNameCaption);
92          return this;
93      }
94  
95      public BasicUploadFieldBuilder inProgressRatioCaption(String inProgressRatioCaption) {
96          definition().setInProgressRatioCaption(inProgressRatioCaption);
97          return this;
98      }
99  
100     public BasicUploadFieldBuilder dropZoneCaption(String dropZoneCaption) {
101         definition().setDropZoneCaption(dropZoneCaption);
102         return this;
103     }
104 
105     public BasicUploadFieldBuilder warningNoteCaption(String warningNoteCaption) {
106         definition().setWarningNoteCaption(warningNoteCaption);
107         return this;
108     }
109 
110     public BasicUploadFieldBuilder fileDetailSourceCaption(String fileDetailSourceCaption) {
111         definition().setFileDetailSourceCaption(fileDetailSourceCaption);
112         return this;
113     }
114 
115     public BasicUploadFieldBuilder inProgressCaption(String inProgressCaption) {
116         definition().setInProgressCaption(inProgressCaption);
117         return this;
118     }
119 
120     public BasicUploadFieldBuilder deleteCaption(String deleteCaption) {
121         definition().setDeleteCaption(deleteCaption);
122         return this;
123     }
124 
125     public BasicUploadFieldBuilder typeInterruption(String typeInterruption) {
126         definition().setTypeInterruption(typeInterruption);
127         return this;
128     }
129 
130     public BasicUploadFieldBuilder selectNewCaption(String selectNewCaption) {
131         definition().setSelectNewCaption(selectNewCaption);
132         return this;
133     }
134 
135     public BasicUploadFieldBuilder sizeInterruption(String sizeInterruption) {
136         definition().setSizeInterruption(sizeInterruption);
137         return this;
138     }
139 
140     public BasicUploadFieldBuilder fileDetailHeaderCaption(String fileDetailHeaderCaption) {
141         definition().setFileDetailHeaderCaption(fileDetailHeaderCaption);
142         return this;
143     }
144 
145     public BasicUploadFieldBuilder fileDetailFormatCaption(String fileDetailFormatCaption) {
146         definition().setFileDetailFormatCaption(fileDetailFormatCaption);
147         return this;
148     }
149 
150     public BasicUploadFieldBuilder errorNoteCaption(String errorNoteCaption) {
151         definition().setErrorNoteCaption(errorNoteCaption);
152         return this;
153     }
154 
155     public BasicUploadFieldBuilder successNoteCaption(String successNoteCaption) {
156         definition().setSuccessNoteCaption(successNoteCaption);
157         return this;
158     }
159 
160     public BasicUploadFieldBuilder fileDetailSizeCaption(String fileDetailSizeCaption) {
161         definition().setFileDetailSizeCaption(fileDetailSizeCaption);
162         return this;
163     }
164 
165     // Overrides for methods in parent class changing return type to allow method chaining
166 
167     @Override
168     public BasicUploadFieldBuilder label(String label) {
169         return (BasicUploadFieldBuilder) super.label(label);
170     }
171 
172     @Override
173     public BasicUploadFieldBuilder i18nBasename(String i18nBasename) {
174         return (BasicUploadFieldBuilder) super.i18nBasename(i18nBasename);
175     }
176 
177     @Override
178     public BasicUploadFieldBuilder i18n(boolean i18n) {
179         return (BasicUploadFieldBuilder) super.i18n(i18n);
180     }
181 
182     @Override
183     public BasicUploadFieldBuilder i18n() {
184         return (BasicUploadFieldBuilder) super.i18n();
185     }
186 
187     @Override
188     public BasicUploadFieldBuilder description(String description) {
189         return (BasicUploadFieldBuilder) super.description(description);
190     }
191 
192     @Override
193     public BasicUploadFieldBuilder type(String type) {
194         return (BasicUploadFieldBuilder) super.type(type);
195     }
196 
197     @Override
198     public BasicUploadFieldBuilder required(boolean required) {
199         return (BasicUploadFieldBuilder) super.required(required);
200     }
201 
202     @Override
203     public BasicUploadFieldBuilder required() {
204         return (BasicUploadFieldBuilder) super.required();
205     }
206 
207     @Override
208     public BasicUploadFieldBuilder requiredErrorMessage(String requiredErrorMessage) {
209         return (BasicUploadFieldBuilder) super.requiredErrorMessage(requiredErrorMessage);
210     }
211 
212     @Override
213     public BasicUploadFieldBuilder readOnly(boolean readOnly) {
214         return (BasicUploadFieldBuilder) super.readOnly(readOnly);
215     }
216 
217     @Override
218     public BasicUploadFieldBuilder readOnly() {
219         return (BasicUploadFieldBuilder) super.readOnly();
220     }
221 
222     @Override
223     public BasicUploadFieldBuilder defaultValue(String defaultValue) {
224         return (BasicUploadFieldBuilder) super.defaultValue(defaultValue);
225     }
226 
227     @Override
228     public BasicUploadFieldBuilder styleName(String styleName) {
229         return (BasicUploadFieldBuilder) super.styleName(styleName);
230     }
231 
232     @Override
233     public BasicUploadFieldBuilder validator(ConfiguredFieldValidatorDefinition validatorDefinition) {
234         return (BasicUploadFieldBuilder) super.validator(validatorDefinition);
235     }
236 
237     @Override
238     public BasicUploadFieldBuilder validator(GenericValidatorBuilder validatorBuilder) {
239         return (BasicUploadFieldBuilder) super.validator(validatorBuilder);
240     }
241 }