diff options
author | Leif Åstrand <leif@vaadin.com> | 2011-11-29 14:47:42 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2011-11-29 14:47:42 +0200 |
commit | ddc6070445611cdf4f62003f8eb47e01baabbcd1 (patch) | |
tree | cd1a5bfb288336e3b0c050f8509f7d246ba67616 /src | |
parent | be546bddfe0765b4d40f4bdeb8eb5e9c1be5bdcf (diff) | |
parent | bc93f0e2418a2f67db12212c8f13c00c4aef00a1 (diff) | |
download | vaadin-framework-ddc6070445611cdf4f62003f8eb47e01baabbcd1.tar.gz vaadin-framework-ddc6070445611cdf4f62003f8eb47e01baabbcd1.zip |
Merge remote branch 'origin/master' into windowing
Conflicts:
src/com/vaadin/ui/AbstractField.java
tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
Diffstat (limited to 'src')
31 files changed, 284 insertions, 994 deletions
diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml index 9cf2a828db..f2fc764e28 100644 --- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml +++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml @@ -18,12 +18,6 @@ <when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" /> </replace-with> - <!-- Use our own history impl for IE7 to workaround #2931. --> - <replace-with class="com.vaadin.terminal.gwt.client.HistoryImplIEVaadin"> - <when-type-is class="com.google.gwt.user.client.impl.HistoryImpl" /> - <when-property-is name="user.agent" value="ie6" /> - </replace-with> - <generate-with class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator"> <when-type-is class="com.vaadin.terminal.gwt.client.WidgetMap" /> @@ -57,7 +51,6 @@ <when-type-is class="com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper" /> <any> - <when-property-is name="user.agent" value="ie6" /> <when-property-is name="user.agent" value="ie8" /> </any> </replace-with> diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index daa62b4495..4c9be79787 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -192,10 +192,6 @@ public class BrowserInfo { return isSafari() && browserDetails.getBrowserMajorVersion() == 4; } - public boolean isIE7() { - return isIE() && browserDetails.getBrowserMajorVersion() == 7; - } - public boolean isIE8() { return isIE() && browserDetails.getBrowserMajorVersion() == 8; } @@ -216,23 +212,6 @@ public class BrowserInfo { return browserDetails.isWebKit(); } - public boolean isFF2() { - // FIXME: Should use browserVersion - return browserDetails.isFirefox() - && browserDetails.getBrowserEngineVersion() == 1.8; - } - - public boolean isFF3() { - // FIXME: Should use browserVersion - return browserDetails.isFirefox() - && browserDetails.getBrowserEngineVersion() == 1.9; - } - - public boolean isFF4() { - return browserDetails.isFirefox() - && browserDetails.getBrowserMajorVersion() == 4; - } - /** * Returns the Gecko version if the browser is Gecko based. The Gecko * version for Firefox 2 is 1.8 and 1.9 for Firefox 3. diff --git a/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java b/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java deleted file mode 100644 index f0ad3d561a..0000000000 --- a/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java +++ /dev/null @@ -1,192 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ -/* - * Copyright 2008 Google Inc. - * - * 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.terminal.gwt.client; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.impl.HistoryImpl; - -/** - * A slightly modified version of GWT's HistoryImplIE6 to bypass bug #2931. Also - * combined with HistoryImplFrame. - * - * This class should be removed if GWT issue 3890 gets resolved. (Also remember - * to removed deferred binding rule from .gwt.xml file). - */ -public class HistoryImplIEVaadin extends HistoryImpl { - - private static native Element findHistoryFrame() - /*-{ - return $doc.getElementById('__gwt_historyFrame'); - }-*/; - - private static native Element getTokenElement(Element historyFrame) - /*-{ - // Initialize the history iframe. If '__gwt_historyToken' already exists, then - // we're probably backing into the app, so _don't_ set the iframe's location. - if (historyFrame.contentWindow) { - var doc = historyFrame.contentWindow.document; - return doc.getElementById('__gwt_historyToken'); - } - }-*/; - - protected Element historyFrame; - - @Override - protected final void nativeUpdate(String historyToken) { - /* - * Must update the location hash since it isn't already correct. - */ - updateHash(historyToken); - navigateFrame(historyToken); - } - - @Override - protected final void nativeUpdateOnEvent(String historyToken) { - updateHash(historyToken); - } - - /** - * Sanitizes an untrusted string to be used in an HTML context. NOTE: This - * method of escaping strings should only be used on Internet Explorer. - * - * @param maybeHtml - * untrusted string that may contain html - * @return sanitized string - */ - private static String escapeHtml(String maybeHtml) { - final Element div = DOM.createDiv(); - DOM.setInnerText(div, maybeHtml); - return DOM.getInnerHTML(div); - } - - /** - * For IE6, reading from $wnd.location.hash drops part of the fragment if - * the fragment contains a '?'. To avoid this bug, we use location.href - * instead. - */ - private static native String getLocationHash() - /*-{ - var href = $wnd.location.href; - var hashLoc = href.lastIndexOf("#"); - return (hashLoc > 0) ? href.substring(hashLoc) : ""; - }-*/; - - @Override - public boolean init() { - historyFrame = findHistoryFrame(); - if (historyFrame == null) { - return false; - } - - initHistoryToken(); - - // Initialize the history iframe. If a token element already exists, - // then - // we're probably backing into the app, so _don't_ create a new item. - Element tokenElement = getTokenElement(historyFrame); - if (tokenElement != null) { - setToken(getTokenElementContent(tokenElement)); - } else { - navigateFrame(getToken()); - } - - injectGlobalHandler(); - - initUrlCheckTimer(); - return true; - } - - protected native String getTokenElementContent(Element tokenElement) - /*-{ - return tokenElement.innerText; - }-*/; - - protected native void initHistoryToken() - /*-{ - // Assume an empty token. - var token = ''; - // Get the initial token from the url's hash component. - var hash = @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::getLocationHash()(); - if (hash.length > 0) { - try { - token = this.@com.google.gwt.user.client.impl.HistoryImpl::decodeFragment(Ljava/lang/String;)(hash.substring(1)); - } catch (e) { - // Clear the bad hash (this can't have been a valid token). - $wnd.location.hash = ''; - } - } - @com.google.gwt.user.client.impl.HistoryImpl::setToken(Ljava/lang/String;)(token); - }-*/; - - protected native void injectGlobalHandler() - /*-{ - var historyImplRef = this; - - $wnd.__gwt_onHistoryLoad = function(token) { - historyImplRef.@com.google.gwt.user.client.impl.HistoryImpl::newItemOnEvent(Ljava/lang/String;)(token); - }; - }-*/; - - protected native void navigateFrame(String token) - /*-{ - var escaped = @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::escapeHtml(Ljava/lang/String;)(token); - var doc = this.@com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::historyFrame.contentWindow.document; - doc.open(); - doc.write('<html><body onload="if(parent.__gwt_onHistoryLoad)parent.__gwt_onHistoryLoad(__gwt_historyToken.innerText)"><div id="__gwt_historyToken">' + escaped + '</div></body></html>'); - doc.close(); - }-*/; - - protected native void updateHash(String token) - /*-{ - $wnd.location.hash = this.@com.google.gwt.user.client.impl.HistoryImpl::encodeFragment(Ljava/lang/String;)(token); - }-*/; - - private native void initUrlCheckTimer() - /*-{ - // This is the URL check timer. It detects when an unexpected change - // occurs in the document's URL (e.g. when the user enters one manually - // or selects a 'favorite', but only the #hash part changes). When this - // occurs, we _must_ reload the page. This is because IE has a really - // nasty bug that totally mangles its history stack and causes the location - // bar in the UI to stop working under these circumstances. - var historyImplRef = this; - var urlChecker = function() { - $wnd.setTimeout(urlChecker, 250); - var hash = @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::getLocationHash()(); - if (hash.length > 0) { - var token = ''; - try { - token = historyImplRef.@com.google.gwt.user.client.impl.HistoryImpl::decodeFragment(Ljava/lang/String;)(hash.substring(1)); - } catch (e) { - // If there's a bad hash, always reload. This could only happen if - // if someone entered or linked to a bad url. - $wnd.location.reload(); - } - - var historyToken = @com.google.gwt.user.client.impl.HistoryImpl::getToken()(); - if (token != historyToken) { - $wnd.location.reload(); - } - } - }; - urlChecker(); - }-*/; - -} diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index fd014bffe6..3601f385b1 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -13,7 +13,6 @@ import java.util.Set; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; @@ -195,36 +194,6 @@ public class Util { return null; } - /** - * Detects if current browser is IE. - * - * @deprecated use BrowserInfo class instead - * - * @return true if IE - */ - @Deprecated - public static boolean isIE() { - return BrowserInfo.get().isIE(); - } - - /** - * @deprecated use BrowserInfo class instead - * @return - */ - @Deprecated - public static boolean isIE7() { - return BrowserInfo.get().isIE7(); - } - - /** - * @deprecated use BrowserInfo class instead - * @return - */ - @Deprecated - public static boolean isFF2() { - return BrowserInfo.get().isFF2(); - } - private static final Element escapeHtmlHelper = DOM.createDiv(); /** @@ -236,8 +205,8 @@ public class Util { public static String escapeHTML(String html) { DOM.setInnerText(escapeHtmlHelper, html); String escapedText = DOM.getInnerHTML(escapeHtmlHelper); - if (BrowserInfo.get().isIE() && BrowserInfo.get().getIEVersion() < 9) { - // #7478 IE7-IE8 "incorrectly" returns "<br>" for newlines set using + if (BrowserInfo.get().isIE8()) { + // #7478 IE8 "incorrectly" returns "<br>" for newlines set using // setInnerText. The same for " " which is converted to " " escapedText = escapedText.replaceAll("<(BR|br)>", "\n"); escapedText = escapedText.replaceAll(" ", " "); @@ -317,23 +286,19 @@ public class Util { int offsetWidth = element.getOffsetWidth(); int offsetHeight = element.getOffsetHeight(); - if (!BrowserInfo.get().isIE7()) { - if (offsetHeight < 1) { - offsetHeight = 1; - } - if (offsetWidth < 1) { - offsetWidth = 10; - } - element.getStyle().setPropertyPx("height", offsetHeight); + if (offsetHeight < 1) { + offsetHeight = 1; } + if (offsetWidth < 1) { + offsetWidth = 10; + } + element.getStyle().setPropertyPx("height", offsetHeight); element.getStyle().setPropertyPx("width", offsetWidth); borders = element.getOffsetWidth() - element.getClientWidth(); element.getStyle().setProperty("width", width); - if (!BrowserInfo.get().isIE7()) { - element.getStyle().setProperty("height", height); - } + element.getStyle().setProperty("height", height); } else { borders = element.getOffsetWidth() - element.getPropertyInt("clientWidth"); @@ -758,33 +723,6 @@ public class Util { }-*/; /** - * IE7 sometimes "forgets" to render content. This function runs a hack to - * workaround the bug if needed. This happens easily in framset. See #3295. - */ - public static void runIE7ZeroSizedBodyFix() { - if (BrowserInfo.get().isIE7()) { - int offsetWidth = RootPanel.getBodyElement().getOffsetWidth(); - if (offsetWidth == 0) { - shakeBodyElement(); - } - } - } - - /** - * Does some very small adjustments to body element. We need this just to - * overcome some IE bugs. - */ - public static void shakeBodyElement() { - final DivElement shaker = Document.get().createDivElement(); - RootPanel.getBodyElement().insertBefore(shaker, - RootPanel.getBodyElement().getFirstChildElement()); - shaker.getStyle().setPropertyPx("height", 0); - shaker.setInnerHTML(" "); - RootPanel.getBodyElement().removeChild(shaker); - - } - - /** * Locates the child component of <literal>parent</literal> which contains * the element <literal>element</literal>. The child component is also * returned if "element" is part of its caption. If diff --git a/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java b/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java index 3778579b99..1e1fc5380a 100644 --- a/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java +++ b/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java @@ -302,4 +302,28 @@ public class VBrowserDetails implements Serializable { return isLinux;
}
+ /**
+ * Checks if the browser is so old that it simply won't work with a Vaadin
+ * application.
+ *
+ * @return true if the browser won't work, false if not the browser is
+ * supported or might work
+ */
+ public boolean isTooOldToFunctionProperly() {
+ if (isIE() && getBrowserMajorVersion() < 8) {
+ return true;
+ }
+ if (isSafari() && getBrowserMajorVersion() < 5) {
+ return true;
+ }
+ if (isFirefox() && getBrowserMajorVersion() < 4) {
+ return true;
+ }
+ if (isOpera() && getBrowserMajorVersion() < 11) {
+ return true;
+ }
+
+ return false;
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/src/com/vaadin/terminal/gwt/client/WidgetSet.java index 38984e75c3..1c09709bfd 100644 --- a/src/com/vaadin/terminal/gwt/client/WidgetSet.java +++ b/src/com/vaadin/terminal/gwt/client/WidgetSet.java @@ -6,8 +6,6 @@ package com.vaadin.terminal.gwt.client; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.terminal.gwt.client.ui.VButton; -import com.vaadin.terminal.gwt.client.ui.VCheckBox; import com.vaadin.terminal.gwt.client.ui.VFilterSelect; import com.vaadin.terminal.gwt.client.ui.VListSelect; import com.vaadin.terminal.gwt.client.ui.VPasswordField; @@ -79,9 +77,7 @@ public class WidgetSet { // add our historical quirks - if (widgetClass == VButton.class && uidl.hasAttribute("type")) { - return VCheckBox.class; - } else if (widgetClass == VView.class && uidl.hasAttribute("sub")) { + if (widgetClass == VView.class && uidl.hasAttribute("sub")) { return VWindow.class; } else if (widgetClass == VFilterSelect.class) { if (uidl.hasAttribute("type")) { @@ -143,9 +139,7 @@ public class WidgetSet { * is in multiselect mode, causing the clientside implementation to * *actually* be VListSelect, when the annotation says VFilterSelect */ - if (fullyqualifiedName.equals("com.vaadin.ui.Button")) { - loadImplementation(VCheckBox.class); - } else if (fullyqualifiedName.equals("com.vaadin.ui.Select")) { + if (fullyqualifiedName.equals("com.vaadin.ui.Select")) { loadImplementation(VListSelect.class); } else if (fullyqualifiedName.equals("com.vaadin.ui.TextField")) { loadImplementation(VTextArea.class); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java index 3df623415a..5c940eab12 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java @@ -143,11 +143,6 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, } wrapper.insertBefore(errorIndicatorElement, captionElement); - // Fix for IE7 - if (BrowserInfo.get().isIE7()) { - errorIndicatorElement.setInnerText(" "); - } - } else if (errorIndicatorElement != null) { wrapper.removeChild(errorIndicatorElement); errorIndicatorElement = null; @@ -451,25 +446,6 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, } } - @Override - public void setWidth(String width) { - if (BrowserInfo.get().isIE7()) { - if (width != null && width.length() > 2) { - // Assume pixel values are always sent from - // ApplicationConnection - int w = Integer - .parseInt(width.substring(0, width.length() - 2)); - w -= getHorizontalBorderAndPaddingWidth(getElement()); - if (w < 0) { - // validity check for IE - w = 0; - } - width = w + "px"; - } - } - super.setWidth(width); - } - private static native int getHorizontalBorderAndPaddingWidth(Element elem) /*-{ // THIS METHOD IS ONLY USED FOR INTERNET EXPLORER, IT DOESN'T WORK WITH OTHERS diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java b/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java index ebdc0e547c..3f5973d804 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java @@ -4,10 +4,6 @@ package com.vaadin.terminal.gwt.client.ui; -import com.google.gwt.dom.client.InputElement; -import com.google.gwt.dom.client.LabelElement; -import com.google.gwt.dom.client.Node; -import com.google.gwt.dom.client.NodeList; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -19,7 +15,6 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.EventHelper; import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.MouseEventDetails; @@ -31,6 +26,8 @@ import com.vaadin.terminal.gwt.client.VTooltip; public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements Paintable, Field, FocusHandler, BlurHandler { + public static final String VARIABLE_STATE = "state"; + public static final String CLASSNAME = "v-checkbox"; String id; @@ -60,7 +57,7 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements event.getNativeEvent(), getElement()); client.updateVariable(id, "mousedetails", details.serialize(), false); - client.updateVariable(id, "state", getValue(), immediate); + client.updateVariable(id, VARIABLE_STATE, getValue(), immediate); } }); @@ -124,41 +121,11 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements // Set text setText(uidl.getStringAttribute("caption")); - setValue(uidl.getBooleanVariable("state")); + setValue(uidl.getBooleanVariable(VARIABLE_STATE)); immediate = uidl.getBooleanAttribute("immediate"); } @Override - public void setText(String text) { - super.setText(text); - if (BrowserInfo.get().isIE() && BrowserInfo.get().getIEVersion() < 8) { - - boolean breakLink = text == null || "".equals(text); - - // break or create link between label element and checkbox, to - // enable native focus outline around checkbox element itself, if - // caption is not present - NodeList<Node> childNodes = getElement().getChildNodes(); - String id = null; - for (int i = 0; i < childNodes.getLength(); i++) { - Node item = childNodes.getItem(i); - if (item.getNodeName().toLowerCase().equals("input")) { - InputElement input = (InputElement) item; - id = input.getId(); - } - if (item.getNodeName().toLowerCase().equals("label")) { - LabelElement label = (LabelElement) item; - if (breakLink) { - label.setHtmlFor(""); - } else { - label.setHtmlFor(id); - } - } - } - } - } - - @Override public void onBrowserEvent(Event event) { if (icon != null && (event.getTypeInt() == Event.ONCLICK) && (DOM.eventGetTarget(event) == icon.getElement())) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java index 89f063eaf9..0032b1a5dc 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.vaadin.terminal.gwt.client.ui; import com.google.gwt.dom.client.AnchorElement; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 2af04cb97e..7be01a1195 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -12,7 +12,6 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -1244,22 +1243,13 @@ public class VFilterSelect extends Composite implements Paintable, Field, } /** - * Sets the text in the text box using a deferred command if on Gecko. This - * is required for performance reasons (see #3663). + * Sets the text in the text box. * * @param text * the text to set in the text box */ private void setTextboxText(final String text) { - if (BrowserInfo.get().isFF3()) { - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - tb.setText(text); - } - }); - } else { - tb.setText(text); - } + tb.setText(text); } /* diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java index f4691a3f27..378286381f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java @@ -404,6 +404,7 @@ public class VFormLayout extends SimplePanel implements Container { // Workaround for IE weirdness, sometimes returns bad height in some // circumstances when Caption is empty. See #1444 // IE7 bugs more often. I wonder what happens when IE8 arrives... + // FIXME: This could be unnecessary for IE8+ if (BrowserInfo.get().isIE()) { if (isEmpty) { setHeight("0px"); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VLabel.java b/src/com/vaadin/terminal/gwt/client/ui/VLabel.java index 76ea1297ea..05017f22e8 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VLabel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VLabel.java @@ -124,8 +124,8 @@ public class VLabel extends HTML implements Paintable { @Override public void setText(String text) { - if (BrowserInfo.get().isIE() && BrowserInfo.get().getIEVersion() < 9) { - // #3983 - IE7,IE8 incorrectly replaces \n with <br> so we do the + if (BrowserInfo.get().isIE8()) { + // #3983 - IE8 incorrectly replaces \n with <br> so we do the // escaping manually and set as HTML super.setHTML(Util.escapeHTML(text)); } else { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 8b53fb01c1..5081734c7e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -714,27 +714,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, popup.setPopupPosition(left, top); - // IE7 really tests one's patience sometimes - // Part of a fix to correct #3850 - if (BrowserInfo.get().isIE7()) { - popup.getElement().getStyle().setProperty("zoom", ""); - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - if (popup == null) { - // The child menu can be hidden before this command is - // run. - return; - } - - if (popup.getElement().getStyle().getProperty("width") == null - || popup.getElement().getStyle() - .getProperty("width") == "") { - popup.setWidth(popup.getOffsetWidth() + "px"); - } - popup.getElement().getStyle().setProperty("zoom", "1"); - } - }); - } } private int adjustPopupHeight(int top, final int shadowSpace) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java index 458c43024c..d295ec86ee 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java @@ -4,7 +4,6 @@ package com.vaadin.terminal.gwt.client.ui; -import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -13,7 +12,6 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Button; @@ -99,13 +97,6 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, } getElement().insertBefore(errorIndicatorElement, captionElement); - // Fix for IE - // TODO This was originally for IE6 & IE7 and might not be needed - // any more - if (BrowserInfo.get().isIE()) { - errorIndicatorElement.setInnerText(" "); - } - } else if (errorIndicatorElement != null) { getElement().removeChild(errorIndicatorElement); errorIndicatorElement = null; @@ -124,21 +115,6 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, } } - if (BrowserInfo.get().isIE7()) { - /* - * Workaround for IE7 size calculation issues. Deferred because of - * issues with a button with an icon using the reindeer theme - */ - if (width.equals("")) { - Scheduler.get().scheduleDeferred(new Command() { - - public void execute() { - setWidth(""); - setWidth(getOffsetWidth() + "px"); - } - }); - } - } } @Override @@ -172,24 +148,8 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, @Override public void setWidth(String width) { - /* Workaround for IE7 button size part 1 (#2014) */ - if (BrowserInfo.get().isIE7() && this.width != null) { - if (this.width.equals(width)) { - return; - } - - if (width == null) { - width = ""; - } - } - this.width = width; super.setWidth(width); - - /* Workaround for IE7 button size part 2 (#2014) */ - if (BrowserInfo.get().isIE7()) { - super.setWidth(width); - } } /* diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java index 0957b6270f..260aa1123e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java @@ -15,7 +15,6 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; import com.vaadin.terminal.gwt.client.BrowserInfo; -import com.vaadin.terminal.gwt.client.Util; /** * In Vaadin UI this Overlay should always be used for all elements that @@ -162,30 +161,18 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { private static int adjustByRelativeTopBodyMargin() { if (topFix == -1) { - topFix = detectRelativeBodyFixes("top", BrowserInfo.get().isIE7()); + topFix = detectRelativeBodyFixes("top"); } return topFix; } - private native static int detectRelativeBodyFixes(String axis, - boolean removeClientLeftOrTop) + private native static int detectRelativeBodyFixes(String axis) /*-{ try { var b = $wnd.document.body; var cstyle = b.currentStyle ? b.currentStyle : getComputedStyle(b); if(cstyle && cstyle.position == 'relative') { - var offset = b.getBoundingClientRect()[axis]; - if (removeClientLeftOrTop) { - // IE7 include the top left border of the client area into the boundingClientRect - var clientTopOrLeft = 0; - if (axis == "top") - clientTopOrLeft = $wnd.document.documentElement.clientTop; - else - clientTopOrLeft = $wnd.document.documentElement.clientLeft; - - offset -= clientTopOrLeft; - } - return offset; + return b.getBoundingClientRect()[axis]; } } catch(e){} return 0; @@ -193,7 +180,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { private static int adjustByRelativeLeftBodyMargin() { if (leftFix == -1) { - leftFix = detectRelativeBodyFixes("left", BrowserInfo.get().isIE7()); + leftFix = detectRelativeBodyFixes("left"); } return leftFix; @@ -210,13 +197,6 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { updateShadowSizeAndPosition(1.0); } } - Util.runIE7ZeroSizedBodyFix(); - } - - @Override - public void hide(boolean autoClosed) { - super.hide(autoClosed); - Util.runIE7ZeroSizedBodyFix(); } @Override diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java index 4611f6e4ab..20cfdd7ad4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java @@ -322,11 +322,10 @@ public class VPanel extends SimplePanel implements Container, } public void runHacks(boolean runGeckoFix) { - if ((BrowserInfo.get().isIE() || BrowserInfo.get().isFF2()) - && (width == null || width.equals(""))) { + if ((BrowserInfo.get().isIE()) && (width == null || width.equals(""))) { /* - * IE and FF2 needs width to be specified for the root DIV so we - * calculate that from the sizes of the caption and layout + * IE (what version??) needs width to be specified for the root DIV + * so we calculate that from the sizes of the caption and layout */ int captionWidth = captionText.getOffsetWidth() + getCaptionMarginLeft() + getCaptionPaddingHorizontal(); @@ -337,11 +336,6 @@ public class VPanel extends SimplePanel implements Container, width = captionWidth; } - if (BrowserInfo.get().isIE7()) { - Util.setWidthExcludingPaddingAndBorder(captionNode, width - - getCaptionMarginLeft(), 26, false); - } - super.setWidth(width + "px"); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index c42567f9b1..850e481cd5 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -2749,8 +2749,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, int hw = captionContainer.getOffsetWidth() + scrollBody.getCellExtraWidth(); - if (BrowserInfo.get().isGecko() - || BrowserInfo.get().isIE7()) { + if (BrowserInfo.get().isGecko()) { hw += sortIndicator.getOffsetWidth(); } if (columnIndex < 0) { @@ -5924,19 +5923,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, */ private int getContentAreaBorderHeight() { if (contentAreaBorderHeight < 0) { - if (BrowserInfo.get().isIE7()) { - contentAreaBorderHeight = Util - .measureVerticalBorder(scrollBodyPanel.getElement()); - } else { - DOM.setStyleAttribute(scrollBodyPanel.getElement(), "overflow", - "hidden"); - int oh = scrollBodyPanel.getOffsetHeight(); - int ch = scrollBodyPanel.getElement().getPropertyInt( - "clientHeight"); - contentAreaBorderHeight = oh - ch; - DOM.setStyleAttribute(scrollBodyPanel.getElement(), "overflow", - "auto"); - } + + DOM.setStyleAttribute(scrollBodyPanel.getElement(), "overflow", + "hidden"); + int oh = scrollBodyPanel.getOffsetHeight(); + int ch = scrollBodyPanel.getElement() + .getPropertyInt("clientHeight"); + contentAreaBorderHeight = oh - ch; + DOM.setStyleAttribute(scrollBodyPanel.getElement(), "overflow", + "auto"); } return contentAreaBorderHeight; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index 6157079711..2841099198 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.Set; -import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; import com.google.gwt.event.dom.client.DomEvent.Type; @@ -20,7 +19,6 @@ import com.google.gwt.event.dom.client.TouchStartEvent; import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -306,15 +304,6 @@ public class VSplitPanel extends ComplexPanel implements Container, renderInformation.updateSize(getElement()); - if (BrowserInfo.get().isIE7()) { - // Part III of IE7 hack - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - iLayout(); - } - }); - } - // This is needed at least for cases like #3458 to take // appearing/disappearing scrollbars into account. client.runDescendentsLayout(this); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java index 016a411447..049e81e59a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java @@ -238,33 +238,6 @@ public class VTabsheet extends VTabsheetBase { return tab; } - @Override - public void setWidth(String width) { - super.setWidth(width); - if (BrowserInfo.get().isIE7()) { - /* - * IE7 apparently has problems with calculating width for - * floated elements inside a DIV with padding. Set the width - * explicitly for the caption. - */ - fixTextWidth(); - } - } - - private void fixTextWidth() { - Element captionText = getTextElement(); - if (captionText == null) { - return; - } - - int captionWidth = Util.getRequiredWidth(captionText); - int scrollWidth = captionText.getScrollWidth(); - if (scrollWidth > captionWidth) { - captionWidth = scrollWidth; - } - captionText.getStyle().setPropertyPx("width", captionWidth); - } - public void setClosable(boolean closable) { this.closable = closable; if (closable && closeButton == null) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java index fbbe603ee9..d0aebaf1de 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java @@ -287,44 +287,15 @@ public class VTextField extends TextBoxBase implements Paintable, Field, setPrompting(inputPrompt != null && focusedTextField != this && (text.equals(""))); - if (BrowserInfo.get().isFF3()) { - /* - * Firefox 3 is really sluggish when updating input attached to dom. - * Some optimizations seems to work much better in Firefox3 if we - * update the actual content lazily when the rest of the DOM has - * stabilized. In tests, about ten times better performance is - * achieved with this optimization. See for eg. #2898 - */ - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - String fieldValue; - if (prompting) { - fieldValue = isReadOnly() ? "" : inputPrompt; - addStyleDependentName(CLASSNAME_PROMPT); - } else { - fieldValue = text; - removeStyleDependentName(CLASSNAME_PROMPT); - } - /* - * Avoid resetting the old value. Prevents cursor flickering - * which then again happens due to this Gecko hack. - */ - if (!getText().equals(fieldValue)) { - setText(fieldValue); - } - } - }); + String fieldValue; + if (prompting) { + fieldValue = isReadOnly() ? "" : inputPrompt; + addStyleDependentName(CLASSNAME_PROMPT); } else { - String fieldValue; - if (prompting) { - fieldValue = isReadOnly() ? "" : inputPrompt; - addStyleDependentName(CLASSNAME_PROMPT); - } else { - fieldValue = text; - removeStyleDependentName(CLASSNAME_PROMPT); - } - setText(fieldValue); + fieldValue = text; + removeStyleDependentName(CLASSNAME_PROMPT); } + setText(fieldValue); lastTextChangeString = valueBeforeEdit = text; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java index 4115f30c37..caa9c67dd1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java @@ -15,7 +15,6 @@ import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.TextBox; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.ContainerResizedListener; import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.Focusable; @@ -367,10 +366,6 @@ public class VTextualDate extends VDateField implements Paintable, Field, if (fieldExtraWidth < 0) { text.setWidth("0"); fieldExtraWidth = text.getOffsetWidth(); - if (BrowserInfo.get().isFF3()) { - // Firefox somehow always leaves the INPUT element 2px wide - fieldExtraWidth -= 2; - } } return fieldExtraWidth; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java index 8db320b1da..fc6ec46d64 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java @@ -81,6 +81,7 @@ public class VTreeTable extends VScrollTable { colIndexOfHierarchy = uidl .hasAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) ? uidl .getIntAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) : 0; + int oldTotalRows = getTotalRows(); super.updateFromUIDL(uidl, client); if (collapseRequest) { if (collapsedRowKey != null && scrollBody != null) { @@ -96,15 +97,19 @@ public class VTreeTable extends VScrollTable { widget.setScrollPosition(scrollPosition); } - /* - * Triggers row calculations, removes cached rows etc. Basically - * cleans up state. Be careful if touching this, you will brake - * pageLength=0 if you remove this. - */ + // check which rows are needed from the server and initiate a + // deferred fetch onScroll(null); - + } + // Recalculate table size if collapse request, or if page length is zero + // (not sent by server) and row count changes (#7908). + if (collapseRequest + || (!uidl.hasAttribute("pagelength") && getTotalRows() != oldTotalRows)) { /* * Ensure that possibly removed/added scrollbars are considered. + * Triggers row calculations, removes cached rows etc. Basically + * cleans up state. Be careful if touching this, you will break + * pageLength=0 if you remove this. */ triggerLazyColumnAdjustment(true); @@ -164,7 +169,7 @@ public class VTreeTable extends VScrollTable { private boolean browserSupportsAnimation() { BrowserInfo bi = BrowserInfo.get(); - return !(bi.isIE7() || bi.isSafari4()); + return !(bi.isSafari4()); } class VTreeTableScrollBody extends VScrollTable.VScrollTableBody { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 5e50bc7eb4..02da3dc185 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -472,9 +472,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler, * browser window. Constantly recalculating the layout causes the resize * operation to be really slow with complex layouts. */ - boolean lazy = resizeLazy - || (BrowserInfo.get().isIE() && BrowserInfo.get() - .getIEVersion() <= 8) || BrowserInfo.get().isFF3(); + boolean lazy = resizeLazy || BrowserInfo.get().isIE8(); if (lazy) { delayedResizeExecutor.trigger(); @@ -555,16 +553,6 @@ public class VView extends SimplePanel implements Container, ResizeHandler, @Override public int getWidth() { - int w = getRealWidth(); - if (w < 10 && BrowserInfo.get().isIE7()) { - // Overcome an IE7 bug #3295 - Util.shakeBodyElement(); - w = getRealWidth(); - } - return w; - } - - private int getRealWidth() { if (connection.getConfiguration().isStandalone()) { return getElement().getOffsetWidth() - getExcessWidth(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index f2460ef2f1..7f9f1edb4a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -660,42 +660,6 @@ public class VWindow extends VOverlay implements Container, showModalityCurtain(); } super.show(); - - setFF2CaretFixEnabled(true); - fixFF3OverflowBug(); - } - - /** Disable overflow auto with FF3 to fix #1837. */ - private void fixFF3OverflowBug() { - if (BrowserInfo.get().isFF3()) { - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - DOM.setStyleAttribute(getElement(), "overflow", ""); - } - }); - } - } - - /** - * Fix "missing cursor" browser bug workaround for FF2 in Windows and Linux. - * - * Calling this method has no effect on other browsers than the ones based - * on Gecko 1.8 - * - * @param enable - */ - private void setFF2CaretFixEnabled(boolean enable) { - if (BrowserInfo.get().isFF2()) { - if (enable) { - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - DOM.setStyleAttribute(getElement(), "overflow", "auto"); - } - }); - } else { - DOM.setStyleAttribute(getElement(), "overflow", ""); - } - } } @Override @@ -724,14 +688,6 @@ public class VWindow extends VOverlay implements Container, } private void showModalityCurtain() { - if (BrowserInfo.get().isFF2()) { - DOM.setStyleAttribute( - getModalityCurtain(), - "height", - DOM.getElementPropertyInt(RootPanel.getBodyElement(), - "offsetHeight") + "px"); - DOM.setStyleAttribute(getModalityCurtain(), "position", "absolute"); - } DOM.setStyleAttribute(getModalityCurtain(), "zIndex", "" + (windowOrder.indexOf(this) + Z_INDEX)); if (isShowing()) { @@ -753,8 +709,6 @@ public class VWindow extends VOverlay implements Container, private void showDraggingCurtain(boolean show) { if (show && draggingCurtain == null) { - setFF2CaretFixEnabled(false); // makes FF2 slow - draggingCurtain = DOM.createDiv(); DOM.setStyleAttribute(draggingCurtain, "position", "absolute"); DOM.setStyleAttribute(draggingCurtain, "top", "0px"); @@ -767,8 +721,6 @@ public class VWindow extends VOverlay implements Container, DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain); } else if (!show && draggingCurtain != null) { - setFF2CaretFixEnabled(true); // makes FF2 slow - DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain); draggingCurtain = null; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java b/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java index bcb972ca6a..ebb8bd41ea 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java +++ b/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java @@ -9,7 +9,6 @@ import java.util.NoSuchElementException; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.TableElement; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -78,29 +77,12 @@ public class ChildComponentContainer extends Panel { containerDIV = Document.get().createDivElement(); widgetDIV = Document.get().createDivElement(); - if (BrowserInfo.get().isFF2()) { - // Style style = widgetDIV.getStyle(); - // FF2 chokes on some floats very easily. Measuring size escpecially - // becomes terribly slow - TableElement tableEl = Document.get().createTableElement(); - tableEl.setInnerHTML("<tbody><tr><td><div></div></td></tr></tbody>"); - DivElement div = (DivElement) tableEl.getFirstChildElement() - .getFirstChildElement().getFirstChildElement() - .getFirstChildElement(); - tableEl.setCellPadding(0); - tableEl.setCellSpacing(0); - tableEl.setBorder(0); - div.getStyle().setProperty("padding", "0"); - - setElement(tableEl); - containerDIV = div; - } else { - setFloat(widgetDIV, "left"); - setElement(containerDIV); - containerDIV.getStyle().setProperty("height", "0"); - containerDIV.getStyle().setProperty("width", "0px"); - containerDIV.getStyle().setProperty("overflow", "hidden"); - } + + setFloat(widgetDIV, "left"); + setElement(containerDIV); + containerDIV.getStyle().setProperty("height", "0"); + containerDIV.getStyle().setProperty("width", "0px"); + containerDIV.getStyle().setProperty("overflow", "hidden"); if (BrowserInfo.get().isIE()) { /* diff --git a/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/src/com/vaadin/terminal/gwt/server/WebBrowser.java index 4835b3c55b..4ac9cb77b2 100644 --- a/src/com/vaadin/terminal/gwt/server/WebBrowser.java +++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java @@ -400,4 +400,25 @@ public class WebBrowser implements Terminal { } + /** + * Checks if the browser is so old that it simply won't work with a Vaadin + * application. Can be used to redirect to an alternative page, show + * alternative content or similar. + * + * When this method returns true chances are very high that the browser + * won't work and it does not make sense to direct the user to the Vaadin + * application. + * + * @return true if the browser won't work, false if not the browser is + * supported or might work + */ + public boolean isTooOldToFunctionProperly() { + if (browserDetails == null) { + // Don't know, so assume it will work + return false; + } + + return browserDetails.isTooOldToFunctionProperly(); + } + } diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java index 9b05bf02f9..e91511ae39 100644 --- a/src/com/vaadin/ui/AbstractComponent.java +++ b/src/com/vaadin/ui/AbstractComponent.java @@ -19,8 +19,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vaadin.Application; +import com.vaadin.event.ActionManager; import com.vaadin.event.EventRouter; import com.vaadin.event.MethodEventSource; +import com.vaadin.event.ShortcutListener; import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; @@ -145,6 +147,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource private ComponentErrorHandler errorHandler = null; + /** + * Keeps track of the Actions added to this component; the actual + * handling/notifying is delegated, usually to the containing window. + */ + private ActionManager actionManager; + /* Constructor */ /** @@ -635,6 +643,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource if (delayedFocus) { focus(); } + if (actionManager != null) { + actionManager.setViewer(getRoot()); + } } /* @@ -642,6 +653,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource * we use the default documentation from implemented interface. */ public void detach() { + if (actionManager != null) { + actionManager.setViewer((Root) null); + } } /** @@ -1517,4 +1531,34 @@ public abstract class AbstractComponent implements Component, MethodEventSource } -}
\ No newline at end of file + /* + * Actions + */ + + /** + * Gets the {@link ActionManager} used to manage the + * {@link ShortcutListener}s added to this {@link Field}. + * + * @return the ActionManager in use + */ + protected ActionManager getActionManager() { + if (actionManager == null) { + actionManager = new ActionManager(); + if (getRoot() != null) { + actionManager.setViewer(getRoot()); + } + } + return actionManager; + } + + public void addShortcutListener(ShortcutListener shortcut) { + getActionManager().addAction(shortcut); + } + + public void removeShortcutListener(ShortcutListener shortcut) { + if (actionManager != null) { + actionManager.removeAction(shortcut); + } + } + +} diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index ce3687ba1a..d28c3e5256 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -18,7 +18,6 @@ import com.vaadin.data.Validatable; import com.vaadin.data.Validator; import com.vaadin.data.Validator.InvalidValueException; import com.vaadin.event.Action; -import com.vaadin.event.ActionManager; import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutListener; import com.vaadin.terminal.CompositeErrorMessage; @@ -131,12 +130,6 @@ public abstract class AbstractField extends AbstractComponent implements Field, */ private boolean validationVisible = true; - /** - * Keeps track of the Actions added to this component; the actual - * handling/notifying is delegated, usually to the containing window. - */ - private ActionManager actionManager; - private boolean valueWasModifiedByDataSourceDuringCommit; /* Component basics */ @@ -1111,27 +1104,6 @@ public abstract class AbstractField extends AbstractComponent implements Field, } /** - * Notifies the component that it is connected to an application. - * - * @see com.vaadin.ui.Component#attach() - */ - @Override - public void attach() { - super.attach(); - if (actionManager != null) { - actionManager.setViewer(getRoot()); - } - } - - @Override - public void detach() { - super.detach(); - if (actionManager != null) { - actionManager.setViewer((Root) null); - } - } - - /** * Is this field required. Required fields must filled by the user. * * If the field is required, it is visually indicated in the user interface. @@ -1244,36 +1216,6 @@ public abstract class AbstractField extends AbstractComponent implements Field, requestRepaint(); } - /* - * Actions - */ - - /** - * Gets the {@link ActionManager} used to manage the - * {@link ShortcutListener}s added to this {@link Field}. - * - * @return the ActionManager in use - */ - protected ActionManager getActionManager() { - if (actionManager == null) { - actionManager = new ActionManager(); - if (getRoot() != null) { - actionManager.setViewer(getRoot()); - } - } - return actionManager; - } - - public void addShortcutListener(ShortcutListener shortcut) { - getActionManager().addAction(shortcut); - } - - public void removeShortcutListener(ShortcutListener shortcut) { - if (actionManager != null) { - actionManager.removeAction(shortcut); - } - } - /** * A ready-made {@link ShortcutListener} that focuses the given * {@link Focusable} (usually a {@link Field}) when the keyboard shortcut is @@ -1329,4 +1271,4 @@ public abstract class AbstractField extends AbstractComponent implements Field, focusable.focus(); } } -}
\ No newline at end of file +} diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 16314f94c3..eb580efe31 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -9,7 +9,7 @@ import java.io.Serializable; import java.lang.reflect.Method; import java.util.Map; -import com.vaadin.data.Property; +import com.vaadin.event.Action; import com.vaadin.event.FieldEvents; import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; @@ -23,8 +23,9 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VButton; +import com.vaadin.tools.ReflectTools; import com.vaadin.ui.ClientWidget.LoadStyle; -import com.vaadin.ui.themes.BaseTheme; +import com.vaadin.ui.Component.Focusable; /** * A generic button component. @@ -36,28 +37,22 @@ import com.vaadin.ui.themes.BaseTheme; */ @SuppressWarnings("serial") @ClientWidget(value = VButton.class, loadStyle = LoadStyle.EAGER) -public class Button extends AbstractField implements FieldEvents.BlurNotifier, - FieldEvents.FocusNotifier { +public class Button extends AbstractComponent implements + FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Focusable, + Action.ShortcutNotifier { /* Private members */ - boolean switchMode = false; - boolean disableOnClick = false; /** - * Creates a new push button. The value of the push button is false and it - * is immediate by default. - * + * Creates a new push button. */ public Button() { - setValue(Boolean.FALSE); } /** - * Creates a new push button. - * - * The value of the push button is false and it is immediate by default. + * Creates a new push button with the given caption. * * @param caption * the Button caption. @@ -68,7 +63,7 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, } /** - * Creates a new push button with click listener. + * Creates a new push button with a click listener. * * @param caption * the Button caption. @@ -102,36 +97,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, } /** - * Creates a new switch button with initial value. - * - * @param state - * the Initial state of the switch-button. - * @param initialState - * @deprecated use {@link CheckBox} instead of Button in "switchmode" - */ - @Deprecated - public Button(String caption, boolean initialState) { - setCaption(caption); - setValue(Boolean.valueOf(initialState)); - setSwitchMode(true); - } - - /** - * Creates a new switch button that is connected to a boolean property. - * - * @param state - * the Initial state of the switch-button. - * @param dataSource - * @deprecated use {@link CheckBox} instead of Button in "switchmode" - */ - @Deprecated - public Button(String caption, Property dataSource) { - setCaption(caption); - setSwitchMode(true); - setPropertyDataSource(dataSource); - } - - /** * Paints the content of this component. * * @param event @@ -145,11 +110,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - if (isSwitchMode()) { - target.addAttribute("type", "switch"); - } - target.addVariable(this, "state", booleanValue()); - if (isDisableOnClick()) { target.addAttribute(VButton.ATTR_DISABLE_ON_CLICK, true); } @@ -176,46 +136,14 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, } if (!isReadOnly() && variables.containsKey("state")) { - // Gets the new and old button states - final Boolean newValue = (Boolean) variables.get("state"); - final Boolean oldValue = (Boolean) getValue(); - - if (isSwitchMode()) { - - // For switch button, the event is only sent if the - // switch state is changed - if (newValue != null && !newValue.equals(oldValue) - && !isReadOnly()) { - setValue(newValue); - if (variables.containsKey("mousedetails")) { - fireClick(MouseEventDetails - .deSerialize((String) variables - .get("mousedetails"))); - } else { - // for compatibility with custom implementations which - // don't send mouse details - fireClick(); - } - } + // Send click events when the button is pushed + if (variables.containsKey("mousedetails")) { + fireClick(MouseEventDetails.deSerialize((String) variables + .get("mousedetails"))); } else { - - // Only send click event if the button is pushed - if (newValue.booleanValue()) { - if (variables.containsKey("mousedetails")) { - fireClick(MouseEventDetails - .deSerialize((String) variables - .get("mousedetails"))); - } else { - // for compatibility with custom implementations which - // don't send mouse details - fireClick(); - } - } - - // If the button is true for some reason, release it - if (null == oldValue || oldValue.booleanValue()) { - setValue(Boolean.FALSE); - } + // for compatibility with custom implementations which + // don't send mouse details + fireClick(); } } @@ -228,92 +156,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, } /** - * Checks if it is switchMode. - * - * @return <code>true</code> if it is in Switch Mode, otherwise - * <code>false</code>. - * @deprecated the {@link CheckBox} component should be used instead of - * Button in switch mode - */ - @Deprecated - public boolean isSwitchMode() { - return switchMode; - } - - /** - * Sets the switchMode. - * - * @param switchMode - * The switchMode to set. - * @deprecated the {@link CheckBox} component should be used instead of - * Button in switch mode - */ - @Deprecated - public void setSwitchMode(boolean switchMode) { - this.switchMode = switchMode; - if (!switchMode) { - setImmediate(true); - if (booleanValue()) { - setValue(Boolean.FALSE); - } - } - } - - /** - * Get the boolean value of the button state. - * - * @return True iff the button is pressed down or checked. - */ - public boolean booleanValue() { - Boolean value = (Boolean) getValue(); - return (null == value) ? false : value.booleanValue(); - } - - /** - * Sets immediate mode. Push buttons can not be set in non-immediate mode. - * - * @see com.vaadin.ui.AbstractComponent#setImmediate(boolean) - */ - @Override - public void setImmediate(boolean immediate) { - // Push buttons are always immediate - super.setImmediate(!isSwitchMode() || immediate); - } - - /** - * The type of the button as a property. - * - * @see com.vaadin.data.Property#getType() - */ - @Override - public Class getType() { - return Boolean.class; - } - - /* Click event */ - - private static final Method BUTTON_CLICK_METHOD; - - /** - * Button style with no decorations. Looks like a link, acts like a button - * - * @deprecated use {@link BaseTheme#BUTTON_LINK} instead. - */ - @Deprecated - public static final String STYLE_LINK = "link"; - - static { - try { - BUTTON_CLICK_METHOD = ClickListener.class.getDeclaredMethod( - "buttonClick", new Class[] { ClickEvent.class }); - } catch (final java.lang.NoSuchMethodException e) { - // This should never happen - throw new java.lang.RuntimeException( - "Internal error finding methods in Button"); - } - } - - /** * Click event. This event is thrown, when the button is clicked. * * @author IT Mill Ltd. @@ -484,6 +326,10 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, */ public interface ClickListener extends Serializable { + public static final Method BUTTON_CLICK_METHOD = ReflectTools + .findMethod(ClickListener.class, "buttonClick", + ClickEvent.class); + /** * Called when a {@link Button} has been clicked. A reference to the * button is given by {@link ClickEvent#getButton()}. @@ -502,7 +348,8 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, * the Listener to be added. */ public void addListener(ClickListener listener) { - addListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD); + addListener(ClickEvent.class, listener, + ClickListener.BUTTON_CLICK_METHOD); } /** @@ -512,7 +359,8 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, * the Listener to be removed. */ public void removeListener(ClickListener listener) { - removeListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD); + removeListener(ClickEvent.class, listener, + ClickListener.BUTTON_CLICK_METHOD); } /** @@ -538,16 +386,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, fireEvent(new Button.ClickEvent(this, details)); } - @Override - protected void setInternalValue(Object newValue) { - // Make sure only booleans get through - if (null != newValue && !(newValue instanceof Boolean)) { - throw new IllegalArgumentException(getClass().getSimpleName() - + " only accepts Boolean values"); - } - super.setInternalValue(newValue); - } - public void addListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); @@ -573,6 +411,8 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, protected ClickShortcut clickShortcut; + private int tabIndex = 0; + /** * Makes it possible to invoke a click on this button by pressing the given * {@link KeyCode} and (optional) {@link ModifierKey}s.<br/> @@ -685,4 +525,18 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, requestRepaint(); } + public int getTabIndex() { + return tabIndex; + } + + public void setTabIndex(int tabIndex) { + this.tabIndex = tabIndex; + + } + + @Override + public void focus() { + // Overridden only to make public + super.focus(); + } } diff --git a/src/com/vaadin/ui/CheckBox.java b/src/com/vaadin/ui/CheckBox.java index b9ae236cb0..11d9619c8c 100644 --- a/src/com/vaadin/ui/CheckBox.java +++ b/src/com/vaadin/ui/CheckBox.java @@ -4,110 +4,129 @@ package com.vaadin.ui; -import java.lang.reflect.Method; +import java.util.Map; import com.vaadin.data.Property; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.terminal.PaintException; +import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.gwt.client.ui.VCheckBox; @ClientWidget(com.vaadin.terminal.gwt.client.ui.VCheckBox.class) -public class CheckBox extends Button { +public class CheckBox extends AbstractField { /** - * Creates a new switch button. + * Creates a new checkbox. */ public CheckBox() { - setSwitchMode(true); } /** - * Creates a new switch button with a caption and a set initial state. + * Creates a new checkbox with a set caption. * * @param caption - * the caption of the switch button - * @param initialState - * the initial state of the switch button + * the Checkbox caption. */ - @SuppressWarnings("deprecation") - public CheckBox(String caption, boolean initialState) { - super(caption, initialState); - } - - /** - * Creates a new switch button with a caption and a click listener. - * - * @param caption - * the caption of the switch button - * @param listener - * the click listener - */ - public CheckBox(String caption, ClickListener listener) { - super(caption, listener); - setSwitchMode(true); + public CheckBox(String caption) { + this(); + setCaption(caption); } /** - * Convenience method for creating a new switch button with a method - * listening button clicks. Using this method is discouraged because it - * cannot be checked during compilation. Use - * {@link #addListener(Class, Object, Method)} or - * {@link #addListener(com.vaadin.ui.Component.Listener)} instead. The - * method must have either no parameters, or only one parameter of - * Button.ClickEvent type. + * Creates a new checkbox with a caption and a set initial state. * * @param caption - * the Button caption. - * @param target - * the Object having the method for listening button clicks. - * @param methodName - * the name of the method in target object, that receives button - * click events. + * the caption of the checkbox + * @param initialState + * the initial state of the checkbox */ - public CheckBox(String caption, Object target, String methodName) { - super(caption, target, methodName); - setSwitchMode(true); + public CheckBox(String caption, boolean initialState) { + this(caption); + setValue(initialState); } /** - * Creates a new switch button that is connected to a boolean property. + * Creates a new checkbox that is connected to a boolean property. * * @param state * the Initial state of the switch-button. * @param dataSource */ - @SuppressWarnings("deprecation") public CheckBox(String caption, Property dataSource) { - super(caption, dataSource); - setSwitchMode(true); + this(caption); + setPropertyDataSource(dataSource); } - /** - * Creates a new push button with a set caption. - * - * The value of the push button is always false and they are immediate by - * default. - * - * @param caption - * the Button caption. - */ + @Override + public Class<?> getType() { + return Boolean.class; + } - @SuppressWarnings("deprecation") - public CheckBox(String caption) { - super(caption, false); + @Override + public void paintContent(PaintTarget target) throws PaintException { + super.paintContent(target); + + target.addVariable(this, VCheckBox.VARIABLE_STATE, booleanValue()); } - @Deprecated @Override - public void setSwitchMode(boolean switchMode) - throws UnsupportedOperationException { - if (this.switchMode && !switchMode) { - throw new UnsupportedOperationException( - "CheckBox is always in switch mode (consider using a Button)"); + public void changeVariables(Object source, Map<String, Object> variables) { + super.changeVariables(source, variables); + + if (!isReadOnly() && variables.containsKey(VCheckBox.VARIABLE_STATE)) { + // Gets the new and old states + final Boolean newValue = (Boolean) variables + .get(VCheckBox.VARIABLE_STATE); + final Boolean oldValue = (Boolean) getValue(); + + // The event is only sent if the switch state is changed + if (newValue != null && !newValue.equals(oldValue)) { + setValue(newValue); + } + } + + if (variables.containsKey(FocusEvent.EVENT_ID)) { + fireEvent(new FocusEvent(this)); + } + if (variables.containsKey(BlurEvent.EVENT_ID)) { + fireEvent(new BlurEvent(this)); } - super.setSwitchMode(true); } - @Override - public void setDisableOnClick(boolean disableOnClick) { - throw new UnsupportedOperationException( - "CheckBox does not support disable on click"); + public void addListener(BlurListener listener) { + addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, + BlurListener.blurMethod); + } + + public void removeListener(BlurListener listener) { + removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); + } + + public void addListener(FocusListener listener) { + addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, + FocusListener.focusMethod); + } + + public void removeListener(FocusListener listener) { + removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + + } + + /** + * Get the boolean value of the checkbox state. + * + * @return True iff the checkbox is checked. + * @deprecated in Vaadin 7.0.0. Retained to ease migration from Vaadin 6 + */ + @Deprecated + public boolean booleanValue() { + // FIXME: How should null really be handled? A default converter that + // converts it to false? The only UI values supported are true and + // false. + Boolean value = (Boolean) getValue(); + return (null == value) ? false : value.booleanValue(); } } diff --git a/src/com/vaadin/ui/NativeButton.java b/src/com/vaadin/ui/NativeButton.java index 6d128b4bb4..40b88951b3 100644 --- a/src/com/vaadin/ui/NativeButton.java +++ b/src/com/vaadin/ui/NativeButton.java @@ -3,7 +3,6 @@ */ package com.vaadin.ui; -import com.vaadin.data.Property; import com.vaadin.terminal.gwt.client.ui.VNativeButton; @SuppressWarnings("serial") @@ -26,30 +25,4 @@ public class NativeButton extends Button { super(caption, target, methodName); } - /** - * Creates a new switch button with initial value. - * - * @param state - * the Initial state of the switch-button. - * @param initialState - * @deprecated use the {@link CheckBox} component instead - */ - @Deprecated - public NativeButton(String caption, boolean initialState) { - super(caption, initialState); - } - - /** - * Creates a new switch button that is connected to a boolean property. - * - * @param state - * the Initial state of the switch-button. - * @param dataSource - * @deprecated use the {@link CheckBox} component instead - */ - @Deprecated - public NativeButton(String caption, Property dataSource) { - super(caption, dataSource); - } - }
\ No newline at end of file |