]> source.dussan.org Git - vaadin-framework.git/commitdiff
Change Upload to be in immediate mode by default (#111)
authorPekka Hyvönen <pekka@vaadin.com>
Mon, 12 Dec 2016 14:32:59 +0000 (16:32 +0200)
committerGitHub <noreply@github.com>
Mon, 12 Dec 2016 14:32:59 +0000 (16:32 +0200)
Fixes vaadin/framework8-issues#547

all/src/main/templates/release-notes.html
server/src/main/java/com/vaadin/ui/Upload.java
server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java
server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java
shared/src/main/java/com/vaadin/shared/ui/upload/UploadState.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/UploadCssTest.java
uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java
uitest/src/main/java/com/vaadin/tests/components/upload/UploadTitleWithTooltip.java
uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java
uitest/src/main/java/com/vaadin/tests/themes/valo/ImmediateUpload.java

index 99f41b2c91c9cb33a655a96eb7664ead0db1c63b..1daed885087a90ccb143e795ef280bfbdaa82e16 100644 (file)
             </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>
index 866bc96d251273c7ab91ee3fec79cf68b5a73b80..d67fa07641e449ce300560531f24727dc1edd8db 100644 (file)
@@ -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
index d84a32c7b5ae23cd50913c78fb86efbed91b2be8..22695f3918405e04b3506a08b2b8da0b9f32bf46 100644 (file)
@@ -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());
+    }
 }
index 5620e48a97463e7927fcacd266578bdd9a238456..a2364b132d75aeed2b6630b94988de1a3fa083be 100644 (file)
@@ -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();
index 6c42a5092892940df0df9836bbcf912486f97c3f..5245905441b6ee0b5ef70db606421366499a81e5 100644 (file)
@@ -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";
index 1fa591ebc0b41a7caf761a1ddb600e6ee90ee2eb..4a54c127bb45ebea091bee50301ef316920a35db 100644 (file)
@@ -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);
     }
 }
index 0c65c197bbe1861441df9f469764f659fb679efc..e2d5fa2f5202835df2e663d4f8deaa3f822f11ad 100644 (file)
@@ -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);
 
index c38b30752389a0dd76793956932dfd8df5d9d820..f8571a8e89355d5ddbf0b485c8d1a65e1401d0c3 100644 (file)
@@ -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);
     }
index 4e8c441b1ee189467b58a383bbe61b7e88d599dd..a2270f7925e1578f3a08115e4094645c9fcfd8be 100644 (file)
@@ -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);
index 30f472114e05e40222730d2886a7c43b90536130..4d08ec31f6bf5289d9ba831a0eaa2deb8c9e35e0 100644 (file)
@@ -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);
     }
 
     /*