From: Pekka Hyvönen Date: Mon, 12 Dec 2016 14:32:59 +0000 (+0200) Subject: Change Upload to be in immediate mode by default (#111) X-Git-Tag: 8.0.0.alpha10~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e63b51a831676bdcc15b889c1636c0dcccbc0bc0;p=vaadin-framework.git Change Upload to be in immediate mode by default (#111) Fixes vaadin/framework8-issues#547 --- 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 @@
  • TwinColSelect is always in multiselect mode
  • ListSelect is always in multiselect mode
  • -
  • Upload has a separate immediate mode setImmediateMode(boolean immediateMode) replacing removed setImmediate
  • +
  • Upload has a separate immediate mode setImmediateMode(boolean) replacing setImmediate and is now by default in immediate mode
  • RichTextArea no longer receives a special "v-richtextarea-readonly" class when readonly, only the standard "v-readonly" class
  • Grid has been typed to the bean type it is using and its columns are specified with a value provider callback instead of "propertyId"
  • Grid Editor now uses Binder instead of FieldGroup, and doesn't support a FieldFactory
  • 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. *

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

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

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

    + * 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 { public void testWriteEmpty() { testWrite("", new Upload()); } + + @Test + public void testImmediateModeDefault() { + Assert.assertTrue( + testRead("", new Upload()).isImmediateMode()); + + Upload upload = new Upload(); + upload.setImmediateMode(false); + Assert.assertFalse(testRead("", 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 @@ -41,6 +41,14 @@ public class UploadTest { Assert.assertFalse(upload.isUploading()); } + @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(); 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); } /*