diff options
author | Henrik Paul <henrik@vaadin.com> | 2015-03-12 16:03:15 +0200 |
---|---|---|
committer | Henrik Paul <henrik@vaadin.com> | 2015-03-12 16:03:33 +0200 |
commit | f61cf666f3d28ac57b6c3cd5de30d9b54814d683 (patch) | |
tree | 939c0e8a2cc4fbca39b458f39c37dd6a898a0f08 /server/src | |
parent | f31a927acb4168497f6f25ab68120dd9fa03e636 (diff) | |
parent | 5692572146f7029c51b129ff30c89dd30d9c788d (diff) | |
download | vaadin-framework-f61cf666f3d28ac57b6c3cd5de30d9b54814d683.tar.gz vaadin-framework-f61cf666f3d28ac57b6c3cd5de30d9b54814d683.zip |
Merge branch 'master' into detailsrow
Change-Id: Ie0556ae8d56596d5e1894b3a62d39b0afe13b5a3
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/com/vaadin/server/Constants.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/server/DownloadStream.java | 30 | ||||
-rw-r--r-- | server/src/com/vaadin/server/FileDownloader.java | 6 | ||||
-rw-r--r-- | server/src/com/vaadin/server/communication/AtmospherePushConnection.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/server/communication/PushHandler.java | 20 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Flash.java | 10 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Slider.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/declarative/DesignContext.java | 21 |
9 files changed, 39 insertions, 56 deletions
diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java index b9a43a98de..b7c2a1ff3e 100644 --- a/server/src/com/vaadin/server/Constants.java +++ b/server/src/com/vaadin/server/Constants.java @@ -67,7 +67,7 @@ public interface Constants { // Keep the version number in sync with push/build.xml and other locations // listed in that file - static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.2.4.vaadin4"; + static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.2.4.vaadin5"; static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n" + "=================================================================\n" diff --git a/server/src/com/vaadin/server/DownloadStream.java b/server/src/com/vaadin/server/DownloadStream.java index 8b2b933bcc..681c438967 100644 --- a/server/src/com/vaadin/server/DownloadStream.java +++ b/server/src/com/vaadin/server/DownloadStream.java @@ -20,8 +20,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -282,9 +280,16 @@ public class DownloadStream implements Serializable { } } - // Content-Disposition: attachment generally forces download - response.setHeader("Content-Disposition", - getContentDispositionValue()); + // suggest local filename from DownloadStream if + // Content-Disposition + // not explicitly set + String contentDispositionValue = getParameter("Content-Disposition"); + if (contentDispositionValue == null) { + contentDispositionValue = "filename=\"" + getFileName() + + "\""; + response.setHeader("Content-Disposition", + contentDispositionValue); + } int bufferSize = getBufferSize(); if (bufferSize <= 0 || bufferSize > Constants.MAX_BUFFER_SIZE) { @@ -312,21 +317,6 @@ public class DownloadStream implements Serializable { } } - private String getContentDispositionValue() - throws UnsupportedEncodingException { - String contentDispositionValue = getParameter("Content-Disposition"); - - if (contentDispositionValue == null) { - String encodedFilename = URLEncoder.encode(getFileName(), "utf-8"); - - contentDispositionValue = String.format( - "attachment; filename=\"%s\"; filename*=utf-8''%s", - encodedFilename, encodedFilename); - } - - return contentDispositionValue; - } - /** * Helper method that tries to close an output stream and ignores any * exceptions. diff --git a/server/src/com/vaadin/server/FileDownloader.java b/server/src/com/vaadin/server/FileDownloader.java index bea9922c50..42c2f76e1a 100644 --- a/server/src/com/vaadin/server/FileDownloader.java +++ b/server/src/com/vaadin/server/FileDownloader.java @@ -141,6 +141,12 @@ public class FileDownloader extends AbstractExtension { } stream = ((ConnectorResource) resource).getStream(); + if (stream.getParameter("Content-Disposition") == null) { + // Content-Disposition: attachment generally forces download + stream.setParameter("Content-Disposition", + "attachment; filename=\"" + stream.getFileName() + "\""); + } + // Content-Type to block eager browser plug-ins from hijacking // the file if (isOverrideContentType()) { diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index ab45fcfe89..357278f411 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -311,7 +311,7 @@ public class AtmospherePushConnection implements PushConnection { /** * Called when the connection to the client has been lost. * - * @since + * @since 7.4.1 */ public void connectionLost() { resource = null; diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index 22eee70aa0..c570d22086 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -470,23 +470,9 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter { */ private static void sendRefreshAndDisconnect(AtmosphereResource resource) throws IOException { - if (resource instanceof AtmosphereResourceImpl - && !((AtmosphereResourceImpl) resource).isInScope()) { - // The resource is no longer valid so we should not write - // anything to it - getLogger() - .fine("sendRefreshAndDisconnect called for resource no longer in scope"); - return; - } - - AtmospherePushConnection connection = new AtmospherePushConnection(null); - connection.connect(resource); - try { - connection.sendMessage(VaadinService - .createCriticalNotificationJSON(null, null, null, null)); - } finally { - connection.disconnect(); - } + sendNotificationAndDisconnect(resource, + VaadinService.createCriticalNotificationJSON(null, null, null, + null)); } /** diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java index cd7c00087e..2d0f188b84 100644 --- a/server/src/com/vaadin/ui/Flash.java +++ b/server/src/com/vaadin/ui/Flash.java @@ -97,7 +97,7 @@ public class Flash extends AbstractEmbedded { * Returns the codebase. * * @see #setCodebase(String) - * @since 7.4 + * @since 7.4.1 * @return Current codebase. */ public String getCodebase() { @@ -126,7 +126,7 @@ public class Flash extends AbstractEmbedded { * Returns the current codetype. * * @see #setCodetype(String) - * @since 7.4 + * @since 7.4.1 * @return Current codetype. */ public String getCodetype() { @@ -157,7 +157,7 @@ public class Flash extends AbstractEmbedded { * Returns current archive. * * @see #setArchive(String) - * @since 7.4 + * @since 7.4.1 * @return Current archive. */ public String getArchive() { @@ -181,7 +181,7 @@ public class Flash extends AbstractEmbedded { /** * Returns standby. * - * @since + * @since 7.4.1 * @return Standby string. */ public String getStandby() { @@ -247,7 +247,7 @@ public class Flash extends AbstractEmbedded { * * @see #setParameter(String, String) * @see #getParameter(String) - * @since 7.4 + * @since 7.4.1 * @return An iterable with declared parameter names. */ public Iterable<String> getParameterNames() { diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index cf0e54156a..22ef0333c2 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -5088,7 +5088,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * but this method can be used to force recalculation in situations when * grid does not recalculate automatically. * - * @since + * @since 7.4.1 */ public void recalculateColumnWidths() { getRpcProxy(GridClientRpc.class).recalculateColumnWidths(); diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index dad4d295bf..fab6e33cae 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -267,7 +267,7 @@ public class Slider extends AbstractField<Double> { if (resolution > 0) { // Round up to resolution - newValue = (int) (v * Math.pow(10, resolution)); + newValue = Math.floor(v * Math.pow(10, resolution)); newValue = newValue / Math.pow(10, resolution); if (getMin() > newValue || getMax() < newValue) { throw new ValueOutOfBoundsException(newValue); diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java index 09fefd0a6b..218774c72d 100644 --- a/server/src/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/com/vaadin/ui/declarative/DesignContext.java @@ -278,16 +278,8 @@ public class DesignContext implements Serializable { Class<? extends Component> componentClass) { Component instance = instanceCache.get(componentClass); if (instance == null) { - try { - instance = componentClass.newInstance(); - instanceCache.put(componentClass, instance); - } catch (InstantiationException e) { - throw new RuntimeException("Could not instantiate " - + componentClass.getName()); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not instantiate " - + componentClass.getName()); - } + instance = instantiateClass(componentClass.getName()); + instanceCache.put(componentClass, instance); } return instance; } @@ -484,6 +476,15 @@ public class DesignContext implements Serializable { // Extract the package and class names. String qualifiedClassName = tagNameToClassName(node); + return instantiateClass(qualifiedClassName); + } + + /** + * Instantiates given class via ComponentFactory. + * @param qualifiedClassName class name to instantiate + * @return instance of a given class + */ + private Component instantiateClass(String qualifiedClassName) { ComponentFactory factory = Design.getComponentFactory(); Component component = factory.createComponent(qualifiedClassName, this); |