From 0248b8f7ba0817cc1dbf8bae431544803602cb08 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 24 Sep 2013 11:36:18 +0300 Subject: Fixes browser detection for IE11 (#12638) Change-Id: I1f71477368ce42eac3679f7f2f9e87fe8e02e4de --- .../client/TestVBrowserDetailsUserAgentParser.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'client') diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java index 7d5911f5a0..5b428574e2 100644 --- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java +++ b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java @@ -27,6 +27,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; private static final String IE10_WINDOWS_8 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"; + private static final String IE11_WINDOWS_7 = "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; rv:11.0) like Gecko"; // "Version/" was added in 10.00 private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1"; @@ -314,6 +315,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { public void testIE8() { VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS); + assertTrident(bd); assertEngineVersion(bd, 4); assertIE(bd); assertBrowserMajorVersion(bd, 8); @@ -325,6 +327,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS); bd.setIEMode(7); + assertTrident(bd); assertEngineVersion(bd, 4); assertIE(bd); assertBrowserMajorVersion(bd, 7); @@ -335,6 +338,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { public void testIE9() { VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7); + assertTrident(bd); assertEngineVersion(bd, 5); assertIE(bd); assertBrowserMajorVersion(bd, 9); @@ -346,6 +350,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { VBrowserDetails bd = new VBrowserDetails(IE9_IN_IE7_MODE_WINDOWS_7); // bd.setIE8InCompatibilityMode(); + assertTrident(bd); assertEngineVersion(bd, 5); assertIE(bd); assertBrowserMajorVersion(bd, 7); @@ -362,6 +367,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { * Trident/4.0 in example user agent string based on beta even though it * should be Trident/5.0 in real (non-beta) user agent strings */ + assertTrident(bd); assertEngineVersion(bd, 4); assertIE(bd); assertBrowserMajorVersion(bd, 8); @@ -372,6 +378,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { public void testIE10() { VBrowserDetails bd = new VBrowserDetails(IE10_WINDOWS_8); + assertTrident(bd); assertEngineVersion(bd, 6); assertIE(bd); assertBrowserMajorVersion(bd, 10); @@ -379,6 +386,16 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertWindows(bd); } + public void testIE11() { + VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_7); + assertTrident(bd); + assertEngineVersion(bd, 7); + assertIE(bd); + assertBrowserMajorVersion(bd, 11); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + /* * Helper methods below */ @@ -406,6 +423,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertTrue(browserDetails.isGecko()); assertFalse(browserDetails.isWebKit()); assertFalse(browserDetails.isPresto()); + assertFalse(browserDetails.isTrident()); } private void assertPresto(VBrowserDetails browserDetails) { @@ -413,6 +431,15 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertFalse(browserDetails.isGecko()); assertFalse(browserDetails.isWebKit()); assertTrue(browserDetails.isPresto()); + assertFalse(browserDetails.isTrident()); + } + + private void assertTrident(VBrowserDetails browserDetails) { + // Engine + assertFalse(browserDetails.isGecko()); + assertFalse(browserDetails.isWebKit()); + assertFalse(browserDetails.isPresto()); + assertTrue(browserDetails.isTrident()); } private void assertWebKit(VBrowserDetails browserDetails) { @@ -420,6 +447,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertFalse(browserDetails.isGecko()); assertTrue(browserDetails.isWebKit()); assertFalse(browserDetails.isPresto()); + assertFalse(browserDetails.isTrident()); } private void assertFirefox(VBrowserDetails browserDetails) { -- cgit v1.2.3 From d3261d77a45a24edcb4e77370e12c8e88c119d35 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 19 Sep 2013 16:42:50 +0300 Subject: Fixes issue with Table not scrolling completely to the end #12651 Made the Table notice if the user is trying to scroll to an item on the last "page" and in those cases actually scroll to that item, not just to the page's first item as it did before. Change-Id: I47df33c75aa9b7e4f9a5f4bd5daeb301028517e8 --- client/src/com/vaadin/client/ui/VScrollTable.java | 27 +++++---- server/src/com/vaadin/ui/Table.java | 32 +++++++++-- .../tests/components/table/ShowLastItem.html | 36 ++++++++++++ .../tests/components/table/ShowLastItem.java | 66 ++++++++++++++++++++++ 4 files changed, 143 insertions(+), 18 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/ShowLastItem.html create mode 100644 uitest/src/com/vaadin/tests/components/table/ShowLastItem.java (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 3733ee204a..492730259a 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -176,6 +176,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private int firstRowInViewPort = 0; private int pageLength = 15; private int lastRequestedFirstvisible = 0; // to detect "serverside scroll" + private int firstvisibleOnLastPage = -1; // To detect if the first visible + // is on the last page /** For internal use only. May be removed or replaced in the future. */ public boolean showRowHeaders = false; @@ -1111,8 +1113,14 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private ScheduledCommand lazyScroller = new ScheduledCommand() { @Override public void execute() { - int offsetTop = measureRowHeightOffset(firstvisible); - scrollBodyPanel.setScrollPosition(offsetTop); + if (firstvisibleOnLastPage > -1) { + scrollBodyPanel + .setScrollPosition(measureRowHeightOffset(firstvisibleOnLastPage)); + } else { + scrollBodyPanel + .setScrollPosition(measureRowHeightOffset(firstvisible)); + } + firstRowInViewPort = firstvisible; } }; @@ -1120,6 +1128,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, public void updateFirstVisibleAndScrollIfNeeded(UIDL uidl) { firstvisible = uidl.hasVariable("firstvisible") ? uidl .getIntVariable("firstvisible") : 0; + firstvisibleOnLastPage = uidl.hasVariable("firstvisibleonlastpage") ? uidl + .getIntVariable("firstvisibleonlastpage") : -1; if (firstvisible != lastRequestedFirstvisible && scrollBody != null) { // received 'surprising' firstvisible from server: scroll there firstRowInViewPort = firstvisible; @@ -2150,18 +2160,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, isNewBody = false; - if (firstvisible > 0) { - // Deferred due to some Firefox oddities - Scheduler.get().scheduleDeferred(new Command() { - - @Override - public void execute() { - scrollBodyPanel - .setScrollPosition(measureRowHeightOffset(firstvisible)); - firstRowInViewPort = firstvisible; - } - }); - } + Scheduler.get().scheduleFinally(lazyScroller); if (enabled) { // Do we need cache rows diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index bd2b7828de..32ed738697 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -426,6 +426,12 @@ public class Table extends AbstractSelect implements Action.Container, */ private int currentPageFirstItemIndex = 0; + /** + * Index of the "first" item on the last page if a user has used + * setCurrentPageFirstItemIndex to scroll down. -1 if not set. + */ + private int currentPageFirstItemIndexOnLastPage = -1; + /** * Holds value of property selectable. */ @@ -1477,12 +1483,14 @@ public class Table extends AbstractSelect implements Action.Container, } /* - * FIXME #7607 Take somehow into account the case where we want to - * scroll to the bottom so that the last row is completely visible even - * if (table height) / (row height) is not an integer. Reverted the - * original fix because of #8662 regression. + * If the new index is on the last page we set the index to be the first + * item on that last page and make a note of the real index for the + * client side to be able to move the scroll position to the correct + * position. */ + int indexOnLastPage = -1; if (newIndex > maxIndex) { + indexOnLastPage = newIndex; newIndex = maxIndex; } @@ -1494,6 +1502,20 @@ public class Table extends AbstractSelect implements Action.Container, currentPageFirstItemId = null; } currentPageFirstItemIndex = newIndex; + + if (needsPageBufferReset) { + /* + * The flag currentPageFirstItemIndexOnLastPage denotes a user + * set scrolling position on the last page via + * setCurrentPageFirstItemIndex() and shouldn't be changed by + * the table component internally changing the firstvisible item + * on lazy row fetching. Doing so would make the scrolling + * position not be updated correctly when the lazy rows are + * finally rendered. + */ + currentPageFirstItemIndexOnLastPage = indexOnLastPage; + } + } else { // For containers not supporting indexes, we must iterate the @@ -3447,6 +3469,8 @@ public class Table extends AbstractSelect implements Action.Container, if (getCurrentPageFirstItemIndex() != 0 || getPageLength() > 0) { target.addVariable(this, "firstvisible", getCurrentPageFirstItemIndex()); + target.addVariable(this, "firstvisibleonlastpage", + currentPageFirstItemIndexOnLastPage); } } diff --git a/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html new file mode 100644 index 0000000000..c9c93198fa --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html @@ -0,0 +1,36 @@ + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.ShowLastItem?restartApplication
clickvaadin=runcomvaadintestscomponentstableShowLastItem::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
pause1000
screenCapturerow-20-fully-visible
+ + diff --git a/uitest/src/com/vaadin/tests/components/table/ShowLastItem.java b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.java new file mode 100644 index 0000000000..6d6f744918 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.java @@ -0,0 +1,66 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Table; + +public class ShowLastItem extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + final Table table = new Table(); + table.setHeight("210px"); + + table.addContainerProperty("Col", String.class, ""); + + for (int i = 0; i < 20; i++) { + table.addItem(i).getItemProperty("Col") + .setValue("row " + String.valueOf(i)); + } + + Button addItemBtn = new Button("Add item", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Object itemId = "row " + table.getItemIds().size(); + + table.addItem(itemId).getItemProperty("Col") + .setValue(String.valueOf(itemId)); + + table.setCurrentPageFirstItemIndex(table.getItemIds().size() - 1); + } + }); + + addComponent(table); + addComponent(addItemBtn); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Show last item in Table by using setCurrentPageFirstItemId"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12407; + } + +} -- cgit v1.2.3