diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2016-10-06 17:16:31 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-10-07 13:38:13 +0000 |
commit | 8ef496dbde9578cbab3e05f9d81238d4da9806e6 (patch) | |
tree | 400e9e6aa0d08b7d0d0f78caf8203255bc10a303 /server/src/main/java/com/vaadin/ui/Upload.java | |
parent | 8d825141f239a6f39a6d4ebd3b48ced7e97fc61b (diff) | |
download | vaadin-framework-8ef496dbde9578cbab3e05f9d81238d4da9806e6.tar.gz vaadin-framework-8ef496dbde9578cbab3e05f9d81238d4da9806e6.zip |
Separate immediate mode for Upload from AbstactComponent.immediate
Makes it possible to remove the immediate from AbstractComponent.
Part 2 / 2 of adding proper Upload immediateMode, first was to move
old Upload to v7 compatiblity packages.
Change-Id: Iff99df70d9465fa1f3bad4baae44a0488eba01c0
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/Upload.java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Upload.java | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 5d2d4763e7..a08fce099e 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -62,14 +62,14 @@ import com.vaadin.util.ReflectTools; * ProgressListener and updating the indicator in updateProgress(). * * <p> - * Setting upload component immediate initiates the upload as soon as a file is - * selected, instead of the common pattern of file selection field and upload - * button. + * Setting upload component immediate with {@link #setImmediateMode(boolean)} + * initiates the upload as soon as a file is selected, instead of the common + * pattern of file selection field and upload button. * * <p> - * Note! Because of browser dependent implementations of - * <input type="file"> element, setting size for Upload component is not - * supported. For some browsers setting size may work to some extend. + * Note! Because of browser dependent implementations of <input type="file"> + * element, setting size for Upload component is not supported. For some + * browsers setting size may work to some extend. * * @author Vaadin Ltd. * @since 3.0 @@ -991,7 +991,7 @@ public class Upload extends AbstractComponent * {@link #submitUpload()}. * <p> * In case the Upload is used in immediate mode using - * {@link #setImmediate(boolean)}, the file choose (html input with type + * {@link #setImmediateMode(boolean)}, the file choose (html input with type * "file") is hidden and only the button with this text is shown. * <p> * @@ -1048,8 +1048,8 @@ public class Upload extends AbstractComponent @Override public boolean listenProgress() { - return (progressListeners != null - && !progressListeners.isEmpty()); + return progressListeners != null + && !progressListeners.isEmpty(); } @Override @@ -1128,28 +1128,39 @@ public class Upload extends AbstractComponent } /** - * Returns the immediate mode of the component. + * Sets the immediate mode of the upload. * <p> - * An immediate mode Upload component displays the browser file choosing + * If the upload is in immediate mode, it displays the browser file choosing * button immediately, whereas a non-immediate upload only shows a Vaadin * button. * <p> * The default mode of an Upload component is non-immediate. * - * @return true if the component is in immediate mode, false if the - * component if not in immediate mode + * @param immediateMode + * {@code true} for immediate mode, {@code false} for not */ - @Override - public boolean isImmediate() { - if (getExplicitImmediateValue() != null) { - return getExplicitImmediateValue(); - } else { - return false; - } + public void setImmediateMode(boolean immediateMode) { + getState().immediateMode = immediateMode; + } + + /** + * Returns the immediate mode of the upload. + * + * @return {@code true} if the upload is in immediate mode, {@code false} if + * the upload is not in immediate mode + * @see #setImmediateMode(boolean) + */ + public boolean isImmediateMode() { + return getState(false).immediateMode; } @Override protected UploadState getState() { return (UploadState) super.getState(); } + + @Override + protected UploadState getState(boolean markAsDirty) { + return (UploadState) super.getState(markAsDirty); + } } |