From a6aaabefcc63b182287e04789c01b63baf90c243 Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Tue, 24 Apr 2012 14:06:11 +0000 Subject: Applied patch provided for #8600 (hasChildren() broken if item used to have children) and added junit test. Fixes #8600 svn changeset:23624/svn branch:6.8 --- .../server/component/tree/TestHasChildren.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java (limited to 'tests') diff --git a/tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java b/tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java new file mode 100644 index 0000000000..66535d3ffb --- /dev/null +++ b/tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.server.component.tree; + +import junit.framework.TestCase; + +import com.vaadin.ui.Tree; + +public class TestHasChildren extends TestCase { + + private Tree tree; + + @Override + protected void setUp() { + tree = new Tree(); + tree.addItem("parent"); + tree.addItem("child"); + tree.setChildrenAllowed("parent", true); + tree.setParent("child", "parent"); + } + + public void testRemoveChildren() { + assertTrue(tree.hasChildren("parent")); + tree.removeItem("child"); + assertFalse(tree.hasChildren("parent")); + } +} -- cgit v1.2.3 From 935850bc41d42e29b75279a718312dbefc70f405 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 25 Apr 2012 06:21:30 +0000 Subject: Added v-ios and v-android for mobile devices (#7911) svn changeset:23625/svn branch:6.8 --- .../vaadin/terminal/gwt/client/BrowserInfo.java | 66 ++++++++++++++++++++-- .../terminal/gwt/client/VBrowserDetails.java | 51 ++++++++++++++--- .../client/TestVBrowserDetailsUserAgentParser.java | 39 ++++++++++++- 3 files changed, 141 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index 844b4f2e96..a7edee5f32 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -31,6 +31,9 @@ public class BrowserInfo { private static final String OS_LINUX = "lin"; private static final String OS_MACOSX = "mac"; + private static final String MOS_ANDROID = "android"; + private static final String MOS_IOS = "ios"; + private static BrowserInfo instance; private static String cssClass = null; @@ -66,11 +69,11 @@ public class BrowserInfo { browserDetails.setIEMode(documentMode); } } - + if (browserDetails.isChrome()) { - touchDevice = detectChromeTouchDevice(); + touchDevice = detectChromeTouchDevice(); } else { - touchDevice = detectTouchDevice(); + touchDevice = detectTouchDevice(); } } @@ -78,7 +81,7 @@ public class BrowserInfo { /*-{ try { document.createEvent("TouchEvent");return true;} catch(e){return false;}; }-*/; - + private native boolean detectChromeTouchDevice() /*-{ return ("ontouchstart" in window); @@ -169,6 +172,11 @@ public class BrowserInfo { if (osClass != null) { cssClass = cssClass + " " + prefix + osClass; } + + String mosClass = getMobileOperatingSystemClass(); + if (mosClass != null) { + cssClass = cssClass + " " + prefix + mosClass; + } } return cssClass; @@ -186,6 +194,16 @@ public class BrowserInfo { return null; } + private String getMobileOperatingSystemClass() { + if (isAndroid()) { + return MOS_ANDROID; + } else if (browserDetails.isIOS()) { + return MOS_IOS; + } + // Unknown MOS + return null; + } + public boolean isIE() { return browserDetails.isIE(); } @@ -409,4 +427,44 @@ public class BrowserInfo { return touchDevice; } + /** + * Checks if the browser is run on iOS + * + * @return true if the browser is run on iOS, false otherwise + */ + public boolean isIOS() { + return browserDetails.isIOS(); + } + + /** + * Checks if the browser is run on Android + * + * @return true if the browser is run on Android, false otherwise + */ + public boolean isAndroid() { + return browserDetails.isAndroid(); + } + + /** + * Checks if the browser is capable of handling scrolling natively or if a + * touch scroll helper is needed for scrolling. + * + * @return true if browser needs a touch scroll helper, false if the browser + * can handle scrolling natively + */ + public boolean requiresTouchScrollDelegate() { + if (!isTouchDevice()) { + return false; + } + + if (isAndroid() && isWebkit() && getWebkitVersion() < 534) { + return true; + } + // if (isIOS() && isWebkit() && getWebkitVersion() < ???) { + // return true; + // } + + return false; + } + } diff --git a/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java b/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java index aaef981bab..8e9d683baf 100644 --- a/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java +++ b/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java @@ -28,9 +28,16 @@ public class VBrowserDetails implements Serializable { private boolean isOpera = false; private boolean isIE = false; - private boolean isWindows = false; - private boolean isMacOSX = false; - private boolean isLinux = false; + private OperatingSystem os = OperatingSystem.UNKNOWN; + private MobileSystem ms = MobileSystem.UNKNOWN; + + public enum OperatingSystem { + UNKNOWN, WINDOWS, MACOSX, LINUX; + } + + public enum MobileSystem { + UNKNOWN, IOS, ANDROID; + } private float browserEngineVersion = -1; private int browserMajorVersion = -1; @@ -115,13 +122,21 @@ public class VBrowserDetails implements Serializable { // Operating system if (userAgent.contains("windows ")) { - isWindows = true; + os = OperatingSystem.WINDOWS; } else if (userAgent.contains("linux")) { - isLinux = true; + os = OperatingSystem.LINUX; + if (userAgent.contains("android")) { + ms = MobileSystem.ANDROID; + + } } else if (userAgent.contains("macintosh") || userAgent.contains("mac osx") || userAgent.contains("mac os x")) { - isMacOSX = true; + os = OperatingSystem.MACOSX; + if (userAgent.contains("ipad") || userAgent.contains("ipod") + || userAgent.contains("iphone")) { + ms = MobileSystem.IOS; + } } } @@ -281,7 +296,7 @@ public class VBrowserDetails implements Serializable { * @return true if run on Windows, false otherwise */ public boolean isWindows() { - return isWindows; + return os == OperatingSystem.WINDOWS; } /** @@ -290,7 +305,7 @@ public class VBrowserDetails implements Serializable { * @return true if run on Mac OSX, false otherwise */ public boolean isMacOSX() { - return isMacOSX; + return os == OperatingSystem.MACOSX; } /** @@ -299,7 +314,25 @@ public class VBrowserDetails implements Serializable { * @return true if run on Linux, false otherwise */ public boolean isLinux() { - return isLinux; + return os == OperatingSystem.LINUX; + } + + /** + * Tests if the browser is run on Android. + * + * @return true if run on Android, false otherwise + */ + public boolean isAndroid() { + return ms == MobileSystem.ANDROID; + } + + /** + * Tests if the browser is run in iOS. + * + * @return true if run in iOS, false otherwise + */ + public boolean isIOS() { + return ms == MobileSystem.IOS; } } diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java index f661b6cf15..98159775bd 100644 --- a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java +++ b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java @@ -2,8 +2,6 @@ package com.vaadin.terminal.gwt.client; import junit.framework.TestCase; -import com.vaadin.terminal.gwt.client.VBrowserDetails; - public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"; @@ -37,6 +35,9 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String SAFARI3_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29"; private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7"; + private static final String IPHONE_IOS_5_1 = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3"; + private static final String IPAD_IOS_4_3_1 = "Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5"; + public void testSafari3() { VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS); assertWebKit(bd); @@ -57,6 +58,28 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertMacOSX(bd); } + public void testIPhoneIOS5() { + VBrowserDetails bd = new VBrowserDetails(IPHONE_IOS_5_1); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 5); + assertBrowserMinorVersion(bd, 1); + assertEngineVersion(bd, 534f); + assertMacOSX(bd); + assertIOS(bd); + } + + public void testIPadIOS4() { + VBrowserDetails bd = new VBrowserDetails(IPAD_IOS_4_3_1); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 5); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 533f); + assertMacOSX(bd); + assertIOS(bd); + } + public void testChrome3() { VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC); assertWebKit(bd); @@ -352,18 +375,30 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertFalse(browserDetails.isLinux()); assertFalse(browserDetails.isWindows()); assertTrue(browserDetails.isMacOSX()); + assertFalse(browserDetails.isAndroid()); + } + + private void assertIOS(VBrowserDetails browserDetails) { + assertFalse(browserDetails.isLinux()); + assertFalse(browserDetails.isWindows()); + assertTrue(browserDetails.isMacOSX()); + assertTrue(browserDetails.isIOS()); + assertFalse(browserDetails.isAndroid()); } private void assertWindows(VBrowserDetails browserDetails) { assertFalse(browserDetails.isLinux()); assertTrue(browserDetails.isWindows()); assertFalse(browserDetails.isMacOSX()); + assertFalse(browserDetails.isIOS()); + assertFalse(browserDetails.isAndroid()); } private void assertLinux(VBrowserDetails browserDetails) { assertTrue(browserDetails.isLinux()); assertFalse(browserDetails.isWindows()); assertFalse(browserDetails.isMacOSX()); + assertFalse(browserDetails.isIOS()); } } -- cgit v1.2.3 From 4e795bc38ff7ee8a41bd3885eea9ce5de2c281f1 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 25 Apr 2012 07:14:56 +0000 Subject: Add test for $entry and make it ignore some false positives (#8699) svn changeset:23626/svn branch:6.8 --- .../gwt/client/ApplicationConfiguration.java | 1 + src/com/vaadin/terminal/gwt/client/CSSRule.java | 4 +++ .../terminal/gwt/client/ComponentDetailMap.java | 1 + .../vaadin/terminal/gwt/client/ComputedStyle.java | 1 + .../terminal/gwt/client/HistoryImplIEVaadin.java | 4 +++ src/com/vaadin/terminal/gwt/client/ui/VView.java | 1 + .../com/vaadin/tests/server/SourceFileChecker.java | 42 ++++++++++++++++++++++ 7 files changed, 54 insertions(+) (limited to 'tests') diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index a60fb808a1..21ecfe2776 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -270,6 +270,7 @@ public class ApplicationConfiguration implements EntryPoint { var j; for(j in $wnd.vaadin.vaadinConfigurations) { if(!$wnd.vaadin.vaadinConfigurations[j].initialized) { + // $entry not needed as function is not exported list.@java.util.Collection::add(Ljava/lang/Object;)(j); } } diff --git a/src/com/vaadin/terminal/gwt/client/CSSRule.java b/src/com/vaadin/terminal/gwt/client/CSSRule.java index 4d9196c8d6..c36b0611e8 100644 --- a/src/com/vaadin/terminal/gwt/client/CSSRule.java +++ b/src/com/vaadin/terminal/gwt/client/CSSRule.java @@ -33,6 +33,7 @@ public class CSSRule { for(var i = 0; i < sheets.length; i++) { var sheet = sheets[i]; if(sheet.href && sheet.href.indexOf("VAADIN/themes")>-1) { + // $entry not needed as function is not exported this.@com.vaadin.terminal.gwt.client.CSSRule::rules = @com.vaadin.terminal.gwt.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(sheet, selector, deep); return; } @@ -58,6 +59,7 @@ public class CSSRule { // IE handles imported sheet differently if(deep && sheet.imports && sheet.imports.length > 0) { for(var i=0; i < sheet.imports.length; i++) { + // $entry not needed as function is not exported var imports = @com.vaadin.terminal.gwt.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(sheet.imports[i], selector, deep); allMatches.concat(imports); } @@ -83,6 +85,7 @@ public class CSSRule { } } else if(deep && r.type == 3) { // Search @import stylesheet + // $entry not needed as function is not exported var imports = @com.vaadin.terminal.gwt.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(r.styleSheet, selector, deep); allMatches = allMatches.concat(imports); } @@ -102,6 +105,7 @@ public class CSSRule { /*-{ var j = this.@com.vaadin.terminal.gwt.client.CSSRule::rules.length; for(var i=0; i list) /*-{ for(var key in this) { + // $entry not needed as function is not exported list.@java.util.Collection::add(Ljava/lang/Object;)(this[key]); } }-*/; diff --git a/src/com/vaadin/terminal/gwt/client/ComputedStyle.java b/src/com/vaadin/terminal/gwt/client/ComputedStyle.java index e994e47d63..4db3db2adf 100644 --- a/src/com/vaadin/terminal/gwt/client/ComputedStyle.java +++ b/src/com/vaadin/terminal/gwt/client/ComputedStyle.java @@ -179,6 +179,7 @@ public class ComputedStyle { if (isNaN(number)) return null; else + // $entry not needed as function is not exported return @java.lang.Integer::valueOf(I)(number); }-*/; diff --git a/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java b/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java index 0571959339..2e55b4d115 100644 --- a/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java +++ b/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java @@ -123,6 +123,7 @@ public class HistoryImplIEVaadin extends HistoryImpl { // Assume an empty token. var token = ''; // Get the initial token from the url's hash component. + // $entry not needed as function is not exported var hash = @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::getLocationHash()(); if (hash.length > 0) { try { @@ -146,6 +147,7 @@ public class HistoryImplIEVaadin extends HistoryImpl { protected native void navigateFrame(String token) /*-{ + // $entry not needed as function is not exported 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(); @@ -155,6 +157,7 @@ public class HistoryImplIEVaadin extends HistoryImpl { protected native void updateHash(String token) /*-{ + // $entry not needed as function is not exported $wnd.location.hash = this.@com.google.gwt.user.client.impl.HistoryImpl::encodeFragment(Ljava/lang/String;)(token); }-*/; @@ -169,6 +172,7 @@ public class HistoryImplIEVaadin extends HistoryImpl { var historyImplRef = this; var urlChecker = function() { $wnd.setTimeout(urlChecker, 250); + // $entry not needed as function is not exported var hash = @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::getLocationHash()(); if (hash.length > 0) { var token = ''; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 07ade6a8b1..c03652f259 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -657,6 +657,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler, /*-{ var j; for(j in $wnd.vaadin.vaadinConfigurations) { + // $entry not needed as function is not exported list.@java.util.Collection::add(Ljava/lang/Object;)(j); } }-*/; diff --git a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java index 453aab5af8..9906990165 100644 --- a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java +++ b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java @@ -5,6 +5,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.util.HashSet; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import junit.framework.Assert; import junit.framework.TestCase; @@ -81,6 +83,17 @@ public class SourceFileChecker extends TestCase { } } + public void testGwtFilesUsingEntry() { + Set ignore = new HashSet(alwaysIgnore); + ignore.add(externalJavaFiles); + validateFiles( + SRC_DIR, + new GwtEntryChecker(), + ignore, + "The following files might export javscript callbacks without $entry:\n{0}", + ".java"); + } + public interface FileValidator { void validateFile(File f) throws Exception; } @@ -171,4 +184,33 @@ public class SourceFileChecker extends TestCase { } } } + + class GwtEntryChecker extends FileContentsValidator { + // Matches e.g. + // @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::escapeHtml( + private final Matcher matcher = Pattern.compile("@[\\w.]+::\\w+\\(") + .matcher(""); + + @Override + protected void validateContents(File f, String contents) + throws Exception { + matcher.reset(contents); + while (matcher.find()) { + int start = matcher.start(); + + // Search backwards to find index of native block start + int nativeBlockStart = contents.lastIndexOf("/*-{", start); + + // Get contents between block start and our match + String beforeMatchInBlock = contents.substring( + nativeBlockStart, start); + + // Fail if there's no $entry + if (!beforeMatchInBlock.contains("$entry")) { + throw new IllegalArgumentException(); + } + } + } + + } } -- cgit v1.2.3 From e6874b032d1370611e9943f5fa43485bb1b05ea1 Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Wed, 25 Apr 2012 13:11:34 +0000 Subject: Fixes #8693 by applying patch, adds automated test for the case. svn changeset:23631/svn branch:6.8 --- .../terminal/gwt/client/ui/VDateFieldCalendar.java | 7 ++++++ .../components/datefield/InlineDateFields.java | 4 ++++ .../datefield/InlineDateFieldsHiddenOnStart.html | 26 ++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html (limited to 'tests') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java index 91388edcaf..489bc715ed 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java @@ -111,6 +111,13 @@ public class VDateFieldCalendar extends VDateField { */ @SuppressWarnings("deprecation") private void updateValueFromPanel() { + + // If field is invisible at the beginning, client can still be null when + // this function is called. + if (getClient() == null) { + return; + } + Date date2 = calendarPanel.getDate(); Date currentDate = getCurrentDate(); if (currentDate == null || date2.getTime() != currentDate.getTime()) { diff --git a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java index 56f3641043..efda17f7c6 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java @@ -24,6 +24,10 @@ public class InlineDateFields extends ComponentTestCase { @Override protected void initializeComponents() { + InlineDateField hidden = new InlineDateField(); + hidden.setVisible(false); // Used to break rest of layout #8693 + addComponent(hidden); + Locale locale = LOCALES[0]; InlineDateField pd = createInlineDateField("Undefined width", "-1", diff --git a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html new file mode 100644 index 0000000000..6b79ef419b --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html @@ -0,0 +1,26 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.datefield.InlineDateFields?restartApplication
assertElementPresentvaadin=runcomvaadintestscomponentsdatefieldInlineDateFields::PID_SLocale-en_US-undefined-wide/VCalendarPanel[0]#header
+ + -- cgit v1.2.3 From 11cdb557957ee6e9eed30105341ed7dc2c3a6377 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 26 Apr 2012 08:52:41 +0000 Subject: Add support for html in buttons (#8663) svn changeset:23634/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ui/VButton.java | 15 ++++++- .../terminal/gwt/client/ui/VNativeButton.java | 15 ++++++- src/com/vaadin/ui/Button.java | 38 +++++++++++++++++ .../vaadin/tests/components/button/ButtonHtml.html | 47 ++++++++++++++++++++++ .../vaadin/tests/components/button/ButtonHtml.java | 39 ++++++++++++++++++ .../components/nativebutton/NativeButtonHtml.html | 47 ++++++++++++++++++++++ .../components/nativebutton/NativeButtonHtml.java | 41 +++++++++++++++++++ 7 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/button/ButtonHtml.html create mode 100644 tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java create mode 100644 tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.html create mode 100644 tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java (limited to 'tests') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java index 9188f7406a..98103dc41e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java @@ -93,6 +93,11 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, private int clickShortcut = 0; + /** + * If caption should be rendered in HTML + */ + protected boolean htmlCaption = false; + public VButton() { super(DOM.createDiv()); setTabIndex(0); @@ -130,6 +135,10 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, this.client = client; id = uidl.getId(); + // Update HTML value before setting text + htmlCaption = uidl.hasAttribute("html-caption") + && uidl.getBooleanAttribute("html-caption"); + // Set text setText(uidl.getStringAttribute("caption")); @@ -172,7 +181,11 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, } public void setText(String text) { - captionElement.setInnerText(text); + if (htmlCaption) { + captionElement.setInnerHTML(text); + } else { + captionElement.setInnerText(text); + } } @SuppressWarnings("deprecation") diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java index 98d3b505ae..039a0453f2 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java @@ -56,6 +56,11 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, private boolean disableOnClick = false; + /** + * If caption should be rendered in HTML + */ + protected boolean htmlCaption = false; + public VNativeButton() { setStyleName(CLASSNAME); @@ -88,6 +93,10 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, this.client = client; id = uidl.getId(); + // Update HTML value before setting text + htmlCaption = uidl.hasAttribute("html-caption") + && uidl.getBooleanAttribute("html-caption"); + // Set text setText(uidl.getStringAttribute("caption")); @@ -141,7 +150,11 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, @Override public void setText(String text) { - captionElement.setInnerText(text); + if (htmlCaption) { + captionElement.setInnerHTML(text); + } else { + captionElement.setInnerText(text); + } } @Override diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 3c99784592..fdaef046e5 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -45,6 +45,11 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, boolean disableOnClick = false; + /** + * If caption is rendered as HTML + */ + private boolean htmlContentAllowed = false; + /** * Creates a new push button. The value of the push button is false and it * is immediate by default. @@ -156,6 +161,10 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, if (clickShortcut != null) { target.addAttribute("keycode", clickShortcut.getKeyCode()); } + + if (isHtmlContentAllowed()) { + target.addAttribute("html-caption", true); + } } /** @@ -694,4 +703,33 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, requestRepaint(); } + /** + * Set whether the caption text is rendered as HTML or not. You might need + * to retheme button to allow higher content than the original text style. + * + * If set to true, the captions are passed to the browser as html and the + * developer is responsible for ensuring no harmful html is used. If set to + * false, the content is passed to the browser as plain text. + * + * @param htmlContentAllowed + * true if caption is rendered as HTML, + * false otherwise + */ + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + if (this.htmlContentAllowed != htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + requestRepaint(); + } + } + + /** + * Return HTML rendering setting + * + * @return true if the caption text is to be rendered as HTML, + * false otherwise + */ + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + } diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.html b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.html new file mode 100644 index 0000000000..2d58d0e2e1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.html @@ -0,0 +1,47 @@ + + + + + + +ButtonHtml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ButtonHtml
open/run/com.vaadin.tests.components.button.ButtonHtml?restartApplication
screenCaptureinitial
clickvaadin=runcomvaadintestscomponentsbuttonButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
screenCaptureafter_1_click
clickvaadin=runcomvaadintestscomponentsbuttonButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]/domChild[0]
screenCaptureafter_2_clicks
+ + diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java new file mode 100644 index 0000000000..253de5b43c --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.button; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class ButtonHtml extends TestBase { + + @Override + protected void setup() { + Button b = new Button("Plain text button"); + addComponent(b); + + b = new Button( + "HTML button"); + b.setHtmlContentAllowed(true); + addComponent(b); + + final Button swapButton = new Button("Swap button"); + swapButton.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + swapButton.setHtmlContentAllowed(!swapButton + .isHtmlContentAllowed()); + } + }); + addComponent(swapButton); + } + + @Override + protected String getDescription() { + return "Verify that Button HTML rendering works"; + } + + @Override + protected Integer getTicketNumber() { + return 8663; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.html b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.html new file mode 100644 index 0000000000..8a1b21c35d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.html @@ -0,0 +1,47 @@ + + + + + + +NativeButtonHtml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NativeButtonHtml
open/run/com.vaadin.tests.components.nativebutton.NativeButtonHtml?restartApplication
screenCaptureinitial
mouseClickvaadin=runcomvaadintestscomponentsnativebuttonNativeButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VNativeButton[0]116,9
screenCaptureafter_1_click
mouseClickvaadin=runcomvaadintestscomponentsnativebuttonNativeButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VNativeButton[0]74,10
screenCaptureafter_2_clicks
+ + diff --git a/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java new file mode 100644 index 0000000000..011439f810 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java @@ -0,0 +1,41 @@ +package com.vaadin.tests.components.nativebutton; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.NativeButton; + +public class NativeButtonHtml extends TestBase { + + @Override + protected void setup() { + NativeButton b = new NativeButton("Plain text button"); + addComponent(b); + + b = new NativeButton( + "HTML button"); + b.setHtmlContentAllowed(true); + addComponent(b); + + final NativeButton swapButton = new NativeButton("Swap button"); + swapButton.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + swapButton.setHtmlContentAllowed(!swapButton + .isHtmlContentAllowed()); + } + }); + addComponent(swapButton); + } + + @Override + protected String getDescription() { + return "Verify that NativeButton HTML rendering works"; + } + + @Override + protected Integer getTicketNumber() { + // 8663 was for normal button (see ButtonHtml test) + return null; + } +} -- cgit v1.2.3 From c8e8a88211c58787fe8b23c2c39848dcc36e34ff Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 26 Apr 2012 13:11:45 +0000 Subject: Functions for reporting Android and iOS version (#8716) svn changeset:23642/svn branch:6.8 --- .../vaadin/terminal/gwt/client/BrowserInfo.java | 15 ++++ .../terminal/gwt/client/VBrowserDetails.java | 79 ++++++++++++++++++ .../client/TestVBrowserDetailsUserAgentParser.java | 93 ++++++++++++++++++++-- 3 files changed, 181 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index a2e5bffe39..8ec610c089 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -456,4 +456,19 @@ public class BrowserInfo { return false; } + /** + * Tests if this is an Android devices with a broken scrollTop + * implementation + * + * @return true if scrollTop cannot be trusted on this device, false + * otherwise + */ + public boolean isAndroidWithBrokenScrollTop() { + return isAndroid() + && (getOperatingSystemMajorVersion() == 3 || getOperatingSystemMajorVersion() == 4); + } + + private int getOperatingSystemMajorVersion() { + return browserDetails.getOperatingSystemMajorVersion(); + } } diff --git a/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java b/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java index fa5fdc6d47..1212447a65 100644 --- a/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java +++ b/src/com/vaadin/terminal/gwt/client/VBrowserDetails.java @@ -38,6 +38,9 @@ public class VBrowserDetails implements Serializable { private int browserMajorVersion = -1; private int browserMinorVersion = -1; + private int osMajorVersion = -1; + private int osMinorVersion = -1; + /** * Create an instance based on the given user agent. * @@ -121,6 +124,7 @@ public class VBrowserDetails implements Serializable { } else if (userAgent.contains("linux")) { if (userAgent.contains("android")) { os = OperatingSystem.ANDROID; + parseAndroidVersion(userAgent); } else { os = OperatingSystem.LINUX; @@ -131,12 +135,67 @@ public class VBrowserDetails implements Serializable { if (userAgent.contains("ipad") || userAgent.contains("ipod") || userAgent.contains("iphone")) { os = OperatingSystem.IOS; + parseIOSVersion(userAgent); } else { os = OperatingSystem.MACOSX; } } } + private void parseAndroidVersion(String userAgent) { + // Android 5.1; + if (!userAgent.contains("android")) { + return; + } + + String osVersionString = safeSubstring(userAgent, + userAgent.indexOf("android ") + "android ".length(), + userAgent.length()); + osVersionString = safeSubstring(osVersionString, 0, + osVersionString.indexOf(";")); + String[] parts = osVersionString.split("\\."); + parseOsVersion(parts); + } + + private void parseIOSVersion(String userAgent) { + // OS 5_1 like Mac OS X + if (!userAgent.contains("os ") || !userAgent.contains(" like mac")) { + return; + } + + String osVersionString = safeSubstring(userAgent, + userAgent.indexOf("os ") + 3, userAgent.indexOf(" like mac")); + String[] parts = osVersionString.split("_"); + parseOsVersion(parts); + } + + private void parseOsVersion(String[] parts) { + osMajorVersion = -1; + osMinorVersion = -1; + + if (parts.length >= 1) { + try { + osMajorVersion = Integer.parseInt(parts[0]); + } catch (Exception e) { + } + } + if (parts.length >= 2) { + try { + osMinorVersion = Integer.parseInt(parts[1]); + } catch (Exception e) { + } + // Some Androids report version numbers as "2.1-update1" + if (osMinorVersion == -1 && parts[1].contains("-")) { + try { + osMinorVersion = Integer.parseInt(parts[1].substring(0, + parts[1].indexOf('-'))); + } catch (Exception ee) { + } + } + } + + } + private void parseVersionString(String versionString) { int idx = versionString.indexOf('.'); if (idx < 0) { @@ -332,4 +391,24 @@ public class VBrowserDetails implements Serializable { return os == OperatingSystem.IOS; } + /** + * Returns the major version of the operating system. Currently only + * supported for mobile devices (iOS/Android) + * + * @return The major version or -1 if unknown + */ + public int getOperatingSystemMajorVersion() { + return osMajorVersion; + } + + /** + * Returns the minor version of the operating system. Currently only + * supported for mobile devices (iOS/Android) + * + * @return The minor version or -1 if unknown + */ + public int getOperatingSystemMinorVersion() { + return osMinorVersion; + } + } diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java index 98159775bd..fedce98ecf 100644 --- a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java +++ b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java @@ -36,8 +36,14 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7"; private static final String IPHONE_IOS_5_1 = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3"; + private static final String IPHONE_IOS_4_0 = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7"; private static final String IPAD_IOS_4_3_1 = "Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5"; + private static final String ANDROID_HTC_2_1 = "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; ADR6300 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"; + private static final String ANDROID_GOOGLE_NEXUS_2_2 = "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"; + private static final String ANDROID_MOTOROLA_3_0 = "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13"; + private static final String ANDROID_GALAXY_NEXUS_4_0_4_CHROME = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"; + public void testSafari3() { VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS); assertWebKit(bd); @@ -65,8 +71,17 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertBrowserMajorVersion(bd, 5); assertBrowserMinorVersion(bd, 1); assertEngineVersion(bd, 534f); - assertMacOSX(bd); - assertIOS(bd); + assertIOS(bd, 5, 1); + } + + public void testIPhoneIOS4() { + VBrowserDetails bd = new VBrowserDetails(IPHONE_IOS_4_0); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 532f); + assertIOS(bd, 4, 0); } public void testIPadIOS4() { @@ -76,8 +91,57 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertBrowserMajorVersion(bd, 5); assertBrowserMinorVersion(bd, 0); assertEngineVersion(bd, 533f); - assertMacOSX(bd); - assertIOS(bd); + assertIOS(bd, 4, 3); + } + + public void testAndroid21() { + VBrowserDetails bd = new VBrowserDetails(ANDROID_HTC_2_1); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 530f); + assertAndroid(bd, 2, 1); + + } + + public void testAndroid22() { + VBrowserDetails bd = new VBrowserDetails(ANDROID_GOOGLE_NEXUS_2_2); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 533f); + assertAndroid(bd, 2, 2); + } + + public void testAndroid30() { + VBrowserDetails bd = new VBrowserDetails(ANDROID_MOTOROLA_3_0); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 534f); + assertAndroid(bd, 3, 0); + } + + public void testAndroid40Chrome() { + VBrowserDetails bd = new VBrowserDetails( + ANDROID_GALAXY_NEXUS_4_0_4_CHROME); + assertWebKit(bd); + assertChrome(bd); + assertBrowserMajorVersion(bd, 18); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 535f); + assertAndroid(bd, 4, 0); + } + + private void assertOSMajorVersion(VBrowserDetails bd, int i) { + assertEquals(i, bd.getOperatingSystemMajorVersion()); + } + + private void assertOSMinorVersion(VBrowserDetails bd, int i) { + assertEquals(i, bd.getOperatingSystemMinorVersion()); } public void testChrome3() { @@ -378,12 +442,28 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertFalse(browserDetails.isAndroid()); } - private void assertIOS(VBrowserDetails browserDetails) { + private void assertAndroid(VBrowserDetails browserDetails, + int majorVersion, int minorVersion) { assertFalse(browserDetails.isLinux()); assertFalse(browserDetails.isWindows()); - assertTrue(browserDetails.isMacOSX()); + assertFalse(browserDetails.isMacOSX()); + assertFalse(browserDetails.isIOS()); + assertTrue(browserDetails.isAndroid()); + + assertOSMajorVersion(browserDetails, majorVersion); + assertOSMinorVersion(browserDetails, minorVersion); + } + + private void assertIOS(VBrowserDetails browserDetails, int majorVersion, + int minorVersion) { + assertFalse(browserDetails.isLinux()); + assertFalse(browserDetails.isWindows()); + assertFalse(browserDetails.isMacOSX()); assertTrue(browserDetails.isIOS()); assertFalse(browserDetails.isAndroid()); + + assertOSMajorVersion(browserDetails, majorVersion); + assertOSMinorVersion(browserDetails, minorVersion); } private void assertWindows(VBrowserDetails browserDetails) { @@ -399,6 +479,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertFalse(browserDetails.isWindows()); assertFalse(browserDetails.isMacOSX()); assertFalse(browserDetails.isIOS()); + assertFalse(browserDetails.isAndroid()); } } -- cgit v1.2.3 From bc06045297c00666447a39f6fa43d67516a005e4 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 26 Apr 2012 13:30:35 +0000 Subject: Improved touch scrolling test application (#8716, #8720, #8721, #8722, #8723, #8724, #8725) svn changeset:23644/svn branch:6.8 --- .../vaadin/tests/components/TouchScrollables.java | 175 +++++++++++++-------- 1 file changed, 111 insertions(+), 64 deletions(-) (limited to 'tests') diff --git a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java index 88335a1996..52f5a7c067 100644 --- a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java +++ b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java @@ -15,27 +15,103 @@ import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; import com.vaadin.tests.util.Person; import com.vaadin.tests.util.PersonContainer; import com.vaadin.tests.util.TestUtils; -import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; +import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; -import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; +import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; public class TouchScrollables extends TestBase { java.util.Random r = new java.util.Random(1); - private HorizontalLayout testSelector; + private TabSheet testSelector = new TabSheet(); @Override public void setup() { - testSelector = new HorizontalLayout(); getLayout().addComponent(testSelector); + testSelector.setHeight("500px"); + addTest(getPanelTest()); + addTest(getSimpleTableTest()); + addTest(getDDSortableTableTest()); + addTest(getTabSheetTest()); + addTest(getSplitPanelTest()); + addTest(getAccordionTest()); + addTest(getSubWindowTest()); + + TestUtils + .injectCSS( + getLayout().getWindow(), + "body * {-webkit-user-select: none;} .v-table-row-drag-middle .v-table-cell-content {" + + " background-color: inherit ; border-bottom: 1px solid cyan;" + + "}" + + ".v-table-row-drag-middle .v-table-cell-wrapper {" + + " margin-bottom: -1px;" + "}" + "" + + ); + } + + private Component getPanelTest() { + Layout cssLayout = new CssLayout(); + cssLayout.setCaption("Panel"); + + final Panel p = new Panel(); + p.setScrollable(true); + p.setHeight("400px"); + Label l50 = null; + for (int i = 0; i < 100; i++) { + Label c = new Label("Label" + i); + p.addComponent(c); + if (i == 50) { + l50 = c; + } + } + + final Label l = l50; + Button button = new Button("Scroll to label 50", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getLayout().getWindow().scrollIntoView(l); + } + }); + cssLayout.addComponent(button); + button = new Button("Scroll to 100px", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + p.setScrollTop(100); + } + }); + cssLayout.addComponent(button); + cssLayout.addComponent(p); + return cssLayout; + } + + private Component getTabSheetTest() { + TabSheet ts = new TabSheet(); + ts.setCaption("Tabsheet"); + ts.setHeight("100%"); + ts.addTab(getBigComponent(), "Tab 1"); + ts.addTab(getBigComponent(), "Tab 2"); + return ts; + } + + private Component getSplitPanelTest() { + HorizontalSplitPanel sp = new HorizontalSplitPanel(); + sp.setCaption("Splitpanel"); + sp.addComponent(getBigComponent()); + sp.addComponent(getBigComponent()); + return sp; + } + + private Component getSimpleTableTest() { CssLayout cssLayout = new CssLayout(); final Table table = new Table(); @@ -68,58 +144,33 @@ public class TouchScrollables extends TestBase { } cssLayout.addComponent(table); cssLayout.setCaption("Table"); + return cssLayout; + } - addTest(cssLayout); - - cssLayout = new CssLayout(); - cssLayout.setCaption("Panel"); - - final Panel p = new Panel(); - p.setScrollable(true); - p.setHeight("400px"); - p.setCaption("Panel"); - Label l50 = null; - for (int i = 0; i < 100; i++) { - Label c = new Label("Label" + i); - p.addComponent(c); - if (i == 50) { - l50 = c; - } - } + private Component getAccordionTest() { + Accordion a = new Accordion(); + a.setCaption("Accordion"); + a.setHeight("100%"); + a.addTab(getBigComponent(), "Tab 1"); + a.addTab(getBigComponent(), "Tab 2"); + a.addTab(getBigComponent(), "Tab 3"); + return a; + } - final Label l = l50; - button = new Button("Scroll to label 50", new Button.ClickListener() { + private Component getSubWindowTest() { + Button b = new Button("Open subwindow", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - getLayout().getWindow().scrollIntoView(l); + Window w = new Window("Subwindow"); + w.center(); + w.setHeight("200px"); + w.addComponent(getBigComponent()); + getMainWindow().addWindow(w); } }); - cssLayout.addComponent(button); - button = new Button("Scroll to 100px", new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - p.setScrollTop(100); - } - }); - cssLayout.addComponent(button); - cssLayout.addComponent(p); - - addTest(cssLayout); - - TestUtils - .injectCSS( - getLayout().getWindow(), - "body * {-webkit-user-select: none;} .v-table-row-drag-middle .v-table-cell-content {" - + " background-color: inherit ; border-bottom: 1px solid cyan;" - + "}" - + ".v-table-row-drag-middle .v-table-cell-wrapper {" - + " margin-bottom: -1px;" + "}" + "" - - ); - - addDDSortableTable(); - + return b; } - private void addDDSortableTable() { + private Component getDDSortableTableTest() { final Table table; table = new Table(); table.setCaption("DD sortable table with context menus"); @@ -220,7 +271,7 @@ public class TouchScrollables extends TestBase { } }); - addTest(table); + return table; } private void populateTable(Table table) { @@ -239,21 +290,17 @@ public class TouchScrollables extends TestBase { } - private Component testComponent; - - private void addTest(final AbstractComponent t) { - Button button = new Button(t.getCaption()); - testSelector.addComponent(button); - button.addListener(new Button.ClickListener() { + private void addTest(final Component t) { + testSelector.addComponent(t); + } - public void buttonClick(ClickEvent event) { - if (testComponent != null) { - getLayout().removeComponent(testComponent); - } - testComponent = t; - getLayout().addComponent(t); - } - }); + private Component getBigComponent() { + Layout l = new VerticalLayout(); + for (int i = 0; i < 100; i++) { + Label c = new Label("Label" + i); + l.addComponent(c); + } + return l; } @Override -- cgit v1.2.3 From 48893c2135d66a0de2c24acec3e7fb659ec85f7f Mon Sep 17 00:00:00 2001 From: Automerge Date: Fri, 27 Apr 2012 11:39:21 +0000 Subject: [merge from 6.7] Use equals instead of == to compare item ids (#8712). Using == will fail at least with JPAContainer as the entity provider provides the id instances and it is not guaranteed that the same instance is returned every time (e.g. if using a Long the longs represent the same number but are not the same instance) svn changeset:23655/svn branch:6.8 --- src/com/vaadin/ui/Table.java | 2 +- ...TableWithContainerRequiringEqualsForItemId.html | 97 ++++++++++++++++ ...TableWithContainerRequiringEqualsForItemId.java | 128 +++++++++++++++++++++ 3 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java (limited to 'tests') diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index e605ec4f6b..7828fdb734 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -1819,7 +1819,7 @@ public class Table extends AbstractSelect implements Action.Container, if (index < firstIndexNotInCache && index >= pageBufferFirstIndex && pageBuffer[CELL_GENERATED_ROW][indexInOldBuffer] == null - && pageBuffer[CELL_ITEMID][indexInOldBuffer] == id) { + && id.equals(pageBuffer[CELL_ITEMID][indexInOldBuffer])) { // we already have data in our cache, // recycle it instead of fetching it via // getValue/getPropertyValue diff --git a/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html new file mode 100644 index 0000000000..5364b1cd1e --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html @@ -0,0 +1,97 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.TableWithContainerRequiringEqualsForItemId?debug&restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[0]523,81
clickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_01. Button Button999 clicked
clickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_02. Button Button985 clicked
mouseClickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]19,7
contextmenuvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]0
clickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_03. Button Button0 clicked
mouseClickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]8,15
contextmenuvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]999
clickvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_04. Button Button999 clicked
+ + diff --git a/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java new file mode 100644 index 0000000000..1b0335b673 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java @@ -0,0 +1,128 @@ +package com.vaadin.tests.components.table; + +import java.util.Date; + +import com.vaadin.data.util.BeanContainer; +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Component; +import com.vaadin.ui.Table; +import com.vaadin.ui.themes.Reindeer; + +public class TableWithContainerRequiringEqualsForItemId extends TestBase { + + private MyEntityContainer container = new MyEntityContainer(); + private Log log = new Log(10); + + public static class MyEntityContainer extends BeanContainer { + + public MyEntityContainer() { + super(MyEntity.class); + setBeanIdResolver(new BeanIdResolver() { + + public Long getIdForBean(MyEntity bean) { + // Return a new instance every time to ensure Table can + // handle it + return new Long(bean.getId()); + } + }); + + } + + @Override + public Long getIdByIndex(int index) { + // Explicitly get the id using the resolver to make sure the + // instance does not stay the same + BeanItem beanItem = getItem(super.getIdByIndex(index)); + return getBeanIdResolver().getIdForBean(beanItem.getBean()); + }; + + } + + @Override + protected void setup() { + Table t = new Table("Table with 1000 item"); + t.addGeneratedColumn("Actions", new Table.ColumnGenerator() { + public Component generateCell(final Table source, + final Object itemId, final Object columnId) { + Button tripFolderLink = new Button("Button" + itemId); + tripFolderLink.addListener(new Button.ClickListener() { + public void buttonClick(final ClickEvent event) { + log.log("Button " + event.getButton().getCaption() + + " clicked"); + } + }); + tripFolderLink.setStyleName(Reindeer.BUTTON_SMALL); + return tripFolderLink; + } + }); + + for (int i = 0; i < 1000; i++) { + MyEntity myEntity = new MyEntity(i + "st"); + myEntity.setCreated(new Date(new Date().getTime() - 24 * 60 * 60 + * 1000L)); + myEntity.setId(i); + container.addBean(myEntity); + // entityProvider.addEntity(myEntity); + } + + t.setContainerDataSource(container); + t.setVisibleColumns(new String[] { "id", "created", "name", "Actions" }); + + addComponent(t); + addComponent(log); + + t.sort(new Object[] { "id" }, new boolean[] { false }); + + } + + @Override + protected String getDescription() { + return "Test that verifies that Table works correctly with containers which do not return the same instance of the itemId object but instead requires an itemId.equals(otherItemId) check"; + } + + @Override + protected Integer getTicketNumber() { + return 8712; + } + + public static class MyEntity { + + private long id; + + private String name; + + private Date created; + + public MyEntity() { + } + + public MyEntity(String string) { + name = string; + } + + public String getName() { + return name; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + } + +} -- cgit v1.2.3 From f4f4783d7f3e65c5395a519778f231c3e528cb6c Mon Sep 17 00:00:00 2001 From: Automerge Date: Fri, 27 Apr 2012 11:39:27 +0000 Subject: [merge from 6.7] Fix and test case for #8619: Add sanity checks to GridLayout to handle cases where the size of a relative-size child unexpectedly changes svn changeset:23656/svn branch:6.8 --- .../vaadin/terminal/gwt/client/ui/VGridLayout.java | 17 ++++-- .../combobox/GridLayoutComboBoxZoomOut.java | 61 ++++++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java (limited to 'tests') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java index 82b3eabf40..ba37148c36 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java @@ -29,6 +29,7 @@ import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.StyleConstants; import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; +import com.vaadin.terminal.gwt.client.VConsole; import com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout; import com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer; @@ -768,7 +769,11 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { allocated += spacingPixelsHorizontal + columnWidths[cell.col + i]; } - if (allocated < width) { + if (cell.hasRelativeWidth() && allocated != width) { + // This may happen e.g. when browser zoomout causes pixel + // rounding issues, see #8619 + VConsole.error("A relative-width child should never cause cell width to change!"); + } else if (allocated < width) { needsLayout = true; if (cell.colspan == 1) { // do simple column width expansion @@ -777,7 +782,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { // mark that col span expansion is needed reDistributeColSpanWidths = true; } - } else if (allocated != width) { + } else if (allocated > width) { // size is smaller thant allocated, column might // shrink dirtyColumns.add(cell.col); @@ -790,7 +795,11 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { allocated += spacingPixelsVertical + rowHeights[cell.row + i]; } - if (allocated < height) { + if (cell.hasRelativeHeight() && allocated != height) { + // This may happen e.g. when browser zoomout causes pixel + // rounding issues, see #8619 + VConsole.error("A relative-height child should never cause cell height to change!"); + } else if (allocated < height) { needsLayout = true; if (cell.rowspan == 1) { // do simple row expansion @@ -799,7 +808,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { // mark that row span expansion is needed reDistributeRowSpanHeights = true; } - } else if (allocated != height) { + } else if (allocated > height) { // size is smaller than allocated, row might shrink dirtyRows.add(cell.row); } diff --git a/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java new file mode 100644 index 0000000000..a192f1a3a6 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java @@ -0,0 +1,61 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; +import com.vaadin.ui.Select; +import com.vaadin.ui.Window; + +@SuppressWarnings("serial") +public class GridLayoutComboBoxZoomOut extends TestBase { + + @Override + public void setup() { + Window mainWindow = new Window("Gridlayoutbug Application"); + setMainWindow(mainWindow); + + Label description = new Label( + "Open this application in Chrome, zoom out (cmd + \"-\") and " + + "open the ComboBox for weird behaviour."); + mainWindow.addComponent(description); + + Layout formLayout = new GridLayout(2, 1); + // formLayout.setWidth("100%"); + formLayout.setWidth("1000px"); + + Select countryField = new ComboBox(); + countryField.addItem("Finland"); + countryField.addItem("Sweden"); + countryField.addItem("Canada"); + countryField.addItem("USA"); + countryField.setCaption("Country"); + countryField.setWidth("100%"); + formLayout.addComponent(countryField); + + Select statusField = new ComboBox(); + statusField.addItem("Available"); + statusField.addItem("On vacation"); + statusField.addItem("Busy"); + statusField.addItem("Left the building"); + statusField.setCaption("Status"); + statusField.setWidth("100%"); + formLayout.addComponent(statusField); + + mainWindow.addComponent(formLayout); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} -- cgit v1.2.3 From d64d9fdde949292da0fe490b784a742957305fab Mon Sep 17 00:00:00 2001 From: Automerge Date: Fri, 27 Apr 2012 13:06:26 +0000 Subject: [merge from 6.7] Simplified test case for #8730 svn changeset:23660/svn branch:6.8 --- .../vaadin/tests/dd/NotPaintedAcceptSource.java | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java (limited to 'tests') diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java new file mode 100644 index 0000000000..d6d49e018c --- /dev/null +++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java @@ -0,0 +1,90 @@ +package com.vaadin.tests.dd; + +import com.vaadin.data.Item; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.event.dd.acceptcriteria.SourceIs; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.TableDragMode; +import com.vaadin.ui.Table.TableTransferable; + +public class NotPaintedAcceptSource extends TestBase { + + @Override + protected void setup() { + final Table source1 = createTable("Source 1"); + final Table source2 = createTable("Source 2"); + final Table target = createTable("Target"); + + source1.setDragMode(TableDragMode.ROW); + source2.setDragMode(TableDragMode.ROW); + + target.setDropHandler(new DropHandler() { + public AcceptCriterion getAcceptCriterion() { + return new SourceIs(source1, source2); + } + + public void drop(DragAndDropEvent event) { + TableTransferable transferable = (TableTransferable) event + .getTransferable(); + Item item = transferable.getSourceComponent().getItem( + transferable.getItemId()); + Object value = item.getItemProperty("value").getValue(); + AbstractSelectTargetDetails targetDetails = (AbstractSelectTargetDetails) event + .getTargetDetails(); + Object targetItemId = targetDetails.getItemIdOver(); + Object addItemAfter = target.addItemAfter(targetItemId); + target.getItem(addItemAfter).getItemProperty("value") + .setValue(value); + transferable.getSourceComponent().removeItem( + transferable.getItemId()); + } + }); + + final HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSpacing(true); + horizontalLayout.addComponent(source1); + horizontalLayout.addComponent(target); + + addComponent(horizontalLayout); + + addComponent(new Button("Swap sources", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + if (source1.getParent() != null) { + horizontalLayout.replaceComponent(source1, source2); + } else { + horizontalLayout.replaceComponent(source2, source1); + } + } + })); + + } + + private Table createTable(String caption) { + Table table = new Table(caption); + table.addContainerProperty("value", String.class, ""); + for (int i = 0; i < 10; i++) { + table.addItem(new Object[] { caption + " value " + i }, + Integer.valueOf(i)); + } + table.setWidth("300px"); + return table; + } + + @Override + protected String getDescription() { + return "Including a component in an accept criterion when the actual component is not included in a layout and thus not painted should still allow painting the component properly when it is added to a layout."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8730); + } + +} -- cgit v1.2.3 From ab6017f8a9922e5b3421035a087ba68fb14e9200 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 2 May 2012 09:52:01 +0000 Subject: Test using Firefox 12 (#8739) svn changeset:23665/svn branch:6.8 --- tests/test.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test.xml b/tests/test.xml index fbb0a3a019..acbbe672ef 100644 --- a/tests/test.xml +++ b/tests/test.xml @@ -5,7 +5,7 @@ - + -- cgit v1.2.3 From 015306c0e2bcc8701a352a331e78deb0c867f924 Mon Sep 17 00:00:00 2001 From: Automerge Date: Thu, 3 May 2012 13:06:20 +0000 Subject: [merge from 6.7] Don't paint references to orphan components #8730 svn changeset:23668/svn branch:6.8 --- .../vaadin/event/dd/acceptcriteria/SourceIs.java | 27 ++++++-- .../terminal/gwt/server/JsonPaintTarget.java | 9 +++ .../vaadin/tests/dd/NotPaintedAcceptSource.html | 71 ++++++++++++++++++++++ .../vaadin/tests/dd/NotPaintedAcceptSource.java | 1 + 4 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html (limited to 'tests') diff --git a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java index 8562bc70ec..0d29e9a327 100644 --- a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java +++ b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java @@ -6,6 +6,9 @@ */ package com.vaadin.event.dd.acceptcriteria; +import java.util.logging.Level; +import java.util.logging.Logger; + import com.vaadin.event.TransferableImpl; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.terminal.PaintException; @@ -22,27 +25,39 @@ import com.vaadin.ui.Component; @SuppressWarnings("serial") @ClientCriterion(VDragSourceIs.class) public class SourceIs extends ClientSideCriterion { + private static final Logger logger = Logger.getLogger(SourceIs.class + .getName()); - private Component[] component; + private Component[] components; public SourceIs(Component... component) { - this.component = component; + components = component; } @Override public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - target.addAttribute("c", component.length); - for (int i = 0; i < component.length; i++) { - target.addAttribute("component" + i, component[i]); + int paintedComponents = 0; + for (int i = 0; i < components.length; i++) { + Component c = components[i]; + if (c.getApplication() != null) { + target.addAttribute("component" + paintedComponents++, c); + } else { + logger.log( + Level.WARNING, + "SourceIs component {0} at index {1} is not attached to the component hierachy and will thus be ignored", + new Object[] { c.getClass().getName(), + Integer.valueOf(i) }); + } } + target.addAttribute("c", paintedComponents); } public boolean accept(DragAndDropEvent dragEvent) { if (dragEvent.getTransferable() instanceof TransferableImpl) { Component sourceComponent = ((TransferableImpl) dragEvent .getTransferable()).getSourceComponent(); - for (Component c : component) { + for (Component c : components) { if (c == sourceComponent) { return true; } diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index d6c53a2da6..97c5139296 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -698,6 +698,15 @@ public class JsonPaintTarget implements PaintTarget { public String getPaintIdentifier(Paintable paintable) throws PaintException { if (!manager.hasPaintableId(paintable)) { + if (paintable instanceof Component + && ((Component) paintable).getApplication() == null) { + logger.log( + Level.WARNING, + "Painting reference to orphan " + + paintable.getClass().getName() + + ", the component will not be accessible on the client side."); + return "Orphan"; + } if (identifiersCreatedDueRefPaint == null) { identifiersCreatedDueRefPaint = new HashSet(); } diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html new file mode 100644 index 0000000000..fd45e7284d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html @@ -0,0 +1,71 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.dd.NotPaintedAcceptSource?restartApplication
dragvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]50,9
dropvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]124,20
assertTextvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]Source 1 value 0
clickvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]Source 2
dragvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]19,8
dropvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]139,18
contextmenuvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]Source 2 value 0
+ + diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java index d6d49e018c..74774f09ab 100644 --- a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java +++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java @@ -61,6 +61,7 @@ public class NotPaintedAcceptSource extends TestBase { } else { horizontalLayout.replaceComponent(source2, source1); } + target.requestRepaint(); } })); -- cgit v1.2.3 From b1ef06fdb8d1dc03dba2afb397aed89089ac5445 Mon Sep 17 00:00:00 2001 From: Automerge Date: Thu, 3 May 2012 13:06:25 +0000 Subject: [merge from 6.7] Add missing ?restartApplication from the URL svn changeset:23669/svn branch:6.8 --- .../com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html b/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html index b0e2444986..c2e5451a3b 100644 --- a/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html +++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html @@ -13,7 +13,7 @@ open - /run/com.vaadin.tests.layouts.layouttester.LayoutTesterApplication + /run/com.vaadin.tests.layouts.layouttester.LayoutTesterApplication?restartApplication -- cgit v1.2.3