diff options
author | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-26 13:52:08 +0300 |
---|---|---|
committer | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-26 13:52:48 +0300 |
commit | 9d8c26b49b9ef6900fe19745ac995cad5c5b74fc (patch) | |
tree | 505b6a86b2ed876b6c4bde4c57946ce58971ac09 /server/src/com/vaadin | |
parent | 3065d80e1826bcacd53df1a4a214318253697272 (diff) | |
parent | f7a852e3df45437568e54cff592aae50ae9a06ce (diff) | |
download | vaadin-framework-9d8c26b49b9ef6900fe19745ac995cad5c5b74fc.tar.gz vaadin-framework-9d8c26b49b9ef6900fe19745ac995cad5c5b74fc.zip |
Merge branch 'master' into grid-unbuffered-editor
Change-Id: I82cdb7a08a62679b4717d480b50ab951ade8855c
Diffstat (limited to 'server/src/com/vaadin')
19 files changed, 124 insertions, 77 deletions
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index f07b7ecc58..86e9069e90 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -1279,7 +1279,7 @@ public class SQLContainer implements Container, Container.Filterable, } /** - * Fetches a page from the data source based on the values of pageLenght and + * Fetches a page from the data source based on the values of pageLength and * currentOffset. Also updates the set of primary keys, used in * identification of RowItems. */ diff --git a/server/src/com/vaadin/server/ClientConnector.java b/server/src/com/vaadin/server/ClientConnector.java index b784aa5d35..63483bc254 100644 --- a/server/src/com/vaadin/server/ClientConnector.java +++ b/server/src/com/vaadin/server/ClientConnector.java @@ -256,10 +256,6 @@ public interface ClientConnector extends Connector { * client. Gives the connector an opportunity to set computed/dynamic state * values or to invoke last minute RPC methods depending on other component * features. - * <p> - * This method must not alter the component hierarchy in any way. Calling - * {@link #markAsDirty()} from this method will have no effect. - * </p> * * @param initial * <code>true</code> if the client-side connector will be created diff --git a/server/src/com/vaadin/server/ComponentSizeValidator.java b/server/src/com/vaadin/server/ComponentSizeValidator.java index 1fbd840932..71023782ef 100644 --- a/server/src/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/com/vaadin/server/ComponentSizeValidator.java @@ -598,6 +598,12 @@ public class ComponentSizeValidator implements Serializable { if (parent == null) { return false; } else if (parent.getWidth() < 0) { + if (parent instanceof Window) { + // Window has some weird haxxors to support 100% children when + // window is -1 + return false; + } + return true; } else if (parent.getWidthUnits() == Unit.PERCENTAGE) { return isEffectiveUndefinedWidth(parent.getParent()); @@ -615,6 +621,12 @@ public class ComponentSizeValidator implements Serializable { if (parent == null) { return false; } else if (parent.getHeight() < 0) { + if (parent instanceof Window) { + // Window has some weird haxxors to support 100% children when + // window is -1 + return false; + } + return true; } else if (parent.getHeightUnits() == Unit.PERCENTAGE) { return isEffectiveUndefinedHeight(parent.getParent()); diff --git a/server/src/com/vaadin/server/LegacyCommunicationManager.java b/server/src/com/vaadin/server/LegacyCommunicationManager.java index fda5ad444f..e982cdf10a 100644 --- a/server/src/com/vaadin/server/LegacyCommunicationManager.java +++ b/server/src/com/vaadin/server/LegacyCommunicationManager.java @@ -388,17 +388,15 @@ public class LegacyCommunicationManager implements Serializable { } /** - * Handles an exception that occurred when processing RPC calls or a file - * upload. + * Handles an exception related to a connector by invoking the appropriate + * error handler. * * @deprecated As of 7.1. See #11411. * - * @param ui - * The UI where the exception occured * @param throwable - * The exception + * the exception to handle * @param connector - * The Rpc target + * the connector that the exception is related to */ @Deprecated public void handleConnectorRelatedException(ClientConnector connector, diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 74f0051e30..bff71fedee 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -1574,8 +1574,8 @@ public abstract class VaadinService implements Serializable { JsonObject appError = Json.createObject(); putValueOrJsonNull(appError, "caption", caption); putValueOrJsonNull(appError, "url", url); - putValueOrJsonNull(appError, "message", - createCriticalNotificationMessage(message, details)); + putValueOrJsonNull(appError, "message", message); + putValueOrJsonNull(appError, "details", details); JsonObject meta = Json.createObject(); meta.put("appError", appError); @@ -1595,17 +1595,6 @@ public abstract class VaadinService implements Serializable { return "for(;;);[" + returnString + "]"; } - private static String createCriticalNotificationMessage(String message, - String details) { - if (message == null) { - return details; - } else if (details != null) { - return message + "<br/><br/>" + details; - } - - return message; - } - private static void putValueOrJsonNull(JsonObject json, String key, String value) { if (value == null) { diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java index 3b2caba55b..a4797e49aa 100644 --- a/server/src/com/vaadin/server/communication/UidlWriter.java +++ b/server/src/com/vaadin/server/communication/UidlWriter.java @@ -23,7 +23,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,22 +83,44 @@ public class UidlWriter implements Serializable { // to write out service.runPendingAccessTasks(session); - ArrayList<ClientConnector> dirtyVisibleConnectors = ui - .getConnectorTracker().getDirtyVisibleConnectors(); + Set<ClientConnector> processedConnectors = new HashSet<ClientConnector>(); + LegacyCommunicationManager manager = session.getCommunicationManager(); // Paints components ConnectorTracker uiConnectorTracker = ui.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); + while (true) { + ArrayList<ClientConnector> connectorsToProcess = new ArrayList<ClientConnector>(); + for (ClientConnector c : uiConnectorTracker.getDirtyConnectors()) { + if (!processedConnectors.contains(c) + && LegacyCommunicationManager + .isConnectorVisibleToClient(c)) { + connectorsToProcess.add(c); + } + } + + if (connectorsToProcess.isEmpty()) { + break; + } + + for (ClientConnector connector : connectorsToProcess) { + boolean initialized = uiConnectorTracker + .isClientSideInitialized(connector); + processedConnectors.add(connector); + + try { + connector.beforeClientResponse(!initialized); + } catch (RuntimeException e) { + manager.handleConnectorRelatedException(connector, e); + } + } + } + getLogger().log( Level.FINE, - "Found " + dirtyVisibleConnectors.size() + "Found " + processedConnectors.size() + " dirty connectors to paint"); - for (ClientConnector connector : dirtyVisibleConnectors) { - boolean initialized = uiConnectorTracker - .isClientSideInitialized(connector); - connector.beforeClientResponse(!initialized); - } uiConnectorTracker.setWritingResponse(true); try { @@ -292,7 +316,7 @@ public class UidlWriter implements Serializable { session.getDragAndDropService().printJSONResponse(writer); - for (ClientConnector connector : dirtyVisibleConnectors) { + for (ClientConnector connector : processedConnectors) { uiConnectorTracker.markClientSideInitialized(connector); } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 18c3509af7..f499cb1fec 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -1170,16 +1170,16 @@ public abstract class AbstractComponent extends AbstractClientConnector // first try the full shorthands if (widthFull && heightFull) { - attributes.put("size-full", "true"); + attributes.put("size-full", ""); } else if (widthAuto && heightAuto) { - attributes.put("size-auto", "true"); + attributes.put("size-auto", ""); } else { // handle width if (!hasEqualWidth(defaultInstance)) { if (widthFull) { - attributes.put("width-full", "true"); + attributes.put("width-full", ""); } else if (widthAuto) { - attributes.put("width-auto", "true"); + attributes.put("width-auto", ""); } else { String widthString = DesignAttributeHandler.getFormatter() .format(getWidth()) + getWidthUnits().getSymbol(); @@ -1190,9 +1190,9 @@ public abstract class AbstractComponent extends AbstractClientConnector if (!hasEqualHeight(defaultInstance)) { // handle height if (heightFull) { - attributes.put("height-full", "true"); + attributes.put("height-full", ""); } else if (heightAuto) { - attributes.put("height-auto", "true"); + attributes.put("height-auto", ""); } else { String heightString = DesignAttributeHandler.getFormatter() .format(getHeight()) + getHeightUnits().getSymbol(); diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 14c135228c..93025ac0fd 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -126,22 +126,25 @@ public abstract class AbstractTextField extends AbstractField<String> implements selectionPosition = -1; } - target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE, - getTextChangeEventMode().toString()); - target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT, - getTextChangeTimeout()); - if (lastKnownTextContent != null) { - /* - * The field has be repainted for some reason (e.g. caption, size, - * stylename), but the value has not been changed since the last - * text change event. Let the client side know about the value the - * server side knows. Client side may then ignore the actual value, - * depending on its state. - */ - target.addAttribute( - TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS, - true); + if (hasListeners(TextChangeEvent.class)) { + target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE, + getTextChangeEventMode().toString()); + target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT, + getTextChangeTimeout()); + if (lastKnownTextContent != null) { + /* + * The field has be repainted for some reason (e.g. caption, + * size, stylename), but the value has not been changed since + * the last text change event. Let the client side know about + * the value the server side knows. Client side may then ignore + * the actual value, depending on its state. + */ + target.addAttribute( + TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS, + true); + } } + } @Override diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index b0542352b9..64f26b6205 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -3627,6 +3627,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, private final Footer footer = new Footer(this); private Object editedItemId = null; + private boolean editorActive = false; private FieldGroup editorFieldGroup = new CustomFieldGroup(); private CellStyleGenerator cellStyleGenerator; @@ -5803,7 +5804,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, * @return true iff the editor is open */ public boolean isEditorActive() { - return editedItemId != null; + return editorActive; } private void checkColumnExists(Object propertyId) { @@ -5878,6 +5879,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, .getPropertyId()); } + editorActive = true; // Must ensure that all fields, recursively, are sent to the client // This is needed because the fields are hidden using isRendered for (Field<?> f : getEditorFields()) { @@ -5929,6 +5931,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, protected void doCancelEditor() { editedItemId = null; + editorActive = false; editorFieldGroup.discard(); editorFieldGroup.setItemDataSource(null); } @@ -5946,6 +5949,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, } editedItemId = null; + editorActive = false; editorFieldGroup = new CustomFieldGroup(); } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 6ccb272704..792ad72dcc 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -1319,11 +1319,15 @@ public class GridLayout extends AbstractLayout implements setMargin(readMargin(design, getMargin(), designContext)); - // Prepare a 2D map for reading column contents - Elements rowElements = design.getElementsByTag("row"); + List<Element> rowElements = new ArrayList<Element>(); List<Map<Integer, Component>> rows = new ArrayList<Map<Integer, Component>>(); - for (int i = 0; i < rowElements.size(); ++i) { - rows.add(new HashMap<Integer, Component>()); + // Prepare a 2D map for reading column contents + for (Element e : design.children()) { + if (e.tagName().equalsIgnoreCase("row")) { + rowElements.add(e); + rows.add(new HashMap<Integer, Component>()); + + } } setRows(Math.max(rows.size(), 1)); diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index 2e00628eb0..15c94b6d3c 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -285,7 +285,7 @@ public class Slider extends AbstractField<Double> { final int resolution = getResolution(); double ratio = Math.pow(10, resolution); - if(v >= 0) { + if (v >= 0) { return Math.floor(v * ratio) / ratio; } else { return Math.ceil(v * ratio) / ratio; diff --git a/server/src/com/vaadin/ui/declarative/DesignFormatter.java b/server/src/com/vaadin/ui/declarative/DesignFormatter.java index b1d2520631..73c45caed4 100644 --- a/server/src/com/vaadin/ui/declarative/DesignFormatter.java +++ b/server/src/com/vaadin/ui/declarative/DesignFormatter.java @@ -94,7 +94,11 @@ public class DesignFormatter implements Serializable { public String convertToPresentation(Boolean value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { - return String.valueOf(value.booleanValue()); + if (value.booleanValue()) { + return ""; + } else { + return "false"; + } } @Override diff --git a/server/src/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java b/server/src/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java index 104e07f02f..57e8130b29 100644 --- a/server/src/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java +++ b/server/src/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java @@ -105,7 +105,8 @@ public abstract class AbstractJavaScriptRenderer<T> extends AbstractRenderer<T> private JavaScriptCallbackHelper callbackHelper = new JavaScriptCallbackHelper( this); - protected AbstractJavaScriptRenderer(Class<T> presentationType, String nullRepresentation) { + protected AbstractJavaScriptRenderer(Class<T> presentationType, + String nullRepresentation) { super(presentationType, nullRepresentation); } diff --git a/server/src/com/vaadin/ui/renderers/ButtonRenderer.java b/server/src/com/vaadin/ui/renderers/ButtonRenderer.java index a747e45713..e7e723ebd6 100644 --- a/server/src/com/vaadin/ui/renderers/ButtonRenderer.java +++ b/server/src/com/vaadin/ui/renderers/ButtonRenderer.java @@ -45,7 +45,8 @@ public class ButtonRenderer extends ClickableRenderer<String> { * @param nullRepresentation * the textual representation of {@code null} value */ - public ButtonRenderer(RendererClickListener listener, String nullRepresentation) { + public ButtonRenderer(RendererClickListener listener, + String nullRepresentation) { this(nullRepresentation); addClickListener(listener); } diff --git a/server/src/com/vaadin/ui/renderers/ClickableRenderer.java b/server/src/com/vaadin/ui/renderers/ClickableRenderer.java index 01e939bb67..7210eb7840 100644 --- a/server/src/com/vaadin/ui/renderers/ClickableRenderer.java +++ b/server/src/com/vaadin/ui/renderers/ClickableRenderer.java @@ -106,7 +106,8 @@ public class ClickableRenderer<T> extends AbstractRenderer<T> { this(presentationType, null); } - protected ClickableRenderer(Class<T> presentationType, String nullRepresentation) { + protected ClickableRenderer(Class<T> presentationType, + String nullRepresentation) { super(presentationType, nullRepresentation); registerRpc(new RendererClickRpc() { @Override diff --git a/server/src/com/vaadin/ui/renderers/DateRenderer.java b/server/src/com/vaadin/ui/renderers/DateRenderer.java index 092b3f405e..dddeb6cd77 100644 --- a/server/src/com/vaadin/ui/renderers/DateRenderer.java +++ b/server/src/com/vaadin/ui/renderers/DateRenderer.java @@ -72,7 +72,8 @@ public class DateRenderer extends AbstractRenderer<Date> { * @throws IllegalArgumentException * if {@code locale} is {@code null} */ - public DateRenderer(Locale locale, String nullRepresentation) throws IllegalArgumentException { + public DateRenderer(Locale locale, String nullRepresentation) + throws IllegalArgumentException { this("%s", locale, nullRepresentation); } @@ -110,7 +111,8 @@ public class DateRenderer extends AbstractRenderer<Date> { * href="http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax">Format * String Syntax</a> */ - public DateRenderer(String formatString, String nullRepresentation) throws IllegalArgumentException { + public DateRenderer(String formatString, String nullRepresentation) + throws IllegalArgumentException { this(formatString, Locale.getDefault(), nullRepresentation); } @@ -132,8 +134,9 @@ public class DateRenderer extends AbstractRenderer<Date> { */ public DateRenderer(String formatString, Locale locale) throws IllegalArgumentException { - this(formatString,locale, ""); + this(formatString, locale, ""); } + /** * Creates a new date renderer. * <p> @@ -152,8 +155,8 @@ public class DateRenderer extends AbstractRenderer<Date> { * href="http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax">Format * String Syntax</a> */ - public DateRenderer(String formatString, Locale locale, String nullRepresentation) - throws IllegalArgumentException { + public DateRenderer(String formatString, Locale locale, + String nullRepresentation) throws IllegalArgumentException { super(Date.class, nullRepresentation); if (formatString == null) { @@ -182,6 +185,7 @@ public class DateRenderer extends AbstractRenderer<Date> { public DateRenderer(DateFormat dateFormat) throws IllegalArgumentException { this(dateFormat, ""); } + /** * Creates a new date renderer. * <p> @@ -192,7 +196,8 @@ public class DateRenderer extends AbstractRenderer<Date> { * @throws IllegalArgumentException * if {@code dateFormat} is {@code null} */ - public DateRenderer(DateFormat dateFormat, String nullRepresentation) throws IllegalArgumentException { + public DateRenderer(DateFormat dateFormat, String nullRepresentation) + throws IllegalArgumentException { super(Date.class, nullRepresentation); if (dateFormat == null) { throw new IllegalArgumentException("date format may not be null"); diff --git a/server/src/com/vaadin/ui/renderers/HtmlRenderer.java b/server/src/com/vaadin/ui/renderers/HtmlRenderer.java index df89c60ad2..2ec43800c0 100644 --- a/server/src/com/vaadin/ui/renderers/HtmlRenderer.java +++ b/server/src/com/vaadin/ui/renderers/HtmlRenderer.java @@ -28,7 +28,8 @@ public class HtmlRenderer extends AbstractRenderer<String> { /** * Creates a new HTML renderer. * - * @param nullRepresentation the html representation of {@code null} value + * @param nullRepresentation + * the html representation of {@code null} value */ public HtmlRenderer(String nullRepresentation) { super(String.class, nullRepresentation); diff --git a/server/src/com/vaadin/ui/renderers/NumberRenderer.java b/server/src/com/vaadin/ui/renderers/NumberRenderer.java index 1d4d7e0ec9..b1ba309c9a 100644 --- a/server/src/com/vaadin/ui/renderers/NumberRenderer.java +++ b/server/src/com/vaadin/ui/renderers/NumberRenderer.java @@ -69,7 +69,7 @@ public class NumberRenderer extends AbstractRenderer<Number> { * @param nullRepresentation * the textual representation of {@code null} value * @throws IllegalArgumentException - * if {@code numberFormat} is {@code null} + * if {@code numberFormat} is {@code null} */ public NumberRenderer(NumberFormat numberFormat, String nullRepresentation) throws IllegalArgumentException { @@ -112,8 +112,10 @@ public class NumberRenderer extends AbstractRenderer<Number> { * @throws IllegalArgumentException * if {@code locale} is {@code null} */ - public NumberRenderer(String formatString, Locale locale) throws IllegalArgumentException { - this(formatString, locale, ""); //This will call #toString() during formatting + public NumberRenderer(String formatString, Locale locale) + throws IllegalArgumentException { + this(formatString, locale, ""); // This will call #toString() during + // formatting } /** @@ -122,8 +124,8 @@ public class NumberRenderer extends AbstractRenderer<Number> { * The renderer is configured to render with the given format string in the * default locale. * - * @param - * formatString the format string with which to format the number + * @param formatString + * the format string with which to format the number * @throws IllegalArgumentException * if {@code formatString} is {@code null} * @see <a @@ -150,7 +152,8 @@ public class NumberRenderer extends AbstractRenderer<Number> { * href="http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax">Format * String Syntax</a> */ - public NumberRenderer(String formatString, Locale locale, String nullRepresentation) { + public NumberRenderer(String formatString, Locale locale, + String nullRepresentation) { super(Number.class, nullRepresentation); if (formatString == null) { diff --git a/server/src/com/vaadin/ui/renderers/TextRenderer.java b/server/src/com/vaadin/ui/renderers/TextRenderer.java index 0045024b2f..ce8a73d057 100644 --- a/server/src/com/vaadin/ui/renderers/TextRenderer.java +++ b/server/src/com/vaadin/ui/renderers/TextRenderer.java @@ -35,6 +35,7 @@ public class TextRenderer extends AbstractRenderer<String> { /** * Creates a new text renderer + * * @param nullRepresentation * the textual representation of {@code null} value */ |