diff options
author | Henri Sara <hesara@vaadin.com> | 2012-02-19 12:04:42 +0200 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2012-02-19 12:04:42 +0200 |
commit | 1faaa184dc8fbcd551049c78e420a7cfff0ede0e (patch) | |
tree | 99a5424cab7b56e0e3d13dbde664c83ae53a4329 /src/com/vaadin/terminal/gwt/client | |
parent | bc8914066b68e1938ac63606f205672d688be0f1 (diff) | |
parent | e7792742a7bc1e13ceeffb9561f32d9bc01338b2 (diff) | |
download | vaadin-framework-1faaa184dc8fbcd551049c78e420a7cfff0ede0e.tar.gz vaadin-framework-1faaa184dc8fbcd551049c78e420a7cfff0ede0e.zip |
Merge branch 'master' into rpc
Conflicts:
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
Diffstat (limited to 'src/com/vaadin/terminal/gwt/client')
9 files changed, 64 insertions, 37 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index e5006f4a9c..330e4cf5de 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -64,13 +64,23 @@ public class BrowserInfo { browserDetails.setIEMode(documentMode); } } - touchDevice = detectTouchDevice(); + + if (browserDetails.isChrome()) { + touchDevice = detectChromeTouchDevice(); + } else { + touchDevice = detectTouchDevice(); + } } private native boolean detectTouchDevice() /*-{ try { document.createEvent("TouchEvent");return true;} catch(e){return false;}; }-*/; + + private native boolean detectChromeTouchDevice() + /*-{ + return ("ontouchstart" in window); + }-*/; private native int getIEDocumentMode() /*-{ diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index 591016d54d..0c4181066a 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -1238,7 +1238,6 @@ public class Util { * button, false otherwise */ public static boolean isTouchEventOrLeftMouseButton(Event event) { - int eventType = event.getTypeInt(); boolean touchEvent = Util.isTouchEvent(event); return touchEvent || event.getButton() == Event.BUTTON_LEFT; } diff --git a/src/com/vaadin/terminal/gwt/client/VPaintableMap.java b/src/com/vaadin/terminal/gwt/client/VPaintableMap.java index e36d02bb2b..37ddc6dd9a 100644 --- a/src/com/vaadin/terminal/gwt/client/VPaintableMap.java +++ b/src/com/vaadin/terminal/gwt/client/VPaintableMap.java @@ -22,7 +22,6 @@ import com.vaadin.terminal.gwt.client.RenderInformation.Size; public class VPaintableMap { private Map<String, VPaintable> idToPaintable = new HashMap<String, VPaintable>(); - private Map<VPaintable, String> paintableToId = new HashMap<VPaintable, String>(); public static VPaintableMap get(ApplicationConnection applicationConnection) { return applicationConnection.getPaintableMap(); @@ -81,7 +80,6 @@ public class VPaintableMap { */ public void clear() { idToPaintable.clear(); - paintableToId.clear(); idToComponentDetail.clear(); } @@ -99,7 +97,6 @@ public class VPaintableMap { ComponentDetail componentDetail = GWT.create(ComponentDetail.class); idToComponentDetail.put(pid, componentDetail); idToPaintable.put(pid, paintable); - paintableToId.put(paintable, pid); if (paintable instanceof VPaintableWidget) { VPaintableWidget pw = (VPaintableWidget) paintable; setPid(pw.getWidgetForPaintable().getElement(), pid); @@ -122,12 +119,14 @@ public class VPaintableMap { * the paintable who's id is needed * @return the id for the given paintable or null if the paintable could not * be found + * @deprecated use {@link VPaintable#getId()} instead */ + @Deprecated public String getPid(VPaintable paintable) { if (paintable == null) { return null; } - return paintableToId.get(paintable); + return paintable.getId(); } @Deprecated @@ -236,7 +235,6 @@ public class VPaintableMap { // clean reference to paintable idToComponentDetail.remove(pid); idToPaintable.remove(pid); - paintableToId.remove(paintable); } /* * else NOP : same component has been reattached to another @@ -361,7 +359,7 @@ public class VPaintableMap { } public Collection<? extends VPaintable> getPaintables() { - return Collections.unmodifiableCollection(paintableToId.keySet()); + return Collections.unmodifiableCollection(idToPaintable.values()); } /** diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java index ebdb05a6c8..42addc66eb 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java @@ -6,6 +6,7 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.ArrayList; import java.util.Collection; +import com.google.gwt.user.client.ui.HasOneWidget; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.VPaintableMap; @@ -36,15 +37,23 @@ public abstract class VAbstractPaintableWidgetContainer extends if (widget instanceof HasWidgets) { for (Widget child : (HasWidgets) widget) { - VPaintableWidget paintable = paintableMap.getPaintable(child); - if (paintable != null) { - // If child is a paintable, add it to the collection - paintables.add(paintable); - } else { - // Else keep looking for paintables inside the child widget - addDescendantPaintables(child, paintables, paintableMap); - } + addIfPaintable(child, paintables, paintableMap); } + } else if (widget instanceof HasOneWidget) { + Widget child = ((HasOneWidget) widget).getWidget(); + addIfPaintable(child, paintables, paintableMap); + } + } + + private static void addIfPaintable(Widget widget, + Collection<VPaintableWidget> paintables, VPaintableMap paintableMap) { + VPaintableWidget paintable = paintableMap.getPaintable(widget); + if (paintable != null) { + // If widget is a paintable, add it to the collection + paintables.add(paintable); + } else { + // Else keep looking for paintables inside the widget + addDescendantPaintables(widget, paintables, paintableMap); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java b/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java index 320520cb39..c439163595 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCheckBox.java @@ -71,7 +71,10 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements public void onBrowserEvent(Event event) { if (icon != null && (event.getTypeInt() == Event.ONCLICK) && (DOM.eventGetTarget(event) == icon.getElement())) { - setValue(!getValue()); + // Click on icon should do nothing if widget is disabled + if (isEnabled()) { + setValue(!getValue()); + } } super.onBrowserEvent(event); if (event.getTypeInt() == Event.ONLOAD) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index b54c3dd943..5e061175c0 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -1157,9 +1157,11 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * The URI of the icon */ protected void setSelectedItemIcon(String iconUri) { - if (iconUri == null || iconUri == "") { - panel.remove(selectedItemIcon); - updateRootWidth(); + if (iconUri == null || iconUri.length() == 0) { + if (selectedItemIcon.isAttached()) { + panel.remove(selectedItemIcon); + updateRootWidth(); + } } else { panel.insert(selectedItemIcon, 0); selectedItemIcon.setUrl(iconUri); @@ -1616,14 +1618,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ int tbWidth = Util.getRequiredWidth(tb); - if (popupWidth < 0) { - /* - * Only use the first page popup width so the textbox will not - * get resized whenever the popup is resized. - */ - popupWidth = Util.getRequiredWidth(popupOpener); - } - /* * Note: iconWidth is here calculated as a negative pixel value so * you should consider this in further calculations. @@ -1632,7 +1626,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, .measureMarginLeft(tb.getElement()) - Util.measureMarginLeft(selectedItemIcon.getElement()) : 0; - int w = tbWidth + popupWidth + iconWidth; + int w = tbWidth + getPopUpOpenerWidth() + iconWidth; /* * When the select has a undefined with we need to check that we are @@ -1669,6 +1663,20 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } /** + * Only use the first page popup width so the textbox will not get resized + * whenever the popup is resized. This also resolves issue where toggling + * combo box between read only and normal state makes it grow larger. + * + * @return Width of popup opener + */ + private int getPopUpOpenerWidth() { + if (popupWidth < 0) { + popupWidth = Util.getRequiredWidth(popupOpener); + } + return popupWidth; + } + + /** * Get the width of the select in pixels where the text area and icon has * been included. * @@ -1686,10 +1694,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ private void setTextboxWidth(int componentWidth) { int padding = getTextboxPadding(); - int popupOpenerWidth = Util.getRequiredWidth(popupOpener); int iconWidth = selectedItemIcon.isAttached() ? Util .getRequiredWidth(selectedItemIcon) : 0; - int textboxWidth = componentWidth - padding - popupOpenerWidth + + int textboxWidth = componentWidth - padding - getPopUpOpenerWidth() - iconWidth; if (textboxWidth < 0) { textboxWidth = 0; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java index ee8aedd642..eaf9eec16a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java @@ -170,6 +170,7 @@ public class VFilterSelectPaintable extends VAbstractPaintableWidget { getWidgetForPaintable().tb.setValue(""); } } + getWidgetForPaintable().setSelectedItemIcon(null); getWidgetForPaintable().selectedOptionKey = null; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index b84fc1312f..a41fbe3ef9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -274,9 +274,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, int endOfFirstRange = row.getIndex() - 1; if (!(endOfFirstRange - startRow.getIndex() < 0)) { // create range of first part unless its length is < 1 - VScrollTableRow endOfRange = scrollBody - .getRowByRowIndex(endOfFirstRange); - ranges.add(new SelectionRange(startRow, endOfRange)); + ranges.add(new SelectionRange(startRow, endOfFirstRange + - startRow.getIndex() + 1)); } int startOfSecondRange = row.getIndex() + 1; if (!(getEndIndex() - startOfSecondRange < 0)) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java index 809c1a0380..392c500f1d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java @@ -318,12 +318,12 @@ public class VTabsheet extends VTabsheetBase { public Tab addTab() { Tab t = new Tab(this); + int tabIndex = getTabCount(); // Logical attach - int spacerIndex = getTabCount(); - insert(t, tr, spacerIndex, true); + insert(t, tr, tabIndex, true); - if (getTabCount() == 0) { + if (tabIndex == 0) { // Set the "first" style t.setStyleNames(false, true); } |