From 8ef496dbde9578cbab3e05f9d81238d4da9806e6 Mon Sep 17 00:00:00 2001 From: Pekka Hyvönen Date: Thu, 6 Oct 2016 17:16:31 +0300 Subject: 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 --- server/src/main/java/com/vaadin/ui/Upload.java | 51 ++++++++++++++++---------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'server') 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(). * *

- * 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. * *

- * Note! Because of browser dependent implementations of - * 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 + * 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()}. *

* 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. *

* @@ -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. *

- * 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. *

* 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); + } } -- cgit v1.2.3