diff options
Diffstat (limited to 'client')
13 files changed, 109 insertions, 66 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index 4159b38211..1f35c408ae 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -199,6 +199,7 @@ public class ApplicationConfiguration implements EntryPoint { private boolean standalone; private ErrorMessage communicationError; private ErrorMessage authorizationError; + private ErrorMessage sessionExpiredError; private int heartbeatInterval; private HashMap<Integer, String> unknownComponents; @@ -314,6 +315,10 @@ public class ApplicationConfiguration implements EntryPoint { return authorizationError; } + public ErrorMessage getSessionExpiredError() { + return sessionExpiredError; + } + /** * Reads the configuration values defined by the bootstrap javascript. */ @@ -353,6 +358,7 @@ public class ApplicationConfiguration implements EntryPoint { communicationError = jsoConfiguration.getConfigError("comErrMsg"); authorizationError = jsoConfiguration.getConfigError("authErrMsg"); + sessionExpiredError = jsoConfiguration.getConfigError("sessExpMsg"); // boostrap sets initPending to false if it has sent the browser details if (jsoConfiguration.getConfigBoolean("initPending") == Boolean.FALSE) { diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 23906f0e02..48815a3d8d 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -84,7 +84,7 @@ import com.vaadin.client.ui.dd.VDragAndDropManager; import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.client.ui.window.WindowConnector; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.Version; import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; @@ -960,9 +960,7 @@ public class ApplicationConnection { */ protected void showCommunicationError(String details, int statusCode) { VConsole.error("Communication error: " + details); - ErrorMessage communicationError = configuration.getCommunicationError(); - showError(details, communicationError.getCaption(), - communicationError.getMessage(), communicationError.getUrl()); + showError(details, configuration.getCommunicationError()); } /** @@ -973,9 +971,31 @@ public class ApplicationConnection { */ protected void showAuthenticationError(String details) { VConsole.error("Authentication error: " + details); - ErrorMessage authorizationError = configuration.getAuthorizationError(); - showError(details, authorizationError.getCaption(), - authorizationError.getMessage(), authorizationError.getUrl()); + showError(details, configuration.getAuthorizationError()); + } + + /** + * Shows the session expiration notification. + * + * @param details + * Optional details for debugging. + */ + protected void showSessionExpiredError(String details) { + VConsole.error("Session expired: " + details); + showError(details, configuration.getSessionExpiredError()); + } + + /** + * Shows an error notification. + * + * @param details + * Optional details for debugging. + * @param message + * An ErrorMessage describing the error. + */ + protected void showError(String details, ErrorMessage message) { + showError(details, message.getCaption(), message.getMessage(), + message.getUrl()); } /** @@ -1002,9 +1022,11 @@ public class ApplicationConnection { if (html.length() > 0) { // Add error description - html.append("<br/><p><I style=\"font-size:0.7em\">"); - html.append(details); - html.append("</I></p>"); + if (details != null) { + html.append("<p><i style=\"font-size:0.7em\">"); + html.append(details); + html.append("</i></p>"); + } VNotification n = VNotification.createNotification(1000 * 60 * 45, uIConnector.getWidget()); @@ -1442,32 +1464,11 @@ public class ApplicationConnection { if (meta != null) { if (meta.containsKey("appError")) { ValueMap error = meta.getValueMap("appError"); - String html = ""; - if (error.containsKey("caption") - && error.getString("caption") != null) { - html += "<h1>" + error.getAsString("caption") - + "</h1>"; - } - if (error.containsKey("message") - && error.getString("message") != null) { - html += "<p>" + error.getAsString("message") - + "</p>"; - } - String url = null; - if (error.containsKey("url")) { - url = error.getString("url"); - } - if (html.length() != 0) { - /* 45 min */ - VNotification n = VNotification.createNotification( - 1000 * 60 * 45, uIConnector.getWidget()); - n.addEventListener(new NotificationRedirect(url)); - n.show(html, VNotification.CENTERED_TOP, - VNotification.STYLE_SYSTEM); - } else { - redirect(url); - } + showError(null, error.getString("caption"), + error.getString("message"), + error.getString("url")); + applicationRunning = false; } if (validatingLayouts) { @@ -2889,7 +2890,7 @@ public class ApplicationConnection { * @return true if at least one listener has been registered on server side * for the event identified by eventIdentifier. * @deprecated as of Vaadin 7. Use - * {@link ComponentState#hasEventListener(String)} instead + * {@link AbstractComponentState#hasEventListener(String)} instead */ @Deprecated public boolean hasEventListeners(ComponentConnector paintable, @@ -2989,7 +2990,7 @@ public class ApplicationConnection { /** * @deprecated as of Vaadin 7. Use - * {@link ComponentState#hasEventListener(String)} instead + * {@link AbstractComponentState#hasEventListener(String)} instead */ @Deprecated public boolean hasEventListeners(Widget widget, String eventIdentifier) { @@ -3027,7 +3028,7 @@ public class ApplicationConnection { * <p> * Heartbeat requests are used to inform the server that the client-side is * still alive. If the client page is closed or the connection lost, the - * server will eventually close the inactive Root. + * server will eventually close the inactive UI. * <p> * <b>TODO</b>: Improved error handling, like in doUidlRequest(). * @@ -3051,16 +3052,17 @@ public class ApplicationConnection { // TODO Permit retry in some error situations VConsole.log("Heartbeat response OK"); scheduleHeartbeat(); + } else if (status == Response.SC_GONE) { + showSessionExpiredError(null); } else { - VConsole.error("Heartbeat request failed with status code " + VConsole.error("Failed sending heartbeat to server. Error code: " + status); } } @Override public void onError(Request request, Throwable exception) { - VConsole.error("Heartbeat request resulted in exception"); - VConsole.error(exception); + VConsole.error("Exception sending heartbeat: " + exception); } }; diff --git a/client/src/com/vaadin/client/ComponentConnector.java b/client/src/com/vaadin/client/ComponentConnector.java index 9858ff6abd..ae889c1dbd 100644 --- a/client/src/com/vaadin/client/ComponentConnector.java +++ b/client/src/com/vaadin/client/ComponentConnector.java @@ -18,7 +18,7 @@ package com.vaadin.client; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; /** * An interface used by client-side widgets or paintable parts to receive @@ -36,7 +36,7 @@ public interface ComponentConnector extends ServerConnector { * @see com.vaadin.client.VPaintable#getState() */ @Override - public ComponentState getState(); + public AbstractComponentState getState(); /** * Returns the widget for this {@link ComponentConnector} diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index 99f973c467..854c8535c4 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -34,7 +34,7 @@ import com.vaadin.client.ui.VTabsheetPanel; import com.vaadin.client.ui.VUI; import com.vaadin.client.ui.VWindow; import com.vaadin.client.ui.window.WindowConnector; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.SharedState; @@ -694,8 +694,8 @@ public class ComponentLocator { private ServerConnector findConnectorById(ServerConnector root, String id) { SharedState state = root.getState(); - if (state instanceof ComponentState - && id.equals(((ComponentState) state).id)) { + if (state instanceof AbstractComponentState + && id.equals(((AbstractComponentState) state).id)) { return root; } for (ServerConnector child : root.getChildren()) { diff --git a/client/src/com/vaadin/client/MeasuredSize.java b/client/src/com/vaadin/client/MeasuredSize.java index 48585ae7c5..ccc8a5058c 100644 --- a/client/src/com/vaadin/client/MeasuredSize.java +++ b/client/src/com/vaadin/client/MeasuredSize.java @@ -19,6 +19,8 @@ import com.google.gwt.core.client.JsArrayString; import com.google.gwt.dom.client.Element; public class MeasuredSize { + private final static boolean debugSizeChanges = false; + public static class MeasureResult { private final boolean widthChanged; private final boolean heightChanged; @@ -189,46 +191,79 @@ public class MeasuredSize { ComputedStyle computedStyle = new ComputedStyle(element); int[] paddings = computedStyle.getPadding(); if (!heightChanged && hasHeightChanged(this.paddings, paddings)) { + debugSizeChange(element, "Height (padding)", this.paddings, + paddings); heightChanged = true; } if (!widthChanged && hasWidthChanged(this.paddings, paddings)) { + debugSizeChange(element, "Width (padding)", this.paddings, paddings); widthChanged = true; } this.paddings = paddings; int[] margins = computedStyle.getMargin(); if (!heightChanged && hasHeightChanged(this.margins, margins)) { + debugSizeChange(element, "Height (margins)", this.margins, margins); heightChanged = true; } if (!widthChanged && hasWidthChanged(this.margins, margins)) { + debugSizeChange(element, "Width (margins)", this.margins, margins); widthChanged = true; } this.margins = margins; int[] borders = computedStyle.getBorder(); if (!heightChanged && hasHeightChanged(this.borders, borders)) { + debugSizeChange(element, "Height (borders)", this.borders, borders); heightChanged = true; } if (!widthChanged && hasWidthChanged(this.borders, borders)) { + debugSizeChange(element, "Width (borders)", this.borders, borders); widthChanged = true; } this.borders = borders; int requiredHeight = Util.getRequiredHeight(element); int marginHeight = sumHeights(margins); + int oldHeight = height; + int oldWidth = width; if (setOuterHeight(requiredHeight + marginHeight)) { + debugSizeChange(element, "Height (outer)", oldHeight, height); heightChanged = true; } int requiredWidth = Util.getRequiredWidth(element); int marginWidth = sumWidths(margins); if (setOuterWidth(requiredWidth + marginWidth)) { + debugSizeChange(element, "Width (outer)", oldWidth, width); widthChanged = true; } return new MeasureResult(widthChanged, heightChanged); } + private void debugSizeChange(Element element, String sizeChangeType, + int[] changedFrom, int[] changedTo) { + debugSizeChange(element, sizeChangeType, + java.util.Arrays.asList(changedFrom).toString(), + java.util.Arrays.asList(changedTo).toString()); + } + + private void debugSizeChange(Element element, String sizeChangeType, + int changedFrom, int changedTo) { + debugSizeChange(element, sizeChangeType, String.valueOf(changedFrom), + String.valueOf(changedTo)); + } + + private void debugSizeChange(Element element, String sizeChangeType, + String changedFrom, String changedTo) { + if (debugSizeChanges) { + VConsole.log(sizeChangeType + " has changed for " + + element.toString() + " from " + changedFrom + " to " + + changedTo); + } + } + private static boolean hasWidthChanged(int[] sizes1, int[] sizes2) { return sizes1[1] != sizes2[1] || sizes1[3] != sizes2[3]; } diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index d111bd3093..7548cfe42a 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -45,7 +45,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.RenderInformation.FloatSize; import com.vaadin.client.ui.VOverlay; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.ui.ComponentStateUtil; @@ -523,7 +523,7 @@ public class Util { * @param state * @return */ - public static FloatSize parseRelativeSize(ComponentState state) { + public static FloatSize parseRelativeSize(AbstractComponentState state) { if (ComponentStateUtil.isUndefinedHeight(state) && ComponentStateUtil.isUndefinedWidth(state)) { return null; diff --git a/client/src/com/vaadin/client/VCaption.java b/client/src/com/vaadin/client/VCaption.java index aadc7b88ad..a662ef4a7b 100644 --- a/client/src/com/vaadin/client/VCaption.java +++ b/client/src/com/vaadin/client/VCaption.java @@ -24,7 +24,7 @@ import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.Icon; import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.ComponentConstants; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.ui.ComponentStateUtil; public class VCaption extends HTML { @@ -393,7 +393,7 @@ public class VCaption extends HTML { } } - public static boolean isNeeded(ComponentState state) { + public static boolean isNeeded(AbstractComponentState state) { if (state.caption != null) { return true; } diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index 8b6c4fb8aa..49e879a681 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -41,7 +41,7 @@ import com.vaadin.client.metadata.TypeData; import com.vaadin.client.ui.datefield.PopupDateFieldConnector; import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.shared.ComponentConstants; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.Connector; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.TabIndexState; @@ -116,8 +116,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector } @Override - public ComponentState getState() { - return (ComponentState) super.getState(); + public AbstractComponentState getState() { + return (AbstractComponentState) super.getState(); } @Override @@ -267,7 +267,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector * </p> */ protected void updateWidgetStyleNames() { - ComponentState state = getState(); + AbstractComponentState state = getState(); String primaryStyleName = getWidget().getStylePrimaryName(); if (state.primaryStyleName != null) { diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 54498c432f..bca68a86f3 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -68,7 +68,7 @@ import com.vaadin.client.Util; import com.vaadin.client.VConsole; import com.vaadin.client.ui.menubar.MenuBar; import com.vaadin.client.ui.menubar.MenuItem; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.EventId; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.combobox.FilteringMode; @@ -598,7 +598,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * @param componentState * shared state of the combo box */ - public void updateStyleNames(UIDL uidl, ComponentState componentState) { + public void updateStyleNames(UIDL uidl, AbstractComponentState componentState) { setStyleName(VFilterSelect.this.getStylePrimaryName() + "-suggestpopup"); menu.setStyleName(VFilterSelect.this.getStylePrimaryName() diff --git a/client/src/com/vaadin/client/ui/VFormLayout.java b/client/src/com/vaadin/client/ui/VFormLayout.java index a46a0a41c8..49c991b39c 100644 --- a/client/src/com/vaadin/client/ui/VFormLayout.java +++ b/client/src/com/vaadin/client/ui/VFormLayout.java @@ -35,7 +35,7 @@ import com.vaadin.client.Focusable; import com.vaadin.client.StyleConstants; import com.vaadin.client.VTooltip; import com.vaadin.shared.ComponentConstants; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.MarginInfo; @@ -65,7 +65,7 @@ public class VFormLayout extends SimplePanel { * @param enabled * @return An array of stylenames */ - private String[] getStylesFromState(ComponentState state, boolean enabled) { + private String[] getStylesFromState(AbstractComponentState state, boolean enabled) { List<String> styles = new ArrayList<String>(); if (ComponentStateUtil.hasStyles(state)) { for (String name : state.styles) { @@ -188,7 +188,7 @@ public class VFormLayout extends SimplePanel { } - public void updateCaption(Widget widget, ComponentState state, + public void updateCaption(Widget widget, AbstractComponentState state, boolean enabled) { final Caption c = widgetToCaption.get(widget); if (c != null) { @@ -249,7 +249,7 @@ public class VFormLayout extends SimplePanel { setStyleName(styleName); } - public void updateCaption(ComponentState state, boolean enabled) { + public void updateCaption(AbstractComponentState state, boolean enabled) { // Update styles as they might have changed when the caption changed setStyles(getStylesFromState(state, enabled)); diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 601c93428c..9b06b711cb 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -92,7 +92,7 @@ import com.vaadin.client.ui.dd.VDragAndDropManager; import com.vaadin.client.ui.dd.VDragEvent; import com.vaadin.client.ui.dd.VHasDropHandler; import com.vaadin.client.ui.dd.VTransferable; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.shared.ui.table.TableConstants; @@ -1113,7 +1113,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } /** For internal use only. May be removed or replaced in the future. */ - public void updateSelectionProperties(UIDL uidl, ComponentState state, + public void updateSelectionProperties(UIDL uidl, AbstractComponentState state, boolean readOnly) { setMultiSelectMode(uidl.hasAttribute("multiselectmode") ? uidl .getIntAttribute("multiselectmode") : MULTISELECT_MODE_DEFAULT); diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index d74665bb6d..63aeaa2fc7 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -55,7 +55,7 @@ import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.VCaption; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.EventId; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.tabsheet.TabsheetBaseConstants; @@ -743,7 +743,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } /** For internal use only. May be removed or replaced in the future. */ - public void handleStyleNames(UIDL uidl, ComponentState state) { + public void handleStyleNames(UIDL uidl, AbstractComponentState state) { // Add proper stylenames for all elements (easier to prevent unwanted // style inheritance) if (ComponentStateUtil.hasStyles(state)) { diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index b94488896e..67555e8331 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -28,7 +28,7 @@ import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.VConsole; import com.vaadin.client.ui.ManagedLayout; -import com.vaadin.shared.ComponentState; +import com.vaadin.shared.AbstractComponentState; public class LayoutDependencyTree { private class LayoutDependency { @@ -309,7 +309,7 @@ public class LayoutDependencyTree { } else { s += "Horizontal"; } - ComponentState state = connector.getState(); + AbstractComponentState state = connector.getState(); s += " sizing: " + getSizeDefinition(direction == VERTICAL ? state.height : state.width) + "\n"; |