diff options
author | Artur Signell <artur@vaadin.com> | 2013-08-19 12:37:52 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-08-19 12:37:52 +0300 |
commit | acc12f857d04d9b341dec700ffa469ca96d30ad8 (patch) | |
tree | 43e4583b45f1ef96d9fc2919746c56f8dfff7317 /server | |
parent | 1420d23cef01bbc4e07dba693fe4717b531cd951 (diff) | |
parent | 99c7d0b3cde116bf31b00bd31f62f9f4920b1762 (diff) | |
download | vaadin-framework-acc12f857d04d9b341dec700ffa469ca96d30ad8.tar.gz vaadin-framework-acc12f857d04d9b341dec700ffa469ca96d30ad8.zip |
Merge changes from origin/7.1
7cb49d1 Fix invisible calendar actions menu #12181
44aacf4 Clarify Embedded javadoc (#12290)
59a043b Fix actions in action menu appearing in random order #12250
5d57129 Fix calendar click events on context menu #12297
f5e3663 Document multiple load semantics in @StyleSheet and @JavaScript (#12200)
17bb700 Add optional OSGi Import-Package for javax.validation (#12301)
ea148c8 Disable all logging if production mode is enabled (#12299)
326bbb5 Fixes parsing of multiple push messages in streaming mode (#12197)
7fc1054 Ensure StringToIntegerConverter rejects values outside range of int (#12230)
f587298 Improve URI fragment listener javadocs (#12296)
d97cfbc Refine handling of null and empty URI fragments (#12207)
99c7d0b Show tooltips for ordered layout captions (#10046)
Change-Id: Ifb2e0131fde769e2620b7ba03755a5ba324d8aaf
Diffstat (limited to 'server')
-rw-r--r-- | server/build.xml | 2 | ||||
-rw-r--r-- | server/ivy.xml | 3 | ||||
-rw-r--r-- | server/src/com/vaadin/annotations/JavaScript.java | 14 | ||||
-rw-r--r-- | server/src/com/vaadin/annotations/StyleSheet.java | 14 | ||||
-rw-r--r-- | server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java | 17 | ||||
-rw-r--r-- | server/src/com/vaadin/server/Page.java | 67 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Calendar.java | 10 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Embedded.java | 16 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java | 11 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java | 18 |
10 files changed, 147 insertions, 25 deletions
diff --git a/server/build.xml b/server/build.xml index 057f65a0d3..98ee2342cf 100644 --- a/server/build.xml +++ b/server/build.xml @@ -23,7 +23,7 @@ </union> <target name="jar"> - <property name="server.osgi.import" value="javax.servlet;version="2.4.0",javax.servlet.http;version="2.4.0",org.jsoup;version="1.6.3",org.jsoup.parser;version="1.6.3",org.jsoup.nodes;version="1.6.3",org.jsoup.helper;version="1.6.3",org.jsoup.safety;version="1.6.3",org.json;version="0.0.20080701"" /> + <property name="server.osgi.import" value="javax.servlet;version="2.4.0",javax.servlet.http;version="2.4.0",javax.validation;version="1.0.0.GA";resolution:=optional,org.jsoup;version="1.6.3",org.jsoup.parser;version="1.6.3",org.jsoup.nodes;version="1.6.3",org.jsoup.helper;version="1.6.3",org.jsoup.safety;version="1.6.3",org.json;version="0.0.20080701"" /> <property name="server.osgi.require" value="com.vaadin.shared;bundle-version="${vaadin.version}",com.vaadin.push;bundle-version="${vaadin.version}";resolution:=optional" /> <antcall target="common.jar"> <param name="require-bundle" value="${server.osgi.require}" /> diff --git a/server/ivy.xml b/server/ivy.xml index db7e953371..b78541c52f 100644 --- a/server/ivy.xml +++ b/server/ivy.xml @@ -25,6 +25,7 @@ <!-- Liferay Portal Service --> <dependency org="com.liferay.portal" name="portal-service" rev="6.0.2" conf="build-provided,ide -> default" /> + <!--Servlet API version 2.4 --> <dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="build-provided,ide,test -> default" /> @@ -36,6 +37,8 @@ <!-- Google App Engine --> <dependency org="com.google.appengine" name="appengine-api-1.0-sdk" rev="1.2.1" conf="build-provided,ide,test -> default" /> + + <!-- Bean Validation API --> <dependency org="javax.validation" name="validation-api" rev="1.0.0.GA" conf="build-provided,ide,test -> default" /> diff --git a/server/src/com/vaadin/annotations/JavaScript.java b/server/src/com/vaadin/annotations/JavaScript.java index f2085556c7..bdba70c095 100644 --- a/server/src/com/vaadin/annotations/JavaScript.java +++ b/server/src/com/vaadin/annotations/JavaScript.java @@ -29,9 +29,21 @@ import com.vaadin.server.ClientConnector; * method for the corresponding client-side connector is invoked. * <p> * Absolute URLs including protocol and host are used as is on the client-side. - * Relative urls are mapped to APP/PUBLISHED/[url] which are by default served + * Relative URLs are mapped to APP/PUBLISHED/[url] which are by default served * from the classpath relative to the class where the annotation is defined. * <p> + * The file is only loaded if it has not already been loaded, determined as + * follows: + * <ul> + * <li>For absolute URLs, the URL is considered loaded if the same URL has + * previously been loaded using {@code @JavaScript} or if a script tag loaded + * from the same URL was present in the DOM when the Vaadin client-side was + * initialized. + * <li>For relative URLs, the URL is considered loaded if another file with the + * same name has already been loaded using {@code @JavaScript}, even if that + * file was loaded from a different folder. + * </ul> + * <p> * 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 diff --git a/server/src/com/vaadin/annotations/StyleSheet.java b/server/src/com/vaadin/annotations/StyleSheet.java index 2e15d9481c..6540633f8f 100644 --- a/server/src/com/vaadin/annotations/StyleSheet.java +++ b/server/src/com/vaadin/annotations/StyleSheet.java @@ -29,9 +29,21 @@ import com.vaadin.server.ClientConnector; * method for the corresponding client-side connector is invoked. * <p> * Absolute URLs including protocol and host are used as is on the client-side. - * Relative urls are mapped to APP/PUBLISHED/[url] which are by default served + * Relative URLs are mapped to APP/PUBLISHED/[url] which are by default served * from the classpath relative to the class where the annotation is defined. * <p> + * The file is only loaded if it has not already been loaded, determined as + * follows: + * <ul> + * <li>For absolute URLs, the URL is considered loaded if the same URL has + * previously been loaded using {@code StyleSheet} or if a + * {@code <link rel="stylesheet">} tag using the same URL was present in the DOM + * when the Vaadin client-side was initialized. + * <li>For relative URLs, the URL is considered loaded if another file with the + * same name has already been loaded using {@code StyleSheet}, even if that file + * was loaded from a different folder. + * </ul> + * <p> * Special Vaadin urls are also supported. The most useful is vaadin:// which * maps to the location of the automatically published VAADIN folder. Using the * VAADIN folder and vaadin:// you can publish stylesheets which use images or diff --git a/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java b/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java index bc436112fe..f6f668ad4d 100644 --- a/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java +++ b/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java @@ -62,7 +62,22 @@ public class StringToIntegerConverter extends Class<? extends Integer> targetType, Locale locale) throws ConversionException { Number n = convertToNumber(value, targetType, locale); - return n == null ? null : n.intValue(); + + if (n == null) { + return null; + } + + int intValue = n.intValue(); + if (intValue == n.longValue()) { + // If the value of n is outside the range of long, the return value + // of longValue() is either Long.MIN_VALUE or Long.MAX_VALUE. The + // above comparison promotes int to long and thus does not need to + // consider wrap-around. + return intValue; + } + + throw new ConversionException("Could not convert '" + value + "' to " + + Integer.class.getName() + ": value out of range"); } diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index 4c19d28b9c..5c8b1aeb42 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -244,9 +244,23 @@ public class Page implements Serializable { public static final BorderStyle BORDER_DEFAULT = BorderStyle.DEFAULT; /** - * Listener that listens to changes in URI fragment. + * Listener that that gets notified when the URI fragment of the page + * changes. + * + * @see Page#addUriFragmentChangedListener(UriFragmentChangedListener) */ public interface UriFragmentChangedListener extends Serializable { + /** + * Event handler method invoked when the URI fragment of the page + * changes. Please note that the initial URI fragment has already been + * set when a new UI is initialized, so there will not be any initial + * event for listeners added during {@link UI#init(VaadinRequest)}. + * + * @see Page#addUriFragmentChangedListener(UriFragmentChangedListener) + * + * @param event + * the URI fragment changed event + */ public void uriFragmentChanged(UriFragmentChangedEvent event); } @@ -267,12 +281,14 @@ public class Page implements Serializable { private List<Notification> notifications; /** - * Event fired when uri fragment changes. + * Event fired when the URI fragment of a <code>Page</code> changes. + * + * @see Page#addUriFragmentChangedListener(UriFragmentChangedListener) */ public static class UriFragmentChangedEvent extends EventObject { /** - * The new uri fragment + * The new URI fragment */ private final String uriFragment; @@ -281,6 +297,8 @@ public class Page implements Serializable { * * @param source * the Source of the event. + * @param uriFragment + * the new uriFragment */ public UriFragmentChangedEvent(Page source, String uriFragment) { super(source); @@ -288,16 +306,16 @@ public class Page implements Serializable { } /** - * Gets the uI in which the fragment has changed. + * Gets the page in which the fragment has changed. * - * @return the uI in which the fragment has changed + * @return the page in which the fragment has changed */ public Page getPage() { return (Page) getSource(); } /** - * Get the new fragment + * Get the new URI fragment * * @return the new fragment */ @@ -478,6 +496,19 @@ public class Page implements Serializable { } } + /** + * Adds a listener that gets notified every time the URI fragment of this + * page is changed. Please note that the initial URI fragment has already + * been set when a new UI is initialized, so there will not be any initial + * event for listeners added during {@link UI#init(VaadinRequest)}. + * + * @see #getUriFragment() + * @see #setUriFragment(String) + * @see #removeUriFragmentChangedListener(UriFragmentChangedListener) + * + * @param listener + * the URI fragment listener to add + */ public void addUriFragmentChangedListener( Page.UriFragmentChangedListener listener) { addListener(UriFragmentChangedEvent.class, listener, @@ -493,6 +524,14 @@ public class Page implements Serializable { addUriFragmentChangedListener(listener); } + /** + * Removes a URI fragment listener that was previously added to this page. + * + * @param listener + * the URI fragment listener to remove + * + * @see Page#addUriFragmentChangedListener(UriFragmentChangedListener) + */ public void removeUriFragmentChangedListener( Page.UriFragmentChangedListener listener) { removeListener(UriFragmentChangedEvent.class, listener, @@ -515,14 +554,15 @@ public class Page implements Serializable { * The fragment is the optional last component of a URI, prefixed with a * hash sign ("#"). * <p> - * Passing <code>null</code> as <code>newFragment</code> clears the fragment - * (no "#" in the URI); passing an empty string sets an empty fragment (a - * trailing "#" in the URI.) This is consistent with the semantics of - * {@link java.net.URI}. + * Passing an empty string as <code>newFragment</code> sets an empty + * fragment (a trailing "#" in the URI.) Passing <code>null</code> if there + * is already a non-null fragment will leave a trailing # in the URI since + * removing it would cause the browser to reload the page. This is not fully + * consistent with the semantics of {@link java.net.URI}. * * @param newUriFragment * The new fragment. - * @param fireEvent + * @param fireEvents * true to fire event * * @see #getUriFragment() @@ -533,6 +573,11 @@ public class Page implements Serializable { */ public void setUriFragment(String newUriFragment, boolean fireEvents) { String oldUriFragment = location.getFragment(); + if (newUriFragment == null && getUriFragment() != null) { + // Can't completely remove the fragment once it has been set, will + // instead set it to the empty string + newUriFragment = ""; + } if (newUriFragment == oldUriFragment || (newUriFragment != null && newUriFragment .equals(oldUriFragment))) { diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java index c3385baa2c..9ccc8ea2d9 100644 --- a/server/src/com/vaadin/ui/Calendar.java +++ b/server/src/com/vaadin/ui/Calendar.java @@ -26,7 +26,7 @@ import java.util.Date; import java.util.EventListener; import java.util.GregorianCalendar; import java.util.HashMap; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Locale; @@ -535,6 +535,7 @@ public class Calendar extends AbstractComponent implements // Get day start and end times Date start = cal.getTime(); cal.add(java.util.Calendar.DATE, 1); + cal.add(java.util.Calendar.SECOND, -1); Date end = cal.getTime(); boolean monthView = (durationInDays > 7); @@ -572,7 +573,7 @@ public class Calendar extends AbstractComponent implements CalendarDateRange range = new CalendarDateRange(s, e, getTimeZone()); Action[] actions = actionHandler.getActions(range, this); if (actions != null) { - Set<Action> actionSet = new HashSet<Action>( + Set<Action> actionSet = new LinkedHashSet<Action>( Arrays.asList(actions)); actionMap.put(range, actionSet); } @@ -586,7 +587,8 @@ public class Calendar extends AbstractComponent implements getTimeZone()); Action[] actions = actionHandler.getActions(range, this); if (actions != null) { - Set<Action> actionSet = new HashSet<Action>(Arrays.asList(actions)); + Set<Action> actionSet = new LinkedHashSet<Action>( + Arrays.asList(actions)); actionMap.put(range, actionSet); } } @@ -1871,4 +1873,4 @@ public class Calendar extends AbstractComponent implements dropHandler.getAcceptCriterion().paint(target); } } -}
\ No newline at end of file +} diff --git a/server/src/com/vaadin/ui/Embedded.java b/server/src/com/vaadin/ui/Embedded.java index c9b64af415..53354db0f4 100644 --- a/server/src/com/vaadin/ui/Embedded.java +++ b/server/src/com/vaadin/ui/Embedded.java @@ -31,13 +31,17 @@ import com.vaadin.shared.ui.embedded.EmbeddedConstants; import com.vaadin.shared.ui.embedded.EmbeddedServerRpc; /** - * Component for embedding external objects. + * A component for embedding external objects. * <p> - * As of Vaadin 7.0, the {@link Image}, {@link Flash}, and {@link BrowserFrame} - * components should be used instead of <code>Embedded</code> for displaying - * images, Adobe Flash objects, and embedded web pages, respectively. - * <code>Embedded</code> is still useful for displaying other multimedia content - * such as applets and PDF documents. + * The {@code Embedded} component is used to display various types of multimedia + * content using the HTML {@code <object>} element. This includes PDF documents, + * Java applets, and QuickTime videos. Installing a browser plug-in is usually + * required to actually view the embedded content. + * <p> + * Note that before Vaadin 7, {@code Embedded} was also used to display images, + * Adobe Flash objects, and embedded web pages. This use of the component is + * deprecated in Vaadin 7; the {@link Image}, {@link Flash}, and + * {@link BrowserFrame} components should be used instead, respectively. * * @see Video * @see Audio diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java b/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java index 01b766a6db..b78fda3136 100644 --- a/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java +++ b/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java @@ -83,4 +83,15 @@ public class CalendarDateRange implements Serializable { return date.compareTo(start) >= 0 && date.compareTo(end) <= 0; } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CalendarDateRange [start=" + start + ", end=" + end + "]"; + } + } diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java index c73853578e..e810106631 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java @@ -2,6 +2,7 @@ package com.vaadin.tests.data.converter; import junit.framework.TestCase; +import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.StringToIntegerConverter; public class TestStringToIntegerConverter extends TestCase { @@ -16,6 +17,23 @@ public class TestStringToIntegerConverter extends TestCase { assertEquals(null, converter.convertToModel("", Integer.class, null)); } + public void testValueOutOfRange() { + Double[] values = new Double[] { Integer.MAX_VALUE * 2.0, + Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, + Long.MIN_VALUE * 2.0 }; + + boolean accepted = false; + for (Number value : values) { + try { + converter.convertToModel(String.format("%.0f", value), + Integer.class, null); + accepted = true; + } catch (ConversionException expected) { + } + } + assertFalse("Accepted value outside range of int", accepted); + } + public void testValueConversion() { assertEquals(Integer.valueOf(10), converter.convertToModel("10", Integer.class, null)); |