diff options
Diffstat (limited to 'client')
16 files changed, 144 insertions, 507 deletions
diff --git a/client/src/com/vaadin/client/AnimationUtil.java b/client/src/com/vaadin/client/AnimationUtil.java index 2077cee3c0..063a0a163e 100644 --- a/client/src/com/vaadin/client/AnimationUtil.java +++ b/client/src/com/vaadin/client/AnimationUtil.java @@ -24,6 +24,7 @@ import com.google.gwt.dom.client.Style; * Utility methods for working with CSS transitions and animations. * * @author Vaadin Ltd + * @since 7.3 */ public class AnimationUtil { diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index 0d17fbd94f..3ccbeba6f3 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -51,7 +51,6 @@ import com.vaadin.client.metadata.ConnectorBundleLoader; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.TypeData; import com.vaadin.client.ui.UnknownComponentConnector; -import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ui.ui.UIConstants; @@ -85,7 +84,7 @@ public class ApplicationConfiguration implements EntryPoint { return null; } else { return value +""; - } + } }-*/; /** @@ -106,7 +105,7 @@ public class ApplicationConfiguration implements EntryPoint { } else { // $entry not needed as function is not exported return @java.lang.Boolean::valueOf(Z)(value); - } + } }-*/; /** @@ -127,7 +126,7 @@ public class ApplicationConfiguration implements EntryPoint { } else { // $entry not needed as function is not exported return @java.lang.Integer::valueOf(I)(value); - } + } }-*/; /** @@ -286,16 +285,14 @@ public class ApplicationConfiguration implements EntryPoint { return serviceUrl; } - /** - * @return the theme name used when initializing the application - * @deprecated as of 7.3. Use {@link UIConnector#getActiveTheme()} to get the - * theme currently in use - */ - @Deprecated public String getThemeName() { return getJsoConfiguration(id).getConfigString("theme"); } + public String getThemeUri() { + return getVaadinDirUrl() + "themes/" + getThemeName(); + } + /** * Gets the URL of the VAADIN directory on the server. * diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index a2c1d11a7d..6bbca98042 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -3108,7 +3108,7 @@ public class ApplicationConnection implements HasHandlers { return null; } if (uidlUri.startsWith("theme://")) { - final String themeUri = getThemeUri(); + final String themeUri = configuration.getThemeUri(); if (themeUri == null) { VConsole.error("Theme not set: ThemeResource will not be found. (" + uidlUri + ")"); @@ -3174,8 +3174,7 @@ public class ApplicationConnection implements HasHandlers { * @return URI to the current theme */ public String getThemeUri() { - return configuration.getVaadinDirUrl() + "themes/" - + getUIConnector().getActiveTheme(); + return configuration.getThemeUri(); } /** diff --git a/client/src/com/vaadin/client/Profiler.java b/client/src/com/vaadin/client/Profiler.java index 2174e00de1..6c0967099f 100644 --- a/client/src/com/vaadin/client/Profiler.java +++ b/client/src/com/vaadin/client/Profiler.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2014 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -37,14 +37,14 @@ import com.vaadin.client.debug.internal.ProfilerSection.ProfilerResultConsumer; * zero overhead unless enabled. To enable profiling, add * <code><set-property name="vaadin.profiler" value="true" /></code> to * your .gwt.xml file. - * + * * @author Vaadin Ltd * @since 7.0.0 */ public class Profiler { /** * Class to include using deferred binding to enable the profiling. - * + * * @author Vaadin Ltd * @since 7.0.0 */ @@ -101,7 +101,7 @@ public class Profiler { /** * Checks whether the profiling gathering is enabled. - * + * * @return <code>true</code> if the profiling is enabled, else * <code>false</code> */ @@ -115,7 +115,7 @@ public class Profiler { * Enters a named block. There should always be a matching invocation of * {@link #leave(String)} when leaving the block. Calls to this method will * be removed by the compiler unless profiling is enabled. - * + * * @param name * the name of the entered block */ @@ -129,7 +129,7 @@ public class Profiler { * Leaves a named block. There should always be a matching invocation of * {@link #enter(String)} when entering the block. Calls to this method will * be removed by the compiler unless profiling is enabled. - * + * * @param name * the name of the left block */ @@ -178,7 +178,7 @@ public class Profiler { * enabled because it will then remove a logger function that might have * been included in the HTML page and that would leak memory unless removed. * </p> - * + * * @since 7.0.2 */ public static void initialize() { @@ -281,7 +281,7 @@ public class Profiler { /** * Overridden in {@link EnabledProfiler} to make {@link #isEnabled()} return * true if GWT.create returns that class. - * + * * @return <code>true</code> if the profiling is enabled, else * <code>false</code> */ @@ -352,7 +352,7 @@ public class Profiler { if (typeof $wnd.__gwtStatsEvent != 'function') { if (typeof $wnd.vaadin.gwtStatsEvents != 'object') { $wnd.vaadin.gwtStatsEvents = []; - } + } $wnd.__gwtStatsEvent = function(event) { $wnd.vaadin.gwtStatsEvents.push(event); return true; @@ -369,9 +369,9 @@ public class Profiler { if (typeof $wnd.vaadin.gwtStatsEvents == 'object') { delete $wnd.vaadin.gwtStatsEvents; if (typeof $wnd.__gwtStatsEvent == 'function') { - $wnd.__gwtStatsEvent = function(){}; + $wnd.__gwtStatsEvent = function() { return true; }; } - } + } }-*/; private static native JsArray<GwtStatsEvent> clearEventsList() @@ -385,7 +385,7 @@ public class Profiler { * <p> * <b>Warning!</b> This is internal API and should not be used by * applications or add-ons. - * + * * @since 7.1.4 * @param profilerResultConsumer * the consumer that gets profiler data diff --git a/client/src/com/vaadin/client/ResourceLoader.java b/client/src/com/vaadin/client/ResourceLoader.java index e88def1a72..68a16e8162 100644 --- a/client/src/com/vaadin/client/ResourceLoader.java +++ b/client/src/com/vaadin/client/ResourceLoader.java @@ -221,6 +221,7 @@ public class ResourceLoader { * listener to notify when script is loaded * @param async * What mode the script.async attribute should be set to + * @since 7.2.4 */ public void loadScript(final String scriptUrl, final ResourceLoadListener resourceLoadListener, boolean async) { @@ -279,6 +280,7 @@ public class ResourceLoader { * execution order for dynamically-added scripts. * * @return Browser supports script.async='false' + * @since 7.2.4 */ public static boolean supportsInOrderScriptExecution() { return BrowserInfo.get().isIE() @@ -373,20 +375,7 @@ public class ResourceLoader { } } - /** - * Adds an onload listener to the given element, which should be a link or a - * script tag. The listener is called whenever loading is complete or an - * error occurred. - * - * @since - * @param element - * the element to attach a listener to - * @param listener - * the listener to call - * @param event - * the event passed to the listener - */ - public static native void addOnloadHandler(Element element, + private native void addOnloadHandler(Element element, ResourceLoadListener listener, ResourceLoadEvent event) /*-{ element.onload = $entry(function() { @@ -401,11 +390,11 @@ public class ResourceLoader { element.onreadystatechange = null; listener.@com.vaadin.client.ResourceLoader.ResourceLoadListener::onError(Lcom/vaadin/client/ResourceLoader$ResourceLoadEvent;)(event); }); - element.onreadystatechange = function() { + element.onreadystatechange = function() { if ("loaded" === element.readyState || "complete" === element.readyState ) { element.onload(arguments[0]); } - }; + }; }-*/; /** @@ -531,12 +520,12 @@ public class ResourceLoader { if (rules === undefined) { rules = sheet.rules; } - + if (rules === null) { // Style sheet loaded, but can't access length because of XSS -> assume there's something there return 1; } - + // Return length so we can distinguish 0 (probably 404 error) from normal case. return rules.length; } catch (err) { diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index f12a02c64f..507a5c2c2d 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -73,6 +73,7 @@ public class Util { * * @param event * @return return key code + * @since 7.2.4 */ public static int getKeyCode(KeyEvent<?> event) { int keyCode = event.getNativeEvent().getKeyCode(); diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index b1315a0d8b..d61af537a9 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -38,12 +38,12 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ui.VWindowOverlay; +import com.vaadin.client.ui.VOverlay; /** * TODO open for extension */ -public class VTooltip extends VWindowOverlay { +public class VTooltip extends VOverlay { private static final String CLASSNAME = "v-tooltip"; private static final int MARGIN = 4; public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN @@ -113,6 +113,7 @@ public class VTooltip extends VWindowOverlay { * * @param info * with the content of the tooltip + * @since 7.2.4 */ public void initializeAssistiveTooltips() { updatePosition(null, true); diff --git a/client/src/com/vaadin/client/communication/TranslatedURLReference.java b/client/src/com/vaadin/client/communication/TranslatedURLReference.java deleted file mode 100644 index c863b7b796..0000000000 --- a/client/src/com/vaadin/client/communication/TranslatedURLReference.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.communication; - -import com.vaadin.client.ApplicationConnection; -import com.vaadin.shared.communication.URLReference; - -public class TranslatedURLReference extends URLReference { - - private ApplicationConnection connection; - - /** - * @param connection - * the connection to set - */ - public void setConnection(ApplicationConnection connection) { - this.connection = connection; - } - - @Override - public String getURL() { - return connection.translateVaadinUri(super.getURL()); - } - -} diff --git a/client/src/com/vaadin/client/communication/URLReference_Serializer.java b/client/src/com/vaadin/client/communication/URLReference_Serializer.java index 4ecdc606d2..586dd626f0 100644 --- a/client/src/com/vaadin/client/communication/URLReference_Serializer.java +++ b/client/src/com/vaadin/client/communication/URLReference_Serializer.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2014 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -30,16 +30,14 @@ public class URLReference_Serializer implements JSONSerializer<URLReference> { @Override public URLReference deserialize(Type type, JSONValue jsonValue, ApplicationConnection connection) { - TranslatedURLReference reference = GWT - .create(TranslatedURLReference.class); - reference.setConnection(connection); + URLReference reference = GWT.create(URLReference.class); JSONObject json = (JSONObject) jsonValue; if (json.containsKey(URL_FIELD)) { JSONValue jsonURL = json.get(URL_FIELD); String URL = (String) JsonDecoder.decodeValue( new Type(String.class.getName(), null), jsonURL, null, connection); - reference.setURL(URL); + reference.setURL(connection.translateVaadinUri(URL)); } return reference; } diff --git a/client/src/com/vaadin/client/debug/internal/InfoSection.java b/client/src/com/vaadin/client/debug/internal/InfoSection.java index a7a84f5f8f..23b77a94db 100644 --- a/client/src/com/vaadin/client/debug/internal/InfoSection.java +++ b/client/src/com/vaadin/client/debug/internal/InfoSection.java @@ -163,7 +163,7 @@ public class InfoSection implements Section { addVersionInfo(configuration); addRow("Widget set", GWT.getModuleName()); - addRow("Theme", connection.getUIConnector().getActiveTheme()); + addRow("Theme", connection.getConfiguration().getThemeName()); String communicationMethodInfo = connection .getCommunicationMethodName(); diff --git a/client/src/com/vaadin/client/ui/AbstractConnector.java b/client/src/com/vaadin/client/ui/AbstractConnector.java index e93ea0f507..a2e0d9cd54 100644 --- a/client/src/com/vaadin/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractConnector.java @@ -28,7 +28,6 @@ import com.google.gwt.event.shared.HandlerManager; import com.google.web.bindery.event.shared.HandlerRegistration; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.FastStringMap; -import com.vaadin.client.FastStringSet; import com.vaadin.client.JsArrayObject; import com.vaadin.client.Profiler; import com.vaadin.client.ServerConnector; @@ -480,27 +479,4 @@ public abstract class AbstractConnector implements ServerConnector, Set<String> reg = getState().registeredEventListeners; return (reg != null && reg.contains(eventIdentifier)); } - - /** - * Force the connector to recheck its state variables as the variables or - * their meaning might have changed. - * - * @since 7.3 - */ - public void forceStateChange() { - StateChangeEvent event = new FullStateChangeEvent(this); - fireEvent(event); - } - - private static class FullStateChangeEvent extends StateChangeEvent { - public FullStateChangeEvent(ServerConnector connector) { - super(connector, FastStringSet.create()); - } - - @Override - public boolean hasPropertyChanged(String property) { - return true; - } - - } } diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java index a4f62775e1..f9aa2ef2f8 100644 --- a/client/src/com/vaadin/client/ui/VOverlay.java +++ b/client/src/com/vaadin/client/ui/VOverlay.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2014 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -51,7 +51,7 @@ import com.vaadin.client.Util; * temporary float over other components like context menus etc. This is to deal * stacking order correctly with VWindow objects. * </p> - * + * * <h3>Shadow</h3> * <p> * The separate shadow element underneath the main overlay element is <strong> @@ -62,7 +62,7 @@ import com.vaadin.client.Util; * supports, add <code>-webkit-box-shadow</code> and the standard * <code>box-shadow</code> properties. * </p> - * + * * <p> * For IE8, which doesn't support CSS box-shadow, you can use the proprietary * DropShadow filter. It doesn't provide the exact same features as box-shadow, @@ -70,7 +70,7 @@ import com.vaadin.client.Util; * border or a pseudo-element underneath the overlay which mimics a shadow, or * any combination of these. * </p> - * + * * <p> * Read more about the DropShadow filter from <a * href="http://msdn.microsoft.com/en-us/library/ms532985(v=vs.85).aspx" @@ -152,7 +152,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * Shadow element style. If an extending class wishes to use a different * style of shadow, it can use setShadowStyle(String) to give the shadow * element a new style name. - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -164,14 +164,20 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { */ public static final String CLASSNAME_CONTAINER = "v-overlay-container"; + /** + * @since 7.3 + */ public static final String ADDITIONAL_CLASSNAME_ANIMATE_IN = "animate-in"; + /** + * @since 7.3 + */ public static final String ADDITIONAL_CLASSNAME_ANIMATE_OUT = "animate-out"; /** * The shadow element for this overlay. - * + * * @deprecated See main JavaDoc for VOverlay - * + * */ @Deprecated private Element shadow; @@ -200,7 +206,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * The HTML snippet that is used to render the actual shadow. In consists of * nine different DIV-elements with the following class names: - * + * * <pre> * .v-shadow[-stylename] * ---------------------------------------------- @@ -213,9 +219,9 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * | .bottom-left | .bottom | .bottom-right | * ---------------------------------------------- * </pre> - * + * * See default theme 'shadow.css' for implementation example. - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -254,18 +260,32 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { @Deprecated public VOverlay(boolean autoHide, boolean modal, boolean showShadow) { super(autoHide, modal); - setShadowEnabled(showShadow); + setShadowEnabled(showShadow && useShadowDiv()); adjustZIndex(); } /** - * Method to controle whether DOM elements for shadow are added. With this + * Return true if a separate shadow div should be used. Since Vaadin 7.3, + * shadows are implemented with CSS box-shadow. Thus, a shadow div is only + * used for IE8 by default. + * + * @deprecated See main JavaDoc for VOverlay + * @since 7.3 + * @return true to use a shadow div + */ + @Deprecated + protected boolean useShadowDiv() { + return BrowserInfo.get().isIE8(); + } + + /** + * Method to control whether DOM elements for shadow are added. With this * method subclasses can control displaying of shadow also after the * constructor. - * + * * @param enabled * true if shadow should be displayed - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -329,7 +349,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Set the z-index (visual stack position) for this overlay. - * + * * @param zIndex * The new z-index */ @@ -424,7 +444,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * A "thread local" of sorts, set temporarily so that VOverlayImpl knows * which VOverlay is using it, so that it can be attached to the correct * overlay container. - * + * * TODO this is a strange pattern that we should get rid of when possible. */ protected static VOverlay current; @@ -542,12 +562,12 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * Sets the shadow style for this overlay. Will override any previous style * for the shadow. The default style name is defined by CLASSNAME_SHADOW. * The given style will be prefixed with CLASSNAME_SHADOW. - * + * * @param style * The new style name for the shadow element. Will be prefixed by * CLASSNAME_SHADOW, e.g. style=='foobar' -> actual style * name=='v-shadow-foobar'. - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -561,7 +581,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * Extending classes should always call this method after they change the * size of overlay without using normal 'setWidth(String)' and * 'setHeight(String)' methods (if not calling super.setWidth/Height). - * + * */ public void positionOrSizeUpdated() { positionOrSizeUpdated(1.0); @@ -580,7 +600,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * elements. Can be used to animate the related elements, using the * 'progress' parameter (used to animate the shadow in sync with GWT * PopupPanel's default animation 'PopupPanel.AnimationType.CENTER'). - * + * * @param progress * A value between 0.0 and 1.0, indicating the progress of the * animation (0=start, 1=end). @@ -683,7 +703,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * Returns true if we should add a shim iframe below the overlay to deal * with zindex issues with PDFs and applets. Can be overriden to disable * shim iframes if they are not needed. - * + * * @return true if a shim iframe should be added, false otherwise */ protected boolean needsShimElement() { @@ -745,13 +765,13 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Enables or disables sinking the events of the shadow to the same * onBrowserEvent as events to the actual overlay goes. - * + * * Please note, that if you enable this, you can't assume that e.g. * event.getEventTarget returns an element inside the DOM structure of the * overlay - * + * * @param sinkShadowEvents - * + * * @deprecated See main JavaDoc for VOverlay */ @Deprecated @@ -775,7 +795,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Get owner (Widget that made this VOverlay, not the layout parent) of * VOverlay - * + * * @return Owner (creator) or null if not defined */ public Widget getOwner() { @@ -785,7 +805,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Set owner (Widget that made this VOverlay, not the layout parent) of * VOverlay - * + * * @param owner * Owner (creator) of VOverlay */ @@ -796,7 +816,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Get the {@link ApplicationConnection} that this overlay belongs to. If * it's not set, {@link #getOwner()} is used to figure it out. - * + * * @return */ protected ApplicationConnection getApplicationConnection() { @@ -816,7 +836,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Gets the 'overlay container' element. Tries to find the current * {@link ApplicationConnection} using {@link #getApplicationConnection()}. - * + * * @return the overlay container element for the current * {@link ApplicationConnection} or another element if the current * {@link ApplicationConnection} cannot be determined. @@ -840,7 +860,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * {@link ApplicationConnection}. Each overlay should be created in a * overlay container element, so that the correct theme and styles can be * applied. - * + * * @param ac * A reference to {@link ApplicationConnection} * @return The overlay container @@ -865,7 +885,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Set the label of the container element, where tooltip, notification and * dialgs are added to. - * + * * @param applicationConnection * the application connection for which to change the label * @param overlayContainerLabel @@ -898,10 +918,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Gets the visual viewport width, which is useful for e.g iOS where the * view can be zoomed in while keeping the layout viewport intact. - * + * * Falls back to layout viewport; for those browsers/devices the difference * is that the scrollbar with is included (if there is a scrollbar). - * + * * @since 7.0.7 * @return */ @@ -917,10 +937,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /** * Gets the visual viewport height, which is useful for e.g iOS where the * view can be zoomed in while keeping the layout viewport intact. - * + * * Falls back to layout viewport; for those browsers/devices the difference * is that the scrollbar with is included (if there is a scrollbar). - * + * * @since 7.0.7 * @return */ @@ -945,7 +965,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /* * (non-Javadoc) - * + * * @see com.google.gwt.user.client.ui.PopupPanel#hide() */ @Override @@ -955,7 +975,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { /* * (non-Javadoc) - * + * * @see com.google.gwt.user.client.ui.PopupPanel#hide(boolean) */ @Override diff --git a/client/src/com/vaadin/client/ui/VUI.java b/client/src/com/vaadin/client/ui/VUI.java index eae4f6319d..df24c3b1c7 100644 --- a/client/src/com/vaadin/client/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/VUI.java @@ -48,12 +48,11 @@ import com.vaadin.client.Util; import com.vaadin.client.VConsole; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; -import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ui.ui.UIConstants; /** - * + * */ public class VUI extends SimplePanel implements ResizeHandler, Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable, @@ -63,6 +62,9 @@ public class VUI extends SimplePanel implements ResizeHandler, private static int MONITOR_PARENT_TIMER_INTERVAL = 1000; /** For internal use only. May be removed or replaced in the future. */ + public String theme; + + /** For internal use only. May be removed or replaced in the future. */ public String id; /** For internal use only. May be removed or replaced in the future. */ @@ -317,17 +319,21 @@ public class VUI extends SimplePanel implements ResizeHandler, } } - /** - * @return the name of the theme in use by this UI. - * @deprecated as of 7.3. Use {@link UIConnector#getActiveTheme()} instead. - */ - @Deprecated public String getTheme() { - return ((UIConnector) ConnectorMap.get(connection).getConnector(this)) - .getActiveTheme(); + return theme; } /** + * Used to reload host page on theme changes. + * <p> + * For internal use only. May be removed or replaced in the future. + */ + public static native void reloadHostPage() + /*-{ + $wnd.location.reload(); + }-*/; + + /** * Returns true if the body is NOT generated, i.e if someone else has made * the page that we're running in. Otherwise we're in charge of the whole * page. @@ -524,5 +530,4 @@ public class VUI extends SimplePanel implements ResizeHandler, }); } } - } diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 7c1a21f654..1cee727bc9 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -76,9 +76,9 @@ import com.vaadin.shared.ui.window.WindowRole; * * @author Vaadin Ltd */ -public class VWindow extends VWindowOverlay implements - ShortcutActionHandlerOwner, ScrollHandler, KeyDownHandler, - KeyUpHandler, FocusHandler, BlurHandler, Focusable { +public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, + ScrollHandler, KeyDownHandler, KeyUpHandler, FocusHandler, BlurHandler, + Focusable { private static ArrayList<VWindow> windowOrder = new ArrayList<VWindow>(); diff --git a/client/src/com/vaadin/client/ui/VWindowOverlay.java b/client/src/com/vaadin/client/ui/VWindowOverlay.java deleted file mode 100644 index 41a8276402..0000000000 --- a/client/src/com/vaadin/client/ui/VWindowOverlay.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.client.ui; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.RootPanel; -import com.vaadin.client.ApplicationConnection; - -public class VWindowOverlay extends VOverlay { - public VWindowOverlay() { - } - - public VWindowOverlay(boolean autoHide, boolean modal, boolean showShadow) { - super(autoHide, modal, showShadow); - } - - /** - * Gets the 'overlay container' element. Tries to find the current - * {@link ApplicationConnection} using {@link #getApplicationConnection()}. - * - * @return the overlay container element for the current - * {@link ApplicationConnection} or another element if the current - * {@link ApplicationConnection} cannot be determined. - */ - @Override - public com.google.gwt.user.client.Element getOverlayContainer() { - ApplicationConnection ac = getApplicationConnection(); - if (ac == null) { - return super.getOverlayContainer(); - } else { - Element overlayContainer = getOverlayContainer(ac); - return DOM.asOld(overlayContainer); - } - } - - /** - * Gets the 'overlay container' element pertaining to the given - * {@link ApplicationConnection}. Each overlay should be created in a - * overlay container element, so that the correct theme and styles can be - * applied. - * - * @param ac - * A reference to {@link ApplicationConnection} - * @return The overlay container - */ - public static com.google.gwt.user.client.Element getOverlayContainer( - ApplicationConnection ac) { - String id = ac.getConfiguration().getRootPanelId(); - id = id += "-window-overlays"; - Element container = DOM.getElementById(id); - if (container == null) { - container = DOM.createDiv(); - container.setId(id); - String styles = ac.getUIConnector().getWidget().getParent() - .getStyleName(); - container.addClassName(styles); - container.addClassName(CLASSNAME_CONTAINER); - RootPanel.get().getElement().appendChild(container); - } - - return DOM.asOld(container); - } -} diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 8997509da6..1d2a49cbd1 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2014 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -18,7 +18,6 @@ package com.vaadin.client.ui.ui; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; @@ -27,10 +26,8 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.HeadElement; import com.google.gwt.dom.client.LinkElement; import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; -import com.google.gwt.dom.client.StyleElement; import com.google.gwt.dom.client.StyleInjector; import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; @@ -54,17 +51,12 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.Focusable; import com.vaadin.client.Paintable; -import com.vaadin.client.ResourceLoader; -import com.vaadin.client.ResourceLoader.ResourceLoadEvent; -import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.ServerConnector; import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; import com.vaadin.client.ValueMap; -import com.vaadin.client.annotations.OnStateChange; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; -import com.vaadin.client.ui.AbstractConnector; import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.ShortcutActionHandler; @@ -74,7 +66,6 @@ import com.vaadin.client.ui.VUI; import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.client.ui.window.WindowConnector; import com.vaadin.server.Page.Styles; -import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.ui.ComponentStateUtil; @@ -89,7 +80,6 @@ import com.vaadin.shared.ui.ui.UIClientRpc; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.ui.ui.UIServerRpc; import com.vaadin.shared.ui.ui.UIState; -import com.vaadin.shared.util.SharedUtil; import com.vaadin.ui.UI; @Connect(value = UI.class, loadStyle = LoadStyle.EAGER) @@ -98,8 +88,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector private HandlerRegistration childStateChangeHandlerRegistration; - private String activeTheme = null; - private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() { @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { @@ -209,6 +197,14 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getWidget().immediate = getState().immediate; getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); + String newTheme = uidl.getStringAttribute("theme"); + if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) { + // Complete page refresh is needed due css can affect layout + // calculations etc + getWidget().reloadHostPage(); + } else { + getWidget().theme = newTheme; + } // this also implicitly removes old styles String styles = ""; styles += getWidget().getStylePrimaryName() + " "; @@ -403,12 +399,15 @@ public class UIConnector extends AbstractSingleComponentContainerConnector /** * Reads CSS strings and resources injected by {@link Styles#inject} from * the UIDL stream. - * + * * @param uidl * The uidl which contains "css-resource" and "css-string" tags */ private void injectCSS(UIDL uidl) { + final HeadElement head = HeadElement.as(Document.get() + .getElementsByTagName(HeadElement.TAG).getItem(0)); + /* * Search the UIDL stream for CSS resources and strings to be injected. */ @@ -425,7 +424,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector link.setRel("stylesheet"); link.setHref(url); link.setType("text/css"); - getHead().appendChild(link); + head.appendChild(link); + // Check if we have CSS string to inject } else if (cssInjectionsUidl.getTag().equals("css-string")) { for (Iterator<?> it2 = cssInjectionsUidl.getChildIterator(); it2 @@ -437,53 +437,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector } } - /** - * Internal helper to get the <head> tag of the page - * - * @since - * @return the head element - */ - private HeadElement getHead() { - return HeadElement.as(Document.get() - .getElementsByTagName(HeadElement.TAG).getItem(0)); - } - - /** - * Internal helper for removing any stylesheet with the given URL - * - * @since - * @param url - * the url to match with existing stylesheets - */ - private void removeStylesheet(String url) { - NodeList<Element> linkTags = getHead().getElementsByTagName( - LinkElement.TAG); - for (int i = 0; i < linkTags.getLength(); i++) { - LinkElement link = LinkElement.as(linkTags.getItem(i)); - if (!"stylesheet".equals(link.getRel())) { - continue; - } - if (!"text/css".equals(link.getType())) { - continue; - } - if (url.equals(link.getHref())) { - getHead().removeChild(link); - } - } - } - public void init(String rootPanelId, ApplicationConnection applicationConnection) { - // Create a style tag for style injections so they don't end up in - // the theme tag in IE8-IE10 (we don't want to wipe them out if we - // change theme) - if (BrowserInfo.get().isIE() - && BrowserInfo.get().getBrowserMajorVersion() < 11) { - StyleElement style = Document.get().createStyleElement(); - style.setType("text/css"); - getHead().appendChild(style); - } - DOM.sinkEvents(getWidget().getElement(), Event.ONKEYDOWN | Event.ONSCROLL); @@ -493,7 +448,9 @@ public class UIConnector extends AbstractSingleComponentContainerConnector // the user root.getElement().setInnerHTML(""); - activeTheme = applicationConnection.getConfiguration().getThemeName(); + String themeName = applicationConnection.getConfiguration() + .getThemeName(); + root.addStyleName(themeName); root.add(getWidget()); @@ -581,7 +538,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector /** * Checks if the given sub window is a child of this UI Connector - * + * * @deprecated Should be replaced by a more generic mechanism for getting * non-ComponentConnector children * @param wc @@ -595,7 +552,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector /** * Return an iterator for current subwindows. This method is meant for * testing purposes only. - * + * * @return */ public List<WindowConnector> getSubWindows() { @@ -622,7 +579,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector * public API instead of their state object directly. The page state might * not be an independent state object but can be embedded in UI state. * </p> - * + * * @since 7.1 * @return state object of the page */ @@ -686,10 +643,10 @@ public class UIConnector extends AbstractSingleComponentContainerConnector /** * Tries to scroll the viewport so that the given connector is in view. - * + * * @param componentConnector * The connector which should be visible - * + * */ public void scrollIntoView(final ComponentConnector componentConnector) { if (componentConnector == null) { @@ -783,7 +740,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector /** * Invokes the layout analyzer on the server - * + * * @since 7.1 */ public void analyzeLayouts() { @@ -794,7 +751,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector * Sends a request to the server to print details to console that will help * the developer to locate the corresponding server-side connector in the * source code. - * + * * @since 7.1 * @param serverConnector * the connector to locate @@ -803,195 +760,4 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getRpcProxy(DebugWindowServerRpc.class).showServerDebugInfo( serverConnector); } - - @OnStateChange("theme") - void onThemeChange() { - final String oldTheme = activeTheme; - final String newTheme = getState().theme; - if (SharedUtil.equals(oldTheme, newTheme)) { - // This should only happen on the initial load when activeTheme has - // been updated in init - return; - } - - final String oldThemeUrl = getThemeUrl(oldTheme); - final String newThemeUrl = getThemeUrl(newTheme); - getLogger().info("Changing theme from " + oldTheme + " to " + newTheme); - replaceTheme(oldTheme, newTheme, oldThemeUrl, newThemeUrl); - } - - /** - * Loads the new theme and removes references to the old theme - * - * @param oldTheme - * The name of the old theme - * @param newTheme - * The name of the new theme - * @param oldThemeUrl - * The url of the old theme - * @param newThemeUrl - * The url of the new theme - */ - private void replaceTheme(final String oldTheme, final String newTheme, - String oldThemeUrl, final String newThemeUrl) { - - LinkElement tagToReplace = null; - - if (oldTheme != null) { - NodeList<Element> linkTags = getHead().getElementsByTagName( - LinkElement.TAG); - for (int i = 0; i < linkTags.getLength(); i++) { - final LinkElement link = LinkElement.as(linkTags.getItem(i)); - if ("stylesheet".equals(link.getRel()) - && "text/css".equals(link.getType()) - && oldThemeUrl.equals(link.getHref())) { - tagToReplace = link; - break; - } - } - - if (tagToReplace == null) { - getLogger() - .warning( - "Did not find the link tag for the old theme (" - + oldThemeUrl - + "), adding a new stylesheet for the new theme (" - + newThemeUrl + ")"); - } - } - - if (newTheme != null) { - loadTheme(newTheme, newThemeUrl, tagToReplace); - } else { - if (tagToReplace != null) { - tagToReplace.getParentElement().removeChild(tagToReplace); - } - - activateTheme(null); - } - - } - - /** - * Loads the given theme and replaces the given link element with the new - * theme link element. - * - * @param newTheme - * The name of the new theme - * @param newThemeUrl - * The url of the new theme - * @param tagToReplace - * The link element to replace. If null, then the new link - * element is added at the end. - */ - private void loadTheme(final String newTheme, final String newThemeUrl, - final LinkElement tagToReplace) { - LinkElement newThemeLinkElement = Document.get().createLinkElement(); - newThemeLinkElement.setRel("stylesheet"); - newThemeLinkElement.setType("text/css"); - newThemeLinkElement.setHref(newThemeUrl); - ResourceLoader.addOnloadHandler(newThemeLinkElement, - new ResourceLoadListener() { - - @Override - public void onLoad(ResourceLoadEvent event) { - getLogger().info( - "Loading of " + newTheme + " from " - + newThemeUrl + " completed"); - - if (tagToReplace != null) { - tagToReplace.getParentElement().removeChild( - tagToReplace); - } - activateTheme(newTheme); - } - - @Override - public void onError(ResourceLoadEvent event) { - getLogger().warning( - "Could not load theme from " - + getThemeUrl(newTheme)); - } - }, null); - - if (tagToReplace != null) { - getHead().insertBefore(newThemeLinkElement, tagToReplace); - } else { - getHead().appendChild(newThemeLinkElement); - } - } - - /** - * Activates the new theme. Assumes the theme has been loaded and taken into - * use in the browser. - * - * @since 7.3 - * @param newTheme - */ - private void activateTheme(String newTheme) { - if (activeTheme != null) { - getWidget().getParent().removeStyleName(activeTheme); - } - - activeTheme = newTheme; - - if (newTheme != null) { - getWidget().getParent().addStyleName(newTheme); - } - - forceStateChangeRecursively(UIConnector.this); - getLayoutManager().forceLayout(); - } - - /** - * Force a full recursive recheck of every connector's state variables. - * - * @see #forceStateChange() - * - * @since 7.3 - */ - protected static void forceStateChangeRecursively( - AbstractConnector connector) { - connector.forceStateChange(); - - for (ServerConnector child : connector.getChildren()) { - if (child instanceof AbstractConnector) { - forceStateChangeRecursively((AbstractConnector) child); - } else { - getLogger().warning( - "Could not force state change for unknown connector type: " - + child.getClass().getName()); - } - } - - } - - /** - * Internal helper to get the theme URL for a given theme - * - * @since - * @param theme - * the name of the theme - * @return The URL the theme can be loaded from - */ - private String getThemeUrl(String theme) { - return getConnection().translateVaadinUri( - ApplicationConstants.VAADIN_PROTOCOL_PREFIX + "themes/" + theme - + "/styles" + ".css"); - } - - /** - * Returns the name of the theme currently in used by the UI - * - * @since - * @return the theme name used by this UI - */ - public String getActiveTheme() { - return activeTheme; - } - - private static Logger getLogger() { - return Logger.getLogger(UIConnector.class.getName()); - } - } |