summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java69
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java114
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java18
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java2
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java31
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java75
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java30
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java58
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java31
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java8
10 files changed, 314 insertions, 122 deletions
diff --git a/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
index de2d9a9cd8..680131c70c 100644
--- a/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
+++ b/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
@@ -139,7 +139,7 @@ public class BrowserInfo {
if (browserDetails.isFirefox()) {
browserIdentifier = BROWSER_FIREFOX;
majorVersionClass = browserIdentifier
- + browserDetails.getBrowserMajorVersion();
+ + getBrowserMajorVersion();
minorVersionClass = majorVersionClass
+ browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_GECKO;
@@ -151,21 +151,21 @@ public class BrowserInfo {
} else if (browserDetails.isSafari()) {
browserIdentifier = BROWSER_SAFARI;
majorVersionClass = browserIdentifier
- + browserDetails.getBrowserMajorVersion();
+ + getBrowserMajorVersion();
minorVersionClass = majorVersionClass
+ browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_WEBKIT;
} else if (browserDetails.isIE()) {
browserIdentifier = BROWSER_IE;
majorVersionClass = browserIdentifier
- + browserDetails.getBrowserMajorVersion();
+ + getBrowserMajorVersion();
minorVersionClass = majorVersionClass
+ browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_TRIDENT;
} else if (browserDetails.isOpera()) {
browserIdentifier = BROWSER_OPERA;
majorVersionClass = browserIdentifier
- + browserDetails.getBrowserMajorVersion();
+ + getBrowserMajorVersion();
minorVersionClass = majorVersionClass
+ browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_PRESTO;
@@ -222,11 +222,11 @@ public class BrowserInfo {
}
public boolean isIE8() {
- return isIE() && browserDetails.getBrowserMajorVersion() == 8;
+ return isIE() && getBrowserMajorVersion() == 8;
}
public boolean isIE9() {
- return isIE() && browserDetails.getBrowserMajorVersion() == 9;
+ return isIE() && getBrowserMajorVersion() == 9;
}
public boolean isChrome() {
@@ -274,7 +274,7 @@ public class BrowserInfo {
return -1;
}
- return browserDetails.getBrowserMajorVersion();
+ return getBrowserMajorVersion();
}
public float getOperaVersion() {
@@ -282,7 +282,7 @@ public class BrowserInfo {
return -1;
}
- return browserDetails.getBrowserMajorVersion();
+ return getBrowserMajorVersion();
}
public boolean isOpera() {
@@ -290,13 +290,11 @@ public class BrowserInfo {
}
public boolean isOpera10() {
- return browserDetails.isOpera()
- && browserDetails.getBrowserMajorVersion() == 10;
+ return browserDetails.isOpera() && getBrowserMajorVersion() == 10;
}
public boolean isOpera11() {
- return browserDetails.isOpera()
- && browserDetails.getBrowserMajorVersion() == 11;
+ return browserDetails.isOpera() && getBrowserMajorVersion() == 11;
}
public native static String getBrowserString()
@@ -387,4 +385,51 @@ public class BrowserInfo {
private int getOperatingSystemMajorVersion() {
return browserDetails.getOperatingSystemMajorVersion();
}
+
+ /**
+ * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome
+ * 4, 8 for Internet Explorer 8.
+ * <p>
+ * Note that Internet Explorer 8 and newer will return the document mode so
+ * IE8 rendering as IE7 will return 7.
+ * </p>
+ *
+ * @return The major version of the browser.
+ */
+ public int getBrowserMajorVersion() {
+ return browserDetails.getBrowserMajorVersion();
+ }
+
+ /**
+ * Returns the browser minor version e.g., 5 for Firefox 3.5.
+ *
+ * @see #getBrowserMajorVersion()
+ *
+ * @return The minor version of the browser, or -1 if not known/parsed.
+ */
+ public int getBrowserMinorVersion() {
+ return browserDetails.getBrowserMinorVersion();
+ }
+
+ /**
+ * Checks if the browser version is newer or equal to the given major+minor
+ * version.
+ *
+ * @param majorVersion
+ * The major version to check for
+ * @param minorVersion
+ * The minor version to check for
+ * @return true if the browser version is newer or equal to the given
+ * version
+ */
+ public boolean isBrowserVersionNewerOrEqual(int majorVersion,
+ int minorVersion) {
+ if (getBrowserMajorVersion() == majorVersion) {
+ // Same major
+ return (getBrowserMinorVersion() >= minorVersion);
+ }
+
+ // Older or newer major
+ return (getBrowserMajorVersion() > majorVersion);
+ }
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java b/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java
index aef21ac737..97201de297 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java
@@ -42,6 +42,14 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
public static class PositionAndSize {
private int left, top, width, height;
+ public PositionAndSize(int left, int top, int width, int height) {
+ super();
+ setLeft(left);
+ setTop(top);
+ setWidth(width);
+ setHeight(height);
+ }
+
public int getLeft() {
return left;
}
@@ -63,6 +71,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
}
public void setWidth(int width) {
+ if (width < 0) {
+ width = 0;
+ }
+
this.width = width;
}
@@ -71,6 +83,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
}
public void setHeight(int height) {
+ if (height < 0) {
+ height = 0;
+ }
+
this.height = height;
}
@@ -192,7 +208,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
return shadow != null;
}
- private void removeShim() {
+ private void removeShimElement() {
if (shimElement != null) {
shimElement.removeFromParent();
}
@@ -211,7 +227,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
return isShadowEnabled() && shadow.getParentElement() != null;
}
- private boolean isShimAttached() {
+ private boolean isShimElementAttached() {
return shimElement != null && shimElement.hasParentElement();
}
@@ -242,11 +258,11 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
style.setMarginLeft(-adjustByRelativeLeftBodyMargin(), Unit.PX);
style.setMarginTop(-adjustByRelativeTopBodyMargin(), Unit.PX);
super.setPopupPosition(left, top);
- sizeOrPositionUpdated(isAnimationEnabled() ? 0 : 1);
+ positionOrSizeUpdated(isAnimationEnabled() ? 0 : 1);
}
private IFrameElement getShimElement() {
- if (shimElement == null) {
+ if (shimElement == null && needsShimElement()) {
shimElement = Document.get().createIFrameElement();
// Insert shim iframe before the main overlay element. It does not
@@ -318,7 +334,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
if (isAnimationEnabled()) {
new ResizeAnimation().run(POPUP_PANEL_ANIMATION_DURATION);
} else {
- sizeOrPositionUpdated(1.0);
+ positionOrSizeUpdated(1.0);
}
}
@@ -328,7 +344,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
// Always ensure shadow is removed when the overlay is removed.
removeShadowIfPresent();
- removeShim();
+ removeShimElement();
}
@Override
@@ -343,13 +359,13 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
@Override
public void setWidth(String width) {
super.setWidth(width);
- sizeOrPositionUpdated(1.0);
+ positionOrSizeUpdated(1.0);
}
@Override
public void setHeight(String height) {
super.setHeight(height);
- sizeOrPositionUpdated(1.0);
+ positionOrSizeUpdated(1.0);
}
/**
@@ -374,8 +390,16 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
* 'setHeight(String)' methods (if not calling super.setWidth/Height).
*
*/
- public void sizeOrPositionUpdated() {
- sizeOrPositionUpdated(1.0);
+ public void positionOrSizeUpdated() {
+ positionOrSizeUpdated(1.0);
+ }
+
+ /**
+ * @deprecated Call {@link #positionOrSizeUpdated()} instead.
+ */
+ @Deprecated
+ protected void updateShadowSizeAndPosition() {
+ positionOrSizeUpdated();
}
/**
@@ -388,7 +412,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
* A value between 0.0 and 1.0, indicating the progress of the
* animation (0=start, 1=end).
*/
- private void sizeOrPositionUpdated(final double progress) {
+ private void positionOrSizeUpdated(final double progress) {
// Don't do anything if overlay element is not attached
if (!isAttached()) {
return;
@@ -413,18 +437,8 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
getOffsetWidth();
}
- PositionAndSize positionAndSize = new PositionAndSize();
- positionAndSize.left = getActualLeft();
- positionAndSize.top = getActualTop();
- positionAndSize.width = getOffsetWidth();
- positionAndSize.height = getOffsetHeight();
-
- if (positionAndSize.width < 0) {
- positionAndSize.width = 0;
- }
- if (positionAndSize.height < 0) {
- positionAndSize.height = 0;
- }
+ PositionAndSize positionAndSize = new PositionAndSize(getActualLeft(),
+ getActualTop(), getOffsetWidth(), getOffsetHeight());
// Animate the size
positionAndSize.setAnimationFromCenterProgress(progress);
@@ -441,29 +455,31 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
// Update correct values
if (isShadowEnabled()) {
- updateSizeAndPosition(shadow, positionAndSize);
+ updatePositionAndSize(shadow, positionAndSize);
DOM.setStyleAttribute(shadow, "zIndex", zIndex);
DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none"
: "");
}
- updateSizeAndPosition((Element) Element.as(getShimElement()),
- positionAndSize);
+ if (needsShimElement()) {
+ updatePositionAndSize((Element) Element.as(getShimElement()),
+ positionAndSize);
+ }
// Opera fix, part 2 (ticket #2704)
if (BrowserInfo.get().isOpera() && isShadowEnabled()) {
// We'll fix the height of all the middle elements
DOM.getChild(shadow, 3)
- .getStyle()
- .setPropertyPx("height",
- DOM.getChild(shadow, 3).getOffsetHeight());
+ .getStyle()
+ .setPropertyPx("height",
+ DOM.getChild(shadow, 3).getOffsetHeight());
DOM.getChild(shadow, 4)
- .getStyle()
- .setPropertyPx("height",
- DOM.getChild(shadow, 4).getOffsetHeight());
+ .getStyle()
+ .setPropertyPx("height",
+ DOM.getChild(shadow, 4).getOffsetHeight());
DOM.getChild(shadow, 5)
- .getStyle()
- .setPropertyPx("height",
- DOM.getChild(shadow, 5).getOffsetHeight());
+ .getStyle()
+ .setPropertyPx("height",
+ DOM.getChild(shadow, 5).getOffsetHeight());
}
// Attach to dom if not there already
@@ -471,25 +487,37 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
RootPanel.get().getElement().insertBefore(shadow, getElement());
sinkShadowEvents();
}
- if (!isShimAttached()) {
+ if (needsShimElement() && !isShimElementAttached()) {
RootPanel.get().getElement()
- .insertBefore(shimElement, getElement());
+ .insertBefore(getShimElement(), getElement());
}
}
- private void updateSizeAndPosition(Element e,
+ /**
+ * 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() {
+ BrowserInfo info = BrowserInfo.get();
+ return info.isIE() && info.isBrowserVersionNewerOrEqual(8, 0);
+ }
+
+ private void updatePositionAndSize(Element e,
PositionAndSize positionAndSize) {
- e.getStyle().setLeft(positionAndSize.left, Unit.PX);
- e.getStyle().setTop(positionAndSize.top, Unit.PX);
- e.getStyle().setWidth(positionAndSize.width, Unit.PX);
- e.getStyle().setHeight(positionAndSize.height, Unit.PX);
+ e.getStyle().setLeft(positionAndSize.getLeft(), Unit.PX);
+ e.getStyle().setTop(positionAndSize.getTop(), Unit.PX);
+ e.getStyle().setWidth(positionAndSize.getWidth(), Unit.PX);
+ e.getStyle().setHeight(positionAndSize.getHeight(), Unit.PX);
}
protected class ResizeAnimation extends Animation {
@Override
protected void onUpdate(double progress) {
- sizeOrPositionUpdated(progress);
+ positionOrSizeUpdated(progress);
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java b/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java
index 9f17b81691..fe47fcca66 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java
@@ -56,8 +56,8 @@ import com.vaadin.terminal.gwt.client.ui.VLazyExecutor;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
public class VMenuBar extends SimpleFocusablePanel implements
- CloseHandler<PopupPanel>, KeyPressHandler, KeyDownHandler,
- FocusHandler, SubPartAware {
+CloseHandler<PopupPanel>, KeyPressHandler, KeyDownHandler,
+FocusHandler, SubPartAware {
// The hierarchy of VMenuBar is a bit weird as VMenuBar is the Paintable,
// used for the root menu but also used for the sub menus.
@@ -94,11 +94,11 @@ public class VMenuBar extends SimpleFocusablePanel implements
private VLazyExecutor iconLoadedExecutioner = new VLazyExecutor(100,
new ScheduledCommand() {
- @Override
- public void execute() {
- iLayout(true);
- }
- });
+ @Override
+ public void execute() {
+ iLayout(true);
+ }
+ });
boolean openRootOnHover;
@@ -188,7 +188,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
itemHTML.append("<img src=\""
+ Util.escapeAttribute(client.translateVaadinUri(item
.getStringAttribute("icon"))) + "\" class=\""
- + Icon.CLASSNAME + "\" alt=\"\" />");
+ + Icon.CLASSNAME + "\" alt=\"\" />");
}
String itemText = item.getStringAttribute("text");
if (!htmlContentAllowed) {
@@ -606,7 +606,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
// popup
style.setWidth(contentWidth + Util.getNativeScrollbarSize(),
Unit.PX);
- popup.sizeOrPositionUpdated();
+ popup.positionOrSizeUpdated();
}
}
return top;
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
index 451e6badbe..6e253c9137 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
@@ -168,7 +168,7 @@ public class VNotification extends VOverlay {
super.show();
notifications.add(this);
setPosition(position);
- sizeOrPositionUpdated();
+ positionOrSizeUpdated();
/**
* Android 4 fails to render notifications correctly without a little
* nudge (#8551)
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java b/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java
index aa7da488d8..345eebc8aa 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java
@@ -4122,8 +4122,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
row.addStyleName("v-selected");
}
tBodyElement.appendChild(row.getElement());
- adopt(row);
+ // Add to renderedRows before adopt so iterator() will return also
+ // this row if called in an attach handler (#9264)
renderedRows.add(row);
+ adopt(row);
}
private void insertRowAt(VScrollTableRow row, int index) {
@@ -5780,16 +5782,39 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
// Hey IE, are you really sure about this?
availW = scrollBody.getAvailableWidth();
int visibleCellCount = tHead.getVisibleCellCount();
- availW -= scrollBody.getCellExtraWidth() * visibleCellCount;
+ int totalExtraWidth = scrollBody.getCellExtraWidth()
+ * visibleCellCount;
if (willHaveScrollbars()) {
- availW -= Util.getNativeScrollbarSize();
+ totalExtraWidth += Util.getNativeScrollbarSize();
}
+ availW -= totalExtraWidth;
+ int forceScrollBodyWidth = -1;
int extraSpace = availW - usedMinimumWidth;
if (extraSpace < 0) {
+ if (getTotalRows() == 0) {
+ /*
+ * Too wide header combined with no rows in the table.
+ *
+ * No horizontal scrollbars would be displayed because
+ * there's no rows that grows too wide causing the
+ * scrollBody container div to overflow. Must explicitely
+ * force a width to a scrollbar. (see #9187)
+ */
+ forceScrollBodyWidth = usedMinimumWidth + totalExtraWidth;
+ }
extraSpace = 0;
}
+ if (forceScrollBodyWidth > 0) {
+ scrollBody.container.getStyle().setWidth(forceScrollBodyWidth,
+ Unit.PX);
+ } else {
+ // Clear width that might have been set to force horizontal
+ // scrolling if there are no rows
+ scrollBody.container.getStyle().clearWidth();
+ }
+
int totalUndefinedNaturalWidths = usedMinimumWidth
- totalExplicitColumnsWidths;
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java
index e061cda1fa..e1df1ba0db 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java
@@ -19,6 +19,10 @@ package com.vaadin.terminal.gwt.client.ui.textarea;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.TextAreaElement;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
@@ -38,10 +42,17 @@ import com.vaadin.terminal.gwt.client.ui.textfield.VTextField;
public class VTextArea extends VTextField {
public static final String CLASSNAME = "v-textarea";
private boolean wordwrap = true;
+ private MaxLengthHandler maxLengthHandler = new MaxLengthHandler();
+ private boolean browserSupportsMaxLengthAttribute = browserSupportsMaxLengthAttribute();
public VTextArea() {
super(DOM.createTextArea());
setStyleName(CLASSNAME);
+ if (!browserSupportsMaxLengthAttribute) {
+ addKeyUpHandler(maxLengthHandler);
+ addChangeHandler(maxLengthHandler);
+ sinkEvents(Event.ONPASTE);
+ }
}
public TextAreaElement getTextAreaElement() {
@@ -52,22 +63,28 @@ public class VTextArea extends VTextField {
getTextAreaElement().setRows(rows);
}
- @Override
- protected void setMaxLength(int newMaxLength) {
- super.setMaxLength(newMaxLength);
+ private class MaxLengthHandler implements KeyUpHandler, ChangeHandler {
- boolean hasMaxLength = (newMaxLength >= 0);
+ @Override
+ public void onKeyUp(KeyUpEvent event) {
+ enforceMaxLength();
+ }
- if (hasMaxLength) {
- sinkEvents(Event.ONKEYUP);
- } else {
- unsinkEvents(Event.ONKEYUP);
+ public void onPaste(Event event) {
+ enforceMaxLength();
}
+
+ @Override
+ public void onChange(ChangeEvent event) {
+ // Opera does not support paste events so this enforces max length
+ // for Opera.
+ enforceMaxLength();
+ }
+
}
- @Override
- public void onBrowserEvent(Event event) {
- if (getMaxLength() >= 0 && event.getTypeInt() == Event.ONKEYUP) {
+ protected void enforceMaxLength() {
+ if (getMaxLength() >= 0) {
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
@@ -77,9 +94,45 @@ public class VTextArea extends VTextField {
}
});
}
+ }
+
+ protected boolean browserSupportsMaxLengthAttribute() {
+ BrowserInfo info = BrowserInfo.get();
+ if (info.isFirefox() && info.isBrowserVersionNewerOrEqual(4, 0)) {
+ return true;
+ }
+ if (info.isSafari() && info.isBrowserVersionNewerOrEqual(5, 0)) {
+ return true;
+ }
+ if (info.isIE() && info.isBrowserVersionNewerOrEqual(10, 0)) {
+ return true;
+ }
+ if (info.isAndroid() && info.isBrowserVersionNewerOrEqual(2, 3)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void updateMaxLength(int maxLength) {
+ if (browserSupportsMaxLengthAttribute) {
+ super.updateMaxLength(maxLength);
+ } else {
+ // Events handled by MaxLengthHandler. This call enforces max length
+ // when the max length value has changed
+ enforceMaxLength();
+ }
+ }
+
+ @Override
+ public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
+ if (event.getTypeInt() == Event.ONPASTE) {
+ maxLengthHandler.onPaste(event);
+ }
}
+
@Override
public int getCursorPos() {
// This is needed so that TextBoxImplIE6 is used to return the correct
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java b/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java
index b00210cdd2..8f07c67c96 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java
@@ -44,7 +44,7 @@ import com.vaadin.terminal.gwt.client.ui.Field;
*
*/
public class VTextField extends TextBoxBase implements Field, ChangeHandler,
- FocusHandler, BlurHandler, KeyDownHandler {
+FocusHandler, BlurHandler, KeyDownHandler {
/**
* The input node CSS classname.
@@ -114,7 +114,7 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
if (listenTextChangeEvents
&& (event.getTypeInt() & TEXTCHANGE_EVENTS) == event
- .getTypeInt()) {
+ .getTypeInt()) {
deferTextChangeEvent();
}
@@ -261,12 +261,32 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
}
protected void setMaxLength(int newMaxLength) {
- if (newMaxLength >= 0) {
+ if (newMaxLength >= 0 && newMaxLength != maxLength) {
maxLength = newMaxLength;
- } else {
+ updateMaxLength(maxLength);
+ } else if (maxLength != -1) {
maxLength = -1;
+ updateMaxLength(maxLength);
+ }
+
+ }
+
+ /**
+ * This method is reponsible for updating the DOM or otherwise ensuring that
+ * the given max length is enforced. Called when the max length for the
+ * field has changed.
+ *
+ * @param maxLength
+ * The new max length
+ */
+ protected void updateMaxLength(int maxLength) {
+ if (maxLength >= 0) {
+ getElement().setPropertyInt("maxLength", maxLength);
+ } else {
+ getElement().removeAttribute("maxLength");
+
}
- setMaxLengthToElement(newMaxLength);
+ setMaxLengthToElement(maxLength);
}
protected void setMaxLengthToElement(int newMaxLength) {
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java b/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java
index 9fbaa1d8bf..40c5e4b8af 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java
@@ -79,8 +79,8 @@ import com.vaadin.terminal.gwt.client.ui.dd.VTransferable;
*
*/
public class VTree extends FocusElementPanel implements VHasDropHandler,
- FocusHandler, BlurHandler, KeyPressHandler, KeyDownHandler,
- SubPartAware, ActionOwner {
+FocusHandler, BlurHandler, KeyPressHandler, KeyDownHandler,
+SubPartAware, ActionOwner {
public static final String CLASSNAME = "v-tree";
@@ -137,12 +137,12 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
public VLazyExecutor iconLoaded = new VLazyExecutor(50,
new ScheduledCommand() {
- @Override
- public void execute() {
- Util.notifyParentOfSizeChange(VTree.this, true);
- }
+ @Override
+ public void execute() {
+ Util.notifyParentOfSizeChange(VTree.this, true);
+ }
- });
+ });
public VTree() {
super();
@@ -601,7 +601,8 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
focus();
}
- ScheduledCommand command = new ScheduledCommand() {
+ executeEventCommand(new ScheduledCommand() {
+
@Override
public void execute() {
@@ -636,17 +637,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
}
}
}
- };
-
- if (BrowserInfo.get().isWebkit() && !treeHasFocus) {
- /*
- * Safari may need to wait for focus. See FocusImplSafari.
- */
- // VConsole.log("Deferring click handling to let webkit gain focus...");
- Scheduler.get().scheduleDeferred(command);
- } else {
- command.execute();
- }
+ });
return true;
}
@@ -677,7 +668,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
&& client.hasEventListeners(VTree.this,
TreeConstants.ITEM_CLICK_EVENT_ID)
- && (type == Event.ONDBLCLICK || type == Event.ONMOUSEUP)) {
+ && (type == Event.ONDBLCLICK || type == Event.ONMOUSEUP)) {
fireClick(event);
}
if (type == Event.ONCLICK) {
@@ -709,7 +700,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
.getEventTarget().cast())) {
if (dragMode > 0
&& (type == Event.ONTOUCHSTART || event
- .getButton() == NativeEvent.BUTTON_LEFT)) {
+ .getButton() == NativeEvent.BUTTON_LEFT)) {
mouseDownEvent = event; // save event for possible
// dd operation
if (type == Event.ONMOUSEDOWN) {
@@ -790,9 +781,12 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
focus();
}
}
+
final MouseEventDetails details = MouseEventDetailsBuilder
.buildMouseEventDetails(evt);
- ScheduledCommand command = new ScheduledCommand() {
+
+ executeEventCommand(new ScheduledCommand() {
+
@Override
public void execute() {
// Determine if we should send the event immediately to the
@@ -820,14 +814,18 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
client.updateVariable(paintableId, "clickEvent",
details.toString(), sendClickEventNow);
}
- };
- if (treeHasFocus) {
- command.execute();
- } else {
- /*
- * Webkits need a deferring due to FocusImplSafari uses timeout
- */
+ });
+ }
+
+ /*
+ * Must wait for Safari to focus before sending click and value change
+ * events (see #6373, #6374)
+ */
+ private void executeEventCommand(ScheduledCommand command) {
+ if (BrowserInfo.get().isWebkit() && !treeHasFocus) {
Scheduler.get().scheduleDeferred(command);
+ } else {
+ command.execute();
}
}
@@ -1723,7 +1721,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
selectNode(
focusedNode,
(!isMultiselect || multiSelectMode == MULTISELECT_MODE_SIMPLE)
- && selectable);
+ && selectable);
} else {
deselectNode(focusedNode);
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java b/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java
index a8621190ae..909acdf85f 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java
@@ -188,8 +188,7 @@ public class VTreeTable extends VScrollTable {
if (isTreeCellAdded) {
return false;
}
- return curColIndex == colIndexOfHierarchy
- + (showRowHeaders ? 1 : 0);
+ return curColIndex == getHierarchyColumnIndex();
}
@Override
@@ -227,6 +226,23 @@ public class VTreeTable extends VScrollTable {
super.onAttach();
if (getIndentWidth() < 0) {
detectIndent(this);
+ // If we detect indent here then the size of the hierarchy
+ // column is still wrong as it has been set when the indent
+ // was not known.
+ int w = getCellWidthFromDom(getHierarchyColumnIndex());
+ if (w >= 0) {
+ setColWidth(getHierarchyColumnIndex(), w);
+ }
+ }
+ }
+
+ private int getCellWidthFromDom(int cellIndex) {
+ final Element cell = DOM.getChild(getElement(), cellIndex);
+ String w = cell.getStyle().getProperty("width");
+ if (w == null || "".equals(w) || !w.endsWith("px")) {
+ return -1;
+ } else {
+ return Integer.parseInt(w.substring(0, w.length() - 2));
}
}
@@ -242,14 +258,21 @@ public class VTreeTable extends VScrollTable {
@Override
protected void setCellWidth(int cellIx, int width) {
- if (cellIx == colIndexOfHierarchy + (showRowHeaders ? 1 : 0)) {
+ if (cellIx == getHierarchyColumnIndex()) {
// take indentation padding into account if this is the
// hierarchy column
- width = Math.max(width - getIndent(), 0);
+ int indent = getIndent();
+ if (indent != -1) {
+ width = Math.max(width - getIndent(), 0);
+ }
}
super.setCellWidth(cellIx, width);
}
+ private int getHierarchyColumnIndex() {
+ return colIndexOfHierarchy + (showRowHeaders ? 1 : 0);
+ }
+
private int getIndent() {
return (depth + 1) * getIndentWidth();
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java
index a1bab91618..3ee266b944 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java
@@ -46,8 +46,8 @@ import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
@Connect(value = com.vaadin.ui.Window.class)
public class WindowConnector extends AbstractComponentContainerConnector
- implements Paintable, BeforeShortcutActionListener,
- SimpleManagedLayout, PostLayoutListener, MayScrollChildren {
+implements Paintable, BeforeShortcutActionListener,
+SimpleManagedLayout, PostLayoutListener, MayScrollChildren {
private ClickEventHandler clickEventHandler = new ClickEventHandler(this) {
@Override
@@ -102,7 +102,7 @@ public class WindowConnector extends AbstractComponentContainerConnector
}
if (!getWidget().isAttached()) {
getWidget().setVisible(false); // hide until
- // possible centering
+ // possible centering
getWidget().show();
}
if (getState().isResizable() != getWidget().resizable) {
@@ -299,7 +299,7 @@ public class WindowConnector extends AbstractComponentContainerConnector
if (window.centered) {
window.center();
}
- window.sizeOrPositionUpdated();
+ window.positionOrSizeUpdated();
}
@Override