]> source.dussan.org Git - vaadin-framework.git/commitdiff
method and class renames and cleaning up TODOs
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 11 Nov 2010 10:28:14 +0000 (10:28 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 11 Nov 2010 10:28:14 +0000 (10:28 +0000)
svn changeset:15962/svn branch:6.5

20 files changed:
src/com/vaadin/terminal/StreamVariable.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java
src/com/vaadin/terminal/gwt/server/CommunicationManager.java
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java
src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StreamingFailedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StreamingProgressedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/StreamingStartedEventImpl.java [deleted file]
src/com/vaadin/terminal/gwt/server/StremingEndedEventImpl.java [deleted file]
src/com/vaadin/ui/DragAndDropWrapper.java
src/com/vaadin/ui/Html5File.java
src/com/vaadin/ui/Upload.java
tests/src/com/vaadin/tests/dd/DDTest6.java
tests/src/com/vaadin/tests/dd/DragAndDropFiles.java
tests/src/com/vaadin/tests/dd/DragDropPane.java

index 99eb2417efb6eb5343e39e6a1a4a905f4f41989d..d711a8f1c8ea3da9a2e1aa8aeb6954d0b2ef7685 100644 (file)
@@ -4,9 +4,9 @@ import java.io.OutputStream;
 import java.io.Serializable;
 
 import com.vaadin.Application;
-import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingEndEvent;
+import com.vaadin.terminal.StreamVariable.StreamingErrorEvent;
+import com.vaadin.terminal.StreamVariable.StreamingStartEvent;
 
 /**
  * StreamVariable is a special kind of variable whose value is streamed to an
@@ -30,7 +30,7 @@ public interface StreamVariable extends Serializable {
 
     /**
      * Invoked by the terminal when a new upload arrives, after
-     * {@link #streamingStarted(StreamingStartedEvent)} method has been called.
+     * {@link #streamingStarted(StreamingStartEvent)} method has been called.
      * The terminal implementation will write the streamed variable to the
      * returned output stream.
      * 
@@ -45,12 +45,12 @@ public interface StreamVariable extends Serializable {
      * {@link #onProgress(long, long)} is called in a synchronized block when
      * the content is being received. This is potentially bit slow, so we are
      * calling that method only if requested. The value is requested after the
-     * {@link #uploadStarted(StreamingStartedEvent)} event, but not after
+     * {@link #uploadStarted(StreamingStartEvent)} event, but not after
      * reading each buffer.
      * 
      * @return true if this {@link StreamVariable} wants to by notified during
      *         the upload of the progress of streaming.
-     * @see #onProgress(StreamingProgressedEvent)
+     * @see #onProgress(StreamingProgressEvent)
      */
     boolean listenProgress();
 
@@ -58,13 +58,13 @@ public interface StreamVariable extends Serializable {
      * This method is called by the terminal if {@link #listenProgress()}
      * returns true when the streaming starts.
      */
-    void onProgress(StreamingProgressedEvent event);
+    void onProgress(StreamingProgressEvent event);
 
-    void streamingStarted(StreamingStartedEvent event);
+    void streamingStarted(StreamingStartEvent event);
 
-    void streamingFinished(StreamingEndedEvent event);
+    void streamingFinished(StreamingEndEvent event);
 
-    void streamingFailed(StreamingFailedEvent event);
+    void streamingFailed(StreamingErrorEvent event);
 
     /*
      * Not synchronized to avoid stalls (caused by UIDL requests) while
@@ -108,35 +108,35 @@ public interface StreamVariable extends Serializable {
     }
 
     /**
-     * Event passed to {@link #uploadStarted(StreamingStartedEvent)} method
+     * Event passed to {@link #uploadStarted(StreamingStartEvent)} method
      * before the streaming of the content to {@link StreamVariable} starts.
      */
-    public interface StreamingStartedEvent extends StreamingEvent {
+    public interface StreamingStartEvent extends StreamingEvent {
     }
 
     /**
-     * Event passed to {@link #onProgress(StreamingProgressedEvent)} method
+     * Event passed to {@link #onProgress(StreamingProgressEvent)} method
      * during the streaming progresses.
      */
-    public interface StreamingProgressedEvent extends StreamingEvent {
+    public interface StreamingProgressEvent extends StreamingEvent {
     }
 
     /**
-     * Event passed to {@link #uploadFinished(StreamingEndedEvent)} method the
+     * Event passed to {@link #uploadFinished(StreamingEndEvent)} method the
      * contents have been streamed to StreamVariable successfully.
      */
-    public interface StreamingEndedEvent extends StreamingEvent {
+    public interface StreamingEndEvent extends StreamingEvent {
     }
 
     /**
-     * Event passed to {@link #uploadFailed(StreamingFailedEvent)} method when
+     * Event passed to {@link #uploadFailed(StreamingErrorEvent)} method when
      * the streaming ended before the end of the input. The streaming may fail
      * due an interruption by {@link } or due an other unknown exception in
      * communication. In the latter case the exception is also passed to
      * {@link Application#terminalError(com.vaadin.terminal.Terminal.ErrorEvent)}
      * .
      */
-    public interface StreamingFailedEvent extends StreamingEvent {
+    public interface StreamingErrorEvent extends StreamingEvent {
 
         /**
          * @return the exception that caused the receiving not to finish cleanly
index 73b83957c27dee2fc3f66805414369f8adb0acba..5b691438f3d1bc622e47f01c1107fb1d669a3404 100644 (file)
@@ -52,9 +52,9 @@ import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Paintable;
 import com.vaadin.terminal.Paintable.RepaintRequestEvent;
 import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingEndEvent;
+import com.vaadin.terminal.StreamVariable.StreamingErrorEvent;
+import com.vaadin.terminal.StreamVariable.StreamingStartEvent;
 import com.vaadin.terminal.Terminal.ErrorEvent;
 import com.vaadin.terminal.Terminal.ErrorListener;
 import com.vaadin.terminal.URIHandler;
@@ -378,8 +378,8 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      */
     protected void doHandleSimpleMultipartFileUpload(Request request,
-            Response response, StreamVariable streamVariable, VariableOwner owner,
-            String boundary) throws IOException {
+            Response response, StreamVariable streamVariable,
+            VariableOwner owner, String boundary) throws IOException {
         boundary = CRLF + "--" + boundary + "--";
 
         // multipart parsing, supports only one file for request, but that is
@@ -551,8 +551,8 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      */
     protected void doHandleXhrFilePost(Request request, Response response,
-            StreamVariable streamVariable, VariableOwner owner, int contentLength)
-            throws IOException {
+            StreamVariable streamVariable, VariableOwner owner,
+            int contentLength) throws IOException {
 
         // These are unknown in filexhr ATM, maybe add to Accept header that
         // is accessible in portlets
@@ -581,10 +581,11 @@ public abstract class AbstractCommunicationManager implements
     }
 
     protected final void streamToReceiver(final InputStream in,
-            StreamVariable streamVariable, String filename,
-            String type, int contentLength) throws UploadException {
+            StreamVariable streamVariable, String filename, String type,
+            int contentLength) throws UploadException {
         if (streamVariable == null) {
-            throw new IllegalStateException("StreamVariable for the post not found");
+            throw new IllegalStateException(
+                    "StreamVariable for the post not found");
         }
 
         final Application application = getApplication();
@@ -594,8 +595,8 @@ public abstract class AbstractCommunicationManager implements
         try {
             boolean listenProgress;
             synchronized (application) {
-                StreamingStartedEvent startedEvent = new StreamingStartedEventImpl(
-                        streamVariable, filename, type, contentLength);
+                StreamingStartEvent startedEvent = new StreamingStartEventImpl(
+                        filename, type, contentLength);
                 streamVariable.streamingStarted(startedEvent);
                 out = streamVariable.getOutputStream();
                 listenProgress = streamVariable.listenProgress();
@@ -620,9 +621,8 @@ public abstract class AbstractCommunicationManager implements
                     // update progress if listener set and contentLength
                     // received
                     synchronized (application) {
-                        StreamingProgressedEventImpl progressEvent = new StreamingProgressedEventImpl(
-                                streamVariable, filename, type, contentLength,
-                                totalBytes);
+                        StreamingProgressEventImpl progressEvent = new StreamingProgressEventImpl(
+                                filename, type, contentLength, totalBytes);
                         streamVariable.onProgress(progressEvent);
                     }
                 }
@@ -633,8 +633,8 @@ public abstract class AbstractCommunicationManager implements
 
             // upload successful
             out.close();
-            StreamingEndedEvent event = new StremingEndedEventImpl(streamVariable,
-                    filename, type, totalBytes);
+            StreamingEndEvent event = new StreamingEndEventImpl(filename, type,
+                    totalBytes);
             synchronized (application) {
                 streamVariable.streamingFinished(event);
             }
@@ -642,8 +642,8 @@ public abstract class AbstractCommunicationManager implements
         } catch (UploadInterruptedException e) {
             // Download interrupted by application code
             tryToCloseStream(out);
-            StreamingFailedEvent event = new StreamingFailedEventImpl(streamVariable,
-                    filename, type, contentLength, totalBytes, e);
+            StreamingErrorEvent event = new StreamingErrorEventImpl(filename,
+                    type, contentLength, totalBytes, e);
             synchronized (application) {
                 streamVariable.streamingFailed(event);
             }
@@ -652,8 +652,8 @@ public abstract class AbstractCommunicationManager implements
         } catch (final Exception e) {
             tryToCloseStream(out);
             synchronized (application) {
-                StreamingFailedEvent event = new StreamingFailedEventImpl(
-                        streamVariable, filename, type, contentLength, totalBytes, e);
+                StreamingErrorEvent event = new StreamingErrorEventImpl(
+                        filename, type, contentLength, totalBytes, e);
                 synchronized (application) {
                     streamVariable.streamingFailed(event);
                 }
@@ -2181,6 +2181,6 @@ public abstract class AbstractCommunicationManager implements
 
     }
 
-    abstract String createReceiverUrl(VariableOwner owner, String name,
+    abstract String createStreamVariableTargetUrl(VariableOwner owner, String name,
             StreamVariable value);
 }
index 91039d05e5c914b03887537c5e6b1413e42458fe..83ba45789d9f22fe3119839e20ea3ea4c0b4d618 100644 (file)
@@ -1,6 +1,5 @@
 package com.vaadin.terminal.gwt.server;
 
-import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.StreamVariable.StreamingEvent;
 
 /**
@@ -10,7 +9,6 @@ import com.vaadin.terminal.StreamVariable.StreamingEvent;
 abstract class AbstractStreamingEvent implements StreamingEvent {
     private final String type;
     private final String filename;
-    private final StreamVariable streamVariable;
     private final long contentLength;
     private final long bytesReceived;
 
@@ -22,19 +20,14 @@ abstract class AbstractStreamingEvent implements StreamingEvent {
         return type;
     }
 
-    protected AbstractStreamingEvent(StreamVariable streamVariable, String filename,
-            String type, long length, long bytesReceived) {
-        this.streamVariable = streamVariable;
+    protected AbstractStreamingEvent(String filename, String type, long length,
+            long bytesReceived) {
         this.filename = filename;
         this.type = type;
         contentLength = length;
         this.bytesReceived = bytesReceived;
     }
 
-    public final StreamVariable getReceiver() {
-        return streamVariable;
-    }
-
     public final long getContentLength() {
         return contentLength;
     }
index 73f6732cf0555ad83a1fff01ce7f6c2ca32bc53a..ae4ec16c2aedb3d9b2f3527db95f30fc32f4a5b9 100644 (file)
@@ -208,7 +208,8 @@ public class CommunicationManager extends AbstractCommunicationManager {
     /**
      * Handles file upload request submitted via Upload component.
      * 
-     * @see #createReceiverUrl(ReceiverOwner, String, StreamVariable)
+     * @see #createStreamVariableTargetUrl(ReceiverOwner, String,
+     *      StreamVariable)
      * 
      * @param request
      * @param response
@@ -231,24 +232,26 @@ public class CommunicationManager extends AbstractCommunicationManager {
         String uppUri = pathInfo.substring(startOfData);
         String[] parts = uppUri.split("/", 3); // 0 = pid, 1= name, 2 = sec key
 
-        StreamVariable streamVariable = pidToNameToReceiver.get(parts[0]).remove(parts[1]);
-        String secKey = receiverToSeckey.remove(streamVariable);
+        StreamVariable streamVariable = pidToNameToStreamVariable.get(parts[0])
+                .remove(parts[1]);
+        String secKey = streamVariableToSeckey.remove(streamVariable);
         if (secKey.equals(parts[2])) {
 
-            VariableOwner source = (VariableOwner) getVariableOwner(parts[0]);
+            VariableOwner source = getVariableOwner(parts[0]);
             String contentType = request.getContentType();
             if (request.getContentType().contains("boundary")) {
                 // Multipart requests contain boundary string
                 doHandleSimpleMultipartFileUpload(
                         new HttpServletRequestWrapper(request),
-                        new HttpServletResponseWrapper(response), streamVariable,
-                        source, contentType.split("boundary=")[1]);
+                        new HttpServletResponseWrapper(response),
+                        streamVariable, source,
+                        contentType.split("boundary=")[1]);
             } else {
                 // if boundary string does not exist, the posted file is from
                 // XHR2.post(File)
                 doHandleXhrFilePost(new HttpServletRequestWrapper(request),
-                        new HttpServletResponseWrapper(response), streamVariable,
-                        source, request.getContentLength());
+                        new HttpServletResponseWrapper(response),
+                        streamVariable, source, request.getContentLength());
             }
         } else {
             throw new InvalidUIDLSecurityKeyException(
@@ -336,12 +339,12 @@ public class CommunicationManager extends AbstractCommunicationManager {
     @Override
     protected void unregisterPaintable(Component p) {
         /* Cleanup possible receivers */
-        if (pidToNameToReceiver != null) {
-            Map<String, StreamVariable> removed = pidToNameToReceiver
+        if (pidToNameToStreamVariable != null) {
+            Map<String, StreamVariable> removed = pidToNameToStreamVariable
                     .remove(getPaintableId(p));
             if (removed != null) {
                 for (String key : removed.keySet()) {
-                    receiverToSeckey.remove(removed.get(key));
+                    streamVariableToSeckey.remove(removed.get(key));
                 }
             }
         }
@@ -349,16 +352,13 @@ public class CommunicationManager extends AbstractCommunicationManager {
 
     }
 
-    private Map<String, Map<String, StreamVariable>> pidToNameToReceiver;
+    private Map<String, Map<String, StreamVariable>> pidToNameToStreamVariable;
 
-    private Map<StreamVariable, String> receiverToSeckey;
+    private Map<StreamVariable, String> streamVariableToSeckey;
 
     @Override
-    String createReceiverUrl(VariableOwner owner, String name, StreamVariable value) {
-        
-        /*
-         * TODO figure out how this can be simplified now that ReceiverOwner is removed.
-         */
+    String createStreamVariableTargetUrl(VariableOwner owner, String name,
+            StreamVariable value) {
 
         /*
          * We will use the same APP/* URI space as ApplicationResources but
@@ -369,28 +369,28 @@ public class CommunicationManager extends AbstractCommunicationManager {
          * SECKEY is created on each paint to make URL's unpredictable (to
          * prevent CSRF attacks).
          * 
-         * NAME and PID from URI forms a key to fetch StreamVariable when handling
-         * post
+         * NAME and PID from URI forms a key to fetch StreamVariable when
+         * handling post
          */
         String paintableId = getPaintableId((Paintable) owner);
         String key = paintableId + "/" + name;
 
-        if (pidToNameToReceiver == null) {
-            pidToNameToReceiver = new HashMap<String, Map<String, StreamVariable>>();
+        if (pidToNameToStreamVariable == null) {
+            pidToNameToStreamVariable = new HashMap<String, Map<String, StreamVariable>>();
         }
-        Map<String, StreamVariable> nameToReceiver = pidToNameToReceiver
+        Map<String, StreamVariable> nameToStreamVariable = pidToNameToStreamVariable
                 .get(paintableId);
-        if (nameToReceiver == null) {
-            nameToReceiver = new HashMap<String, StreamVariable>();
-            pidToNameToReceiver.put(paintableId, nameToReceiver);
+        if (nameToStreamVariable == null) {
+            nameToStreamVariable = new HashMap<String, StreamVariable>();
+            pidToNameToStreamVariable.put(paintableId, nameToStreamVariable);
         }
-        nameToReceiver.put(name, value);
+        nameToStreamVariable.put(name, value);
 
-        if (receiverToSeckey == null) {
-            receiverToSeckey = new HashMap<StreamVariable, String>();
+        if (streamVariableToSeckey == null) {
+            streamVariableToSeckey = new HashMap<StreamVariable, String>();
         }
         String seckey = UUID.randomUUID().toString();
-        receiverToSeckey.put(value, seckey);
+        streamVariableToSeckey.put(value, seckey);
 
         return getApplication().getURL()
                 + AbstractApplicationServlet.UPLOAD_URL_PREFIX + key + "/"
index 2ea372264de26a760798b48036e9abc4e6121294..d25619282c90d85f66907484430aa4aba0c900b4 100644 (file)
@@ -1113,7 +1113,7 @@ public class JsonPaintTarget implements PaintTarget {
 
     public void addVariable(VariableOwner owner, String name, StreamVariable value)
             throws PaintException {
-        String url = manager.createReceiverUrl(owner, name, value);
+        String url = manager.createStreamVariableTargetUrl(owner, name, value);
         addVariable(owner, name, url);
     }
 
index cf2cab0edf1f99047da200f65ad460c02c23165b..69e7b0ef27ea7b9cf2a3d59fefc4d18d1788c06c 100644 (file)
@@ -198,11 +198,11 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         String name = request.getParameter("name");
         String ownerId = request.getParameter("rec-owner");
         VariableOwner variableOwner = (VariableOwner) getVariableOwner(ownerId);
-        StreamVariable streamVariable = ownerToNameToReceiver.get(variableOwner).remove(
+        StreamVariable streamVariable = ownerToNameToStreamVariable.get(variableOwner).remove(
                 name);
 
         // clean up, may be re added on next paint
-        ownerToNameToReceiver.get(variableOwner).remove(name);
+        ownerToNameToStreamVariable.get(variableOwner).remove(name);
 
         if (contentType.contains("boundary")) {
             doHandleSimpleMultipartFileUpload(
@@ -220,8 +220,8 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
     @Override
     protected void unregisterPaintable(Component p) {
         super.unregisterPaintable(p);
-        if (ownerToNameToReceiver != null) {
-            ownerToNameToReceiver.remove(p);
+        if (ownerToNameToStreamVariable != null) {
+            ownerToNameToStreamVariable.remove(p);
         }
     }
 
@@ -271,17 +271,17 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
                 application, assumedWindow);
     }
 
-    private Map<VariableOwner, Map<String, StreamVariable>> ownerToNameToReceiver;
+    private Map<VariableOwner, Map<String, StreamVariable>> ownerToNameToStreamVariable;
 
     @Override
-    String createReceiverUrl(VariableOwner owner, String name, StreamVariable value) {
-        if (ownerToNameToReceiver == null) {
-            ownerToNameToReceiver = new HashMap<VariableOwner, Map<String, StreamVariable>>();
+    String createStreamVariableTargetUrl(VariableOwner owner, String name, StreamVariable value) {
+        if (ownerToNameToStreamVariable == null) {
+            ownerToNameToStreamVariable = new HashMap<VariableOwner, Map<String, StreamVariable>>();
         }
-        Map<String, StreamVariable> nameToReceiver = ownerToNameToReceiver.get(owner);
+        Map<String, StreamVariable> nameToReceiver = ownerToNameToStreamVariable.get(owner);
         if (nameToReceiver == null) {
             nameToReceiver = new HashMap<String, StreamVariable>();
-            ownerToNameToReceiver.put(owner, nameToReceiver);
+            ownerToNameToStreamVariable.put(owner, nameToReceiver);
         }
         nameToReceiver.put(name, value);
         ResourceURL resurl = currentUidlResponse.createResourceURL();
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java
new file mode 100644 (file)
index 0000000..e6290cb
--- /dev/null
@@ -0,0 +1,13 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable.StreamingEndEvent;
+
+@SuppressWarnings("serial")
+final class StreamingEndEventImpl extends AbstractStreamingEvent implements
+        StreamingEndEvent {
+
+    public StreamingEndEventImpl(String filename, String type, long totalBytes) {
+        super(filename, type, totalBytes, totalBytes);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java
new file mode 100644 (file)
index 0000000..367b4be
--- /dev/null
@@ -0,0 +1,21 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable.StreamingErrorEvent;
+
+@SuppressWarnings("serial")
+final class StreamingErrorEventImpl extends AbstractStreamingEvent implements
+        StreamingErrorEvent {
+
+    private final Exception exception;
+
+    public StreamingErrorEventImpl(final String filename, final String type,
+            long contentLength, long bytesReceived, final Exception exception) {
+        super(filename, type, contentLength, bytesReceived);
+        this.exception = exception;
+    }
+
+    public final Exception getException() {
+        return exception;
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingFailedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingFailedEventImpl.java
deleted file mode 100644 (file)
index 23fb3b0..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
-
-@SuppressWarnings("serial")
-final class StreamingFailedEventImpl extends AbstractStreamingEvent implements
-        StreamingFailedEvent {
-
-    private final Exception exception;
-
-    public StreamingFailedEventImpl(StreamVariable streamVariable, final String filename,
-            final String type, long contentLength, long bytesReceived,
-            final Exception exception) {
-        super(streamVariable, filename, type, contentLength, bytesReceived);
-        this.exception = exception;
-    }
-
-    public final Exception getException() {
-        return exception;
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java
new file mode 100644 (file)
index 0000000..a6308f6
--- /dev/null
@@ -0,0 +1,14 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable.StreamingProgressEvent;
+
+@SuppressWarnings("serial")
+final class StreamingProgressEventImpl extends AbstractStreamingEvent implements
+        StreamingProgressEvent {
+
+    public StreamingProgressEventImpl(final String filename, final String type,
+            long contentLength, long bytesReceived) {
+        super(filename, type, contentLength, bytesReceived);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingProgressedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingProgressedEventImpl.java
deleted file mode 100644 (file)
index 6ca751d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.StreamVariable.StreamingProgressedEvent;
-
-@SuppressWarnings("serial")
-final class StreamingProgressedEventImpl extends AbstractStreamingEvent
-        implements StreamingProgressedEvent {
-
-    public StreamingProgressedEventImpl(StreamVariable streamVariable,
-            final String filename, final String type, long contentLength,
-            long bytesReceived) {
-        super(streamVariable, filename, type, contentLength, bytesReceived);
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java
new file mode 100644 (file)
index 0000000..fedd2bd
--- /dev/null
@@ -0,0 +1,14 @@
+package com.vaadin.terminal.gwt.server;
+
+import com.vaadin.terminal.StreamVariable.StreamingStartEvent;
+
+@SuppressWarnings("serial")
+final class StreamingStartEventImpl extends AbstractStreamingEvent implements
+        StreamingStartEvent {
+
+    public StreamingStartEventImpl(final String filename, final String type,
+            long contentLength) {
+        super(filename, type, contentLength, 0);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/StreamingStartedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingStartedEventImpl.java
deleted file mode 100644 (file)
index f0b3747..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
-
-@SuppressWarnings("serial")
-final class StreamingStartedEventImpl extends AbstractStreamingEvent implements
-        StreamingStartedEvent {
-
-    public StreamingStartedEventImpl(StreamVariable streamVariable, final String filename,
-            final String type, long contentLength) {
-        super(streamVariable, filename, type, contentLength, 0);
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/StremingEndedEventImpl.java b/src/com/vaadin/terminal/gwt/server/StremingEndedEventImpl.java
deleted file mode 100644 (file)
index 9117ce9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.vaadin.terminal.gwt.server;
-
-import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
-
-@SuppressWarnings("serial")
-final class StremingEndedEventImpl extends AbstractStreamingEvent implements
-        StreamingEndedEvent {
-
-    public StremingEndedEventImpl(StreamVariable streamVariable, String filename,
-            String type, long totalBytes) {
-        super(streamVariable, filename, type, totalBytes, totalBytes);
-    }
-
-}
index d79402217c92dd35ba23cf6fbf1fe48a105ac77f..2e0c67342811b85979317327c39fadc7e401c959 100644 (file)
@@ -188,9 +188,10 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
         if (receivers != null && receivers.size() > 0) {
             for (Iterator<Entry<String, Html5File>> it = receivers.entrySet()
                     .iterator(); it.hasNext();) {
-                String id = it.next().getKey();
-                Html5File html5File = receivers.get(id);
-                if (html5File.getReceiver() != null) {
+                Entry<String, com.vaadin.ui.Html5File> entry = it.next();
+                String id = entry.getKey();
+                Html5File html5File = entry.getValue();
+                if (html5File.getStreamVariable() != null) {
                     target.addVariable(this, "rec-" + id, new ProxyReceiver(
                             html5File));
                     // these are cleaned from receivers once the upload has
@@ -245,46 +246,47 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
         private boolean listenProgressOfUploadedFile;
 
         public OutputStream getOutputStream() {
-            if (file.getReceiver() == null) {
+            if (file.getStreamVariable() == null) {
                 return null;
             }
-            return file.getReceiver().getOutputStream();
+            return file.getStreamVariable().getOutputStream();
         }
 
         public boolean listenProgress() {
-            return file.getReceiver().listenProgress();
+            return file.getStreamVariable().listenProgress();
         }
 
-        public void onProgress(StreamingProgressedEvent event) {
-            file.getReceiver().onProgress(new ReceivingEventWrapper(event));
+        public void onProgress(StreamingProgressEvent event) {
+            file.getStreamVariable().onProgress(
+                    new ReceivingEventWrapper(event));
         }
 
-        public void streamingStarted(StreamingStartedEvent event) {
-            listenProgressOfUploadedFile = file.getReceiver() != null;
+        public void streamingStarted(StreamingStartEvent event) {
+            listenProgressOfUploadedFile = file.getStreamVariable() != null;
             if (listenProgressOfUploadedFile) {
-                file.getReceiver().streamingStarted(
+                file.getStreamVariable().streamingStarted(
                         new ReceivingEventWrapper(event));
             }
             // no need tell to the client about this receiver on next paint
             receivers.remove(file);
         }
 
-        public void streamingFinished(StreamingEndedEvent event) {
+        public void streamingFinished(StreamingEndEvent event) {
             if (listenProgressOfUploadedFile) {
-                file.getReceiver().streamingFinished(
+                file.getStreamVariable().streamingFinished(
                         new ReceivingEventWrapper(event));
             }
         }
 
-        public void streamingFailed(final StreamingFailedEvent event) {
+        public void streamingFailed(final StreamingErrorEvent event) {
             if (listenProgressOfUploadedFile) {
-                file.getReceiver().streamingFailed(
+                file.getStreamVariable().streamingFailed(
                         new ReceivingEventWrapper(event));
             }
         }
 
         public boolean isInterrupted() {
-            return file.getReceiver().isInterrupted();
+            return file.getStreamVariable().isInterrupted();
         }
 
         /*
@@ -293,9 +295,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
          * terminal event and provides the lacking information from the
          * Html5File.
          */
-        class ReceivingEventWrapper implements StreamingFailedEvent,
-                StreamingEndedEvent, StreamingStartedEvent,
-                StreamingProgressedEvent {
+        class ReceivingEventWrapper implements StreamingErrorEvent,
+                StreamingEndEvent, StreamingStartEvent, StreamingProgressEvent {
 
             private StreamingEvent wrappedEvent;
 
@@ -320,8 +321,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
             }
 
             public Exception getException() {
-                if (wrappedEvent instanceof StreamingFailedEvent) {
-                    return ((StreamingFailedEvent) wrappedEvent).getException();
+                if (wrappedEvent instanceof StreamingErrorEvent) {
+                    return ((StreamingErrorEvent) wrappedEvent).getException();
                 }
                 return null;
             }
index 7c01f9b0a41137b7d37ed120c7732a2b4a094527..1eb048783ce5c632ffcbf2ee0d329ebd4304ff26 100644 (file)
@@ -51,11 +51,11 @@ public class Html5File implements Serializable {
      *            the callback that returns stream where the implementation
      *            writes the file contents as it arrives.
      */
-    public void setReceiver(StreamVariable streamVariable) {
+    public void setStreamVariable(StreamVariable streamVariable) {
         this.streamVariable = streamVariable;
     }
 
-    public StreamVariable getReceiver() {
+    public StreamVariable getStreamVariable() {
         return streamVariable;
     }
 
index 8e1a859f5fa97b08540f76aebeeb1ba6542d9e4a..c67a0f36448c0fa5745078bd17990da09fa3b2ce 100644 (file)
@@ -13,7 +13,7 @@ import java.util.Map;
 
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingStartEvent;
 import com.vaadin.terminal.gwt.client.ui.VUpload;
 import com.vaadin.terminal.gwt.server.NoInputStreamException;
 import com.vaadin.terminal.gwt.server.NoOutputStreamException;
@@ -911,14 +911,14 @@ public class Upload extends AbstractComponent implements Component.Focusable {
     protected com.vaadin.terminal.StreamVariable getStreamVariable() {
         if (streamVariable == null) {
             streamVariable = new com.vaadin.terminal.StreamVariable() {
-                private StreamingStartedEvent lastStartedEvent;
+                private StreamingStartEvent lastStartedEvent;
 
                 public boolean listenProgress() {
                     return (progressListeners != null && !progressListeners
                             .isEmpty());
                 }
 
-                public void onProgress(StreamingProgressedEvent event) {
+                public void onProgress(StreamingProgressEvent event) {
                     fireUpdateProgress(event.getBytesReceived(),
                             event.getContentLength());
                 }
@@ -935,21 +935,21 @@ public class Upload extends AbstractComponent implements Component.Focusable {
                     return receiveUpload;
                 }
 
-                public void streamingStarted(StreamingStartedEvent event) {
+                public void streamingStarted(StreamingStartEvent event) {
                     startUpload();
                     contentLength = event.getContentLength();
                     fireStarted(event.getFileName(), event.getMimeType());
                     lastStartedEvent = event;
                 }
 
-                public void streamingFinished(StreamingEndedEvent event) {
+                public void streamingFinished(StreamingEndEvent event) {
                     fireUploadSuccess(event.getFileName(), event.getMimeType(),
                             event.getContentLength());
                     endUpload();
                     requestRepaint();
                 }
 
-                public void streamingFailed(StreamingFailedEvent event) {
+                public void streamingFailed(StreamingErrorEvent event) {
                     Exception exception = event.getException();
                     if (exception instanceof NoInputStreamException) {
                         fireNoInputStream(event.getFileName(),
index 87d24b5b1758cbcd2a885684dc2335950c44f488..ecd7f911921d0aa0176902164860c91f2c1f8e76 100644 (file)
@@ -2,7 +2,6 @@ package com.vaadin.tests.dd;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Collection;
@@ -26,10 +25,10 @@ import com.vaadin.event.dd.acceptcriteria.AcceptAll;
 import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
 import com.vaadin.event.dd.acceptcriteria.Not;
 import com.vaadin.event.dd.acceptcriteria.SourceIsTarget;
-import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.Resource;
 import com.vaadin.terminal.StreamResource;
 import com.vaadin.terminal.StreamResource.StreamSource;
+import com.vaadin.terminal.StreamVariable;
 import com.vaadin.terminal.ThemeResource;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.tests.components.TestBase;
@@ -222,7 +221,6 @@ public class DDTest6 extends TestBase {
                         byte[] byteArray = bas.toByteArray();
                         return new ByteArrayInputStream(byteArray);
                     }
-                    // TODO Auto-generated method stub
                     return null;
                 }
             };
@@ -283,7 +281,6 @@ public class DDTest6 extends TestBase {
         table.setEditable(true);
         w.addComponent(table);
         getMainWindow().addWindow(w);
-        // TODO saving would be nice demo
 
     }
 
@@ -409,41 +406,30 @@ public class DDTest6 extends TestBase {
                             }
 
                             public boolean listenProgress() {
-                                // TODO Auto-generated method stub
                                 return false;
                             }
 
-                            public void onProgress(
-                                    StreamingProgressedEvent event) {
-                                // TODO Auto-generated method stub
-                                
+                            public void onProgress(StreamingProgressEvent event) {
                             }
 
                             public void streamingStarted(
-                                    StreamingStartedEvent event) {
-                                // TODO Auto-generated method stub
-                                
+                                    StreamingStartEvent event) {
                             }
 
                             public void streamingFinished(
-                                    StreamingEndedEvent event) {
-                                // TODO Auto-generated method stub
-                                
+                                    StreamingEndEvent event) {
                             }
 
                             public void streamingFailed(
-                                    StreamingFailedEvent event) {
-                                // TODO Auto-generated method stub
-                                
+                                    StreamingErrorEvent event) {
                             }
 
                             public boolean isInterrupted() {
-                                // TODO Auto-generated method stub
                                 return false;
                             }
                         };
 
-                        html5File.setReceiver(streamVariable);
+                        html5File.setStreamVariable(streamVariable);
 
                         File file = new File(fileName, bas);
                         file.setType(html5File.getType());
index 962f458230bf522658dcd7dfd4de42f50c837592..b03620c3b10ef45e8970243719bfc45b8f3f29de 100644 (file)
@@ -10,10 +10,10 @@ import com.vaadin.event.dd.DropHandler;
 import com.vaadin.event.dd.acceptcriteria.AcceptAll;
 import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
 import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.StreamVariable.StreamingEndedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingFailedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingProgressedEvent;
-import com.vaadin.terminal.StreamVariable.StreamingStartedEvent;
+import com.vaadin.terminal.StreamVariable.StreamingEndEvent;
+import com.vaadin.terminal.StreamVariable.StreamingErrorEvent;
+import com.vaadin.terminal.StreamVariable.StreamingProgressEvent;
+import com.vaadin.terminal.StreamVariable.StreamingStartEvent;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.CssLayout;
@@ -73,27 +73,27 @@ public class DragAndDropFiles extends TestBase {
                             }
 
                             public void onProgress(
-                                    StreamingProgressedEvent event) {
+                                    StreamingProgressEvent event) {
                                 System.err.println("Progress"
                                         + event.getBytesReceived());
                             }
 
                             public void streamingStarted(
-                                    StreamingStartedEvent event) {
+                                    StreamingStartEvent event) {
                                 getMainWindow().showNotification(
                                         "Started uploading "
                                                 + event.getFileName());
                             }
 
                             public void streamingFinished(
-                                    StreamingEndedEvent event) {
+                                    StreamingEndEvent event) {
                                 getMainWindow().showNotification(
                                         "Finished uploading "
                                                 + event.getFileName());
                             }
 
                             public void streamingFailed(
-                                    StreamingFailedEvent event) {
+                                    StreamingErrorEvent event) {
                                 getMainWindow().showNotification(
                                         "Failed uploading "
                                                 + event.getFileName());
@@ -103,7 +103,7 @@ public class DragAndDropFiles extends TestBase {
                                 return false;
                             }
                         };
-                        file.setReceiver(streamVariable);
+                        file.setStreamVariable(streamVariable);
                     }
                 }
 
index 5261272bee8b3fa15269a8d14f198934f938f7fb..1b7b7b997b814a72fec22b900726ce10cdf18ca5 100644 (file)
@@ -90,7 +90,6 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler {
                     root.getPosition(component).setLeftValue(
                             Float.valueOf(clientX - left));
                 } catch (Exception e) {
-                    // TODO: handle exception
                 }
             } else {
                 // drag started and ended inside the this Pane
@@ -133,7 +132,7 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler {
             if (files != null) {
                 for (Html5File html5File : files) {
                     l.setCaption(html5File.getFileName());
-                    html5File.setReceiver(new StreamVariable() {
+                    html5File.setStreamVariable(new StreamVariable() {
                         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 
                         public OutputStream getOutputStream() {
@@ -141,32 +140,24 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler {
                         }
 
                         public boolean listenProgress() {
-                            // TODO Auto-generated method stub
                             return false;
                         }
 
-                        public void onProgress(StreamingProgressedEvent event) {
-                            // TODO Auto-generated method stub
-
+                        public void onProgress(StreamingProgressEvent event) {
                         }
 
-                        public void streamingStarted(StreamingStartedEvent event) {
-                            // TODO Auto-generated method stub
-
+                        public void streamingStarted(StreamingStartEvent event) {
                         }
 
-                        public void streamingFinished(StreamingEndedEvent event) {
+                        public void streamingFinished(StreamingEndEvent event) {
                             l.setValue((new String(byteArrayOutputStream
                                     .toByteArray()).substring(0, 80) + "..."));
                         }
 
-                        public void streamingFailed(StreamingFailedEvent event) {
-                            // TODO Auto-generated method stub
-
+                        public void streamingFailed(StreamingErrorEvent event) {
                         }
 
                         public boolean isInterrupted() {
-                            // TODO Auto-generated method stub
                             return false;
                         }
                     });