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