diff options
10 files changed, 42 insertions, 13 deletions
diff --git a/all/src/main/templates/release-notes.html b/all/src/main/templates/release-notes.html index 99f41b2c91..1daed88508 100644 --- a/all/src/main/templates/release-notes.html +++ b/all/src/main/templates/release-notes.html @@ -158,7 +158,7 @@ </ul> <li><tt>TwinColSelect</tt> is always in multiselect mode</li> <li><tt>ListSelect</tt> is always in multiselect mode</li> - <li><tt>Upload</tt> has a separate immediate mode <tt>setImmediateMode(boolean immediateMode)</tt> replacing removed <tt>setImmediate</tt></li> + <li><tt>Upload</tt> has a separate immediate mode <tt>setImmediateMode(boolean)</tt> replacing <tt>setImmediate</tt> and is now by default in immediate mode</li> <li><tt>RichTextArea</tt> no longer receives a special "v-richtextarea-readonly" class when readonly, only the standard "v-readonly" class</li> <li><tt>Grid</tt> has been typed to the bean type it is using and its columns are specified with a value provider callback instead of "propertyId"</li> <li><tt>Grid</tt> Editor now uses <tt>Binder</tt> instead of <tt>FieldGroup</tt>, and doesn't support a <tt>FieldFactory</tt></li> diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 866bc96d25..d67fa07641 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -1128,11 +1128,13 @@ public class Upload extends AbstractComponent /** * Sets the immediate mode of the upload. * <p> - * 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. + * If the upload is in immediate mode, the file upload is started + * immediately after the user has selected the file. * <p> - * The default mode of an Upload component is non-immediate. + * If the upload is not in immediate mode, after selecting the file the user + * must click another button to start the upload. + * <p> + * The default mode of an Upload component is immediate. * * @param immediateMode * {@code true} for immediate mode, {@code false} for not @@ -1143,6 +1145,8 @@ public class Upload extends AbstractComponent /** * Returns the immediate mode of the upload. + * <p> + * The default mode of an Upload component is immediate. * * @return {@code true} if the upload is in immediate mode, {@code false} if * the upload is not in immediate mode diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java index d84a32c7b5..22695f3918 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.server.component.upload; +import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.design.DeclarativeTestBase; @@ -58,4 +59,15 @@ public class UploadDeclarativeTest extends DeclarativeTestBase<Upload> { public void testWriteEmpty() { testWrite("<vaadin-upload />", new Upload()); } + + @Test + public void testImmediateModeDefault() { + Assert.assertTrue( + testRead("<v-upload />", new Upload()).isImmediateMode()); + + Upload upload = new Upload(); + upload.setImmediateMode(false); + Assert.assertFalse(testRead("<v-upload immediate-mode=false />", upload) + .isImmediateMode()); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java index 5620e48a97..a2364b132d 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java @@ -42,6 +42,14 @@ public class UploadTest { } @Test + public void setImmediateMode_defaultTrue() { + Upload upload = new Upload(); + + Assert.assertTrue("Upload should be in immediate mode by default", + upload.isImmediateMode()); + } + + @Test public void getState_uploadHasCustomState() { TestUpload upload = new TestUpload(); UploadState state = upload.getState(); diff --git a/shared/src/main/java/com/vaadin/shared/ui/upload/UploadState.java b/shared/src/main/java/com/vaadin/shared/ui/upload/UploadState.java index 6c42a50928..5245905441 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/upload/UploadState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/upload/UploadState.java @@ -25,7 +25,7 @@ import com.vaadin.shared.AbstractComponentState; public class UploadState extends AbstractComponentState { /** Is the upload component in immediate mode or not */ - public boolean immediateMode; + public boolean immediateMode = true; { primaryStyleName = "v-upload"; diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/components/UploadCssTest.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/components/UploadCssTest.java index 1fa591ebc0..4a54c127bb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/uitest/components/UploadCssTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/uitest/components/UploadCssTest.java @@ -10,11 +10,11 @@ public class UploadCssTest { public UploadCssTest(TestSampler parent) { Upload up = new Upload(); up.setId("upload" + debugIdCounter++); + up.setImmediateMode(false); parent.addComponent(up); up = new Upload(); up.setId("upload" + debugIdCounter++); - up.setImmediateMode(true); parent.addComponent(up); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java index 0c65c197bb..e2d5fa2f52 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java @@ -52,6 +52,7 @@ public class UploadNoSelection extends AbstractTestUIWithLog Upload u = new Upload("Upload", this); u.setId(UPLOAD_ID); u.setSizeUndefined(); + u.setImmediateMode(false); addComponent(u); diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadTitleWithTooltip.java b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadTitleWithTooltip.java index c38b307523..f8571a8e89 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadTitleWithTooltip.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadTitleWithTooltip.java @@ -30,6 +30,7 @@ public class UploadTitleWithTooltip extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { Upload upload = new Upload(); upload.setDescription("tootlip"); + upload.setImmediateMode(false); addComponent(upload); } diff --git a/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java b/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java index 4e8c441b1e..a2270f7925 100644 --- a/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java +++ b/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java @@ -122,6 +122,9 @@ public class FontIcons extends AbstractReindeerTestUI { e.printStackTrace(); continue; } + if (c instanceof Upload) { + ((Upload) c).setImmediateMode(false); + } c.setCaption(clazz.getSimpleName()); c.setIcon(icon); gl.addComponent(c); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/ImmediateUpload.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/ImmediateUpload.java index 30f472114e..4d08ec31f6 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/ImmediateUpload.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/ImmediateUpload.java @@ -35,15 +35,15 @@ public class ImmediateUpload extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - // by default is not in immediate mode - Upload upload = new Upload(); - upload.setId("upload"); - addComponent(upload); - + // by default is in immediate mode (since 8.0) Upload immediateUpload = new Upload(); immediateUpload.setId("immediateupload"); - immediateUpload.setImmediateMode(true); addComponent(immediateUpload); + + Upload upload = new Upload(); + upload.setId("upload"); + upload.setImmediateMode(false); + addComponent(upload); } /* |