From 4f3e81a8db20c780c3c4733627be1793fb17921a Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 9 Aug 2013 09:42:25 +0300 Subject: Use instead of {@code} for sample containing { and } (#12311) Change-Id: Ibbcc48e5557521bfe50e73e63ad723fe7da29c9b --- server/src/com/vaadin/annotations/JavaScript.java | 9 +++++---- server/src/com/vaadin/annotations/StyleSheet.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/annotations/JavaScript.java b/server/src/com/vaadin/annotations/JavaScript.java index bdba70c095..3e9c46083d 100644 --- a/server/src/com/vaadin/annotations/JavaScript.java +++ b/server/src/com/vaadin/annotations/JavaScript.java @@ -44,10 +44,11 @@ import com.vaadin.server.ClientConnector; * file was loaded from a different folder. * *

- * Example: {@code @JavaScript( "http://host.com/file1.js", "file2.js"})} on the - * class com.example.MyConnector would load the file http://host.com/file1.js as - * is and file2.js from /com/example/file2.js on the server's classpath using - * the ClassLoader that was used to load com.example.MyConnector. + * Example: @JavaScript({"http://host.com/file1.js", "file2.js"}) + * on the class com.example.MyConnector would load the file + * http://host.com/file1.js as is and file2.js from /com/example/file2.js on the + * server's classpath using the ClassLoader that was used to load + * com.example.MyConnector. * * @author Vaadin Ltd * @since 7.0.0 diff --git a/server/src/com/vaadin/annotations/StyleSheet.java b/server/src/com/vaadin/annotations/StyleSheet.java index 6540633f8f..bc5b011873 100644 --- a/server/src/com/vaadin/annotations/StyleSheet.java +++ b/server/src/com/vaadin/annotations/StyleSheet.java @@ -49,8 +49,8 @@ import com.vaadin.server.ClientConnector; * VAADIN folder and vaadin:// you can publish stylesheets which use images or * other files with relative paths. *

- * Example: {@code @StyleSheet( "http://host.com/file1.css", "file2.css"})} on - * the class com.example.MyConnector would load the file + * Example: @StyleSheet({"http://host.com/file1.css", "file2.css"}) + * on the class com.example.MyConnector would load the file * http://host.com/file1.css as is and file2.css from /com/example/file2.css on * the server's classpath using the ClassLoader that was used to load * com.example.MyConnector. -- cgit v1.2.3 From 4fb775a66c81e47ff500ab562839028f62ed81b9 Mon Sep 17 00:00:00 2001 From: Teemu Pöntelin Date: Mon, 12 Aug 2013 10:08:12 +0300 Subject: Fixed a typo in FieldGroup.isModified() JavaDoc. (#12172) Change-Id: I10d7ba7d0bc5c03e65206617c521d089fd4d0cfe --- server/src/com/vaadin/data/fieldgroup/FieldGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index 981aea387d..23f2da53ce 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -656,7 +656,7 @@ public class FieldGroup implements Serializable { /** * Checks if any bound field has been modified. * - * @return true if at least on field has been modified, false otherwise + * @return true if at least one field has been modified, false otherwise */ public boolean isModified() { for (Field field : getFields()) { -- cgit v1.2.3 From 36413cb556cee7a7024a552e3772a2369d8f0294 Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Thu, 15 Aug 2013 08:59:03 +0300 Subject: Make sure that no fileIds are replayed to the client (#12330) Due to how ProxyReceivers are constructed and serialized, we don't want to resend the ProxyReceivers for files that already are in the queue. Either we needed to change the way ProxyReceivers behave, or just make sure that they aren't resent. I chose the double-check method. Change-Id: I7c4e866ba4287afd3e80329be3640335d4ff00af --- server/src/com/vaadin/ui/DragAndDropWrapper.java | 27 ++++- .../draganddropwrapper/DragAndDropBatchUpload.java | 132 +++++++++++++++++++++ 2 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropBatchUpload.java (limited to 'server') diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index 6c6aa3c3f4..5d6825c868 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -17,10 +17,12 @@ package com.vaadin.ui; import java.io.OutputStream; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import com.vaadin.event.Transferable; import com.vaadin.event.TransferableImpl; @@ -183,6 +185,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, private final Map html5DataFlavors = new LinkedHashMap(); private DragStartMode dragStartMode = DragStartMode.NONE; + private Set sentIds = new HashSet(); + /** * Wraps given component in a {@link DragAndDropWrapper}. * @@ -229,10 +233,24 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, ProxyReceiver proxyReceiver = entry.getValue(); Html5File html5File = proxyReceiver.file; if (html5File.getStreamVariable() != null) { - target.addVariable(this, "rec-" + id, new ProxyReceiver(id, - html5File)); - // these are cleaned from receivers once the upload has - // started + if (!sentIds.contains(id)) { + target.addVariable(this, "rec-" + id, + new ProxyReceiver(id, html5File)); + + /* + * if a new batch is requested to be uploaded before the + * last one is done, any remaining ids will be replayed. + * We want to avoid a new ProxyReceiver to be made since + * it'll get a new URL, so we need to keep extra track + * on what has been sent. + * + * See #12330. + */ + sentIds.add(id); + + // these are cleaned from receivers once the upload has + // started + } } else { // instructs the client side not to send the file target.addVariable(this, "rec-" + id, (String) null); @@ -317,6 +335,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, } // no need tell to the client about this receiver on next paint receivers.remove(id); + sentIds.remove(id); // let the terminal GC the streamvariable and not to accept other // file uploads to this variable event.disposeStreamVariable(); diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropBatchUpload.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropBatchUpload.java new file mode 100644 index 0000000000..adb5cd9e3a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropBatchUpload.java @@ -0,0 +1,132 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.components.draganddropwrapper; + +import java.io.OutputStream; + +import org.apache.commons.io.output.NullOutputStream; + +import com.vaadin.event.Transferable; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.StreamVariable; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; +import com.vaadin.ui.Html5File; +import com.vaadin.ui.Label; + +public class DragAndDropBatchUpload extends AbstractTestUI { + + private int batchId = 0; + private Label console = new Label("No activity detected yet", + ContentMode.HTML); + + @Override + protected void setup(VaadinRequest request) { + final DragAndDropWrapper dndWrapper = new DragAndDropWrapper( + new Button("Upload here by drag and dropping")); + dndWrapper.setDropHandler(new DropHandler() { + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + @Override + public void drop(DragAndDropEvent event) { + Transferable transferable = event.getTransferable(); + String consoleString = "Drop batch number " + (++batchId) + + ""; + if (transferable instanceof WrapperTransferable) { + WrapperTransferable wTransferable = (WrapperTransferable) transferable; + Html5File[] files = wTransferable.getFiles(); + + if (files != null) { + consoleString += "
" + files.length + " file(s):"; + for (Html5File file : files) { + consoleString += "
" + file.getFileName(); + file.setStreamVariable(new StreamVariable() { + + @Override + public void streamingStarted( + StreamingStartEvent event) { + } + + @Override + public void streamingFinished( + StreamingEndEvent event) { + } + + @Override + public void streamingFailed( + StreamingErrorEvent event) { + } + + @Override + public void onProgress( + StreamingProgressEvent event) { + } + + @Override + public boolean listenProgress() { + return false; + } + + @Override + public boolean isInterrupted() { + return false; + } + + @Override + public OutputStream getOutputStream() { + return new NullOutputStream(); + } + }); + } + } else { + consoleString += "
No files detected..."; + } + console.setValue(consoleString); + } else { + console.setValue(consoleString + + "
Something else than files were dragged"); + } + + } + }); + + addComponent(dndWrapper); + addComponent(console); + } + + @Override + protected String getTestDescription() { + return "Starting to upload a new batch before the old one must not reuse receivers"; + } + + @Override + protected Integer getTicketNumber() { + return 12330; + } + +} -- cgit v1.2.3 From c87772be9a87fe629c5c3d0077e6455261bb4762 Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Tue, 20 Aug 2013 07:13:32 +0000 Subject: Escape markup in CustomLayout's JavaDoc (#12410) svn changeset:26111/svn branch:6.8 Change-Id: I8585c9022b78381a40d9008b0d489aecd741b011 --- server/src/com/vaadin/ui/CustomLayout.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index 7bffa05058..37c9a4fa21 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -80,7 +80,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { * @param templateStream * Stream containing template data. Must be using UTF-8 encoding. * To use a String as a template use for instance new - * ByteArrayInputStream("