diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-04-18 14:09:56 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-04-18 14:09:56 +0300 |
commit | 290f6b3a2b6b3eeadf3c9904fbaae0fa2f016595 (patch) | |
tree | e219c7615fa7aa14d89f274896a4eafb1f283cbb | |
parent | cf06923748ce75dc8113e66a40bb69297def7072 (diff) | |
parent | c3e10ebbbc48d124a88d6e92e16faccdebe43223 (diff) | |
download | vaadin-framework-290f6b3a2b6b3eeadf3c9904fbaae0fa2f016595.tar.gz vaadin-framework-290f6b3a2b6b3eeadf3c9904fbaae0fa2f016595.zip |
Merge remote branch 'origin/6.8'
Conflicts:
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java
8 files changed, 160 insertions, 170 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 5f5ef71c36..2d9398320e 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -766,8 +766,7 @@ public class ApplicationConnection { protected void startRequest() { if (hasActiveRequest) { - throw new IllegalStateException( - "Trying to start a new request while another is active"); + VConsole.error("Trying to start a new request while another is active"); } hasActiveRequest = true; requestStartTime = new Date(); @@ -794,7 +793,7 @@ public class ApplicationConnection { protected void endRequest() { if (!hasActiveRequest) { - throw new IllegalStateException("No active request"); + VConsole.error("No active request"); } // After checkForPendingVariableBursts() there may be a new active // request, so we must set hasActiveRequest to false before, not after, diff --git a/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java index cf6209e312..563ca04abe 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java @@ -1846,9 +1846,18 @@ public class VScrollTable extends FlowPanel implements HasWidgets, isNewBody = false; if (firstvisible > 0) { - scrollBodyPanel - .setScrollPosition(measureRowHeightOffset(firstvisible)); - firstRowInViewPort = firstvisible; + // FIXME #7607 + // Originally deferred due to Firefox oddities which should not + // occur any more. Currently deferring breaks Webkit scrolling with + // relative-height tables, but not deferring instead breaks tables + // with explicit page length. + Scheduler.get().scheduleDeferred(new Command() { + public void execute() { + scrollBodyPanel + .setScrollPosition(measureRowHeightOffset(firstvisible)); + firstRowInViewPort = firstvisible; + } + }); } if (enabled) { @@ -4968,21 +4977,33 @@ public class VScrollTable extends FlowPanel implements HasWidgets, public void run() { TouchScrollDelegate activeScrollDelegate = TouchScrollDelegate .getActiveScrollDelegate(); - if (activeScrollDelegate != null - && !activeScrollDelegate.isMoved()) { - /* - * scrolling hasn't started. Cancel - * scrolling and let row handle this as - * drag start or context menu. - */ - activeScrollDelegate.stopScrolling(); - } else { - /* - * Scrolled or scrolling, clear touch - * start to indicate that row shouldn't - * handle touch move/end events. - */ - touchStart = null; + /* + * If there's a scroll delegate, check if + * we're actually scrolling and handle it. + * If no delegate, do nothing here and let + * the row handle potential drag'n'drop or + * context menu. + */ + if (activeScrollDelegate != null) { + if (activeScrollDelegate.isMoved()) { + /* + * Prevent the row from handling + * touch move/end events (the + * delegate handles those) and from + * doing drag'n'drop or opening a + * context menu. + */ + touchStart = null; + } else { + /* + * Scrolling hasn't started, so + * cancel delegate and let the row + * handle potential drag'n'drop or + * context menu. + */ + activeScrollDelegate + .stopScrolling(); + } } } }.schedule(TOUCHSCROLL_TIMEOUT); diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index 64e069dcfe..23dee15359 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -538,7 +538,8 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * * @param c * the component - * @return + * @return The tab instance associated with the given component, or null if + * the tabsheet does not contain the component. */ public Tab getTab(Component c) { return tabs.get(c); @@ -550,14 +551,15 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * * @param position * the position of the tab - * @return + * @return The tab in the given position, or null if the position is out of + * bounds. */ public Tab getTab(int position) { - Component c = components.get(position); - if (c != null) { - return tabs.get(c); + if (position >= 0 && position < getComponentCount()) { + return getTab(components.get(position)); + } else { + return null; } - return null; } /** @@ -608,17 +610,19 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @param tab */ public void setSelectedTab(Tab tab) { - setSelectedTab(tab.getComponent()); + if (tab != null) { + setSelectedTab(tab.getComponent()); + } } /** - * Sets the selected tab, identified by its position. Does nothing if - * <code>index < 0 || index > {@link #getComponentCount()}</code>. + * Sets the selected tab, identified by its position. Does nothing if the + * position is out of bounds. * - * @param index + * @param position */ - public void setSelectedTab(int index) { - setSelectedTab(getTab(index)); + public void setSelectedTab(int position) { + setSelectedTab(getTab(position)); } /** diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 0658c4e6a5..2fffedd9d6 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -1370,11 +1370,14 @@ public class Table extends AbstractSelect implements Action.Container, maxIndex = 0; } - // Assume that we want to scroll to the very bottom (so that the bottom - // row is completely visible even if (table height) / (row height) is - // not an integer.) + /* + * 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 (newIndex > maxIndex) { - newIndex = maxIndex + 1; + newIndex = maxIndex; } // Refresh first item id diff --git a/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java b/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java index 85c88e29bb..40d0ffd17d 100644 --- a/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java +++ b/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java @@ -119,6 +119,43 @@ public class TestTabSheet { assertEquals(tab1, tabSheet.getTab(0)); assertEquals(tab2, tabSheet.getTab(1)); assertEquals(tab3, tabSheet.getTab(2)); + + assertEquals(null, tabSheet.getTab(3)); } + @Test + public void selectTab() { + TabSheet tabSheet = new TabSheet(); + Tab tab1 = tabSheet.addTab(new Label("aaa")); + Tab tab2 = tabSheet.addTab(new Label("bbb")); + Tab tab3 = tabSheet.addTab(new Label("ccc")); + Label componentNotInSheet = new Label("ddd"); + Tab tabNotInSheet = new TabSheet().addTab(new Label("eee")); + + assertEquals(tab1.getComponent(), tabSheet.getSelectedTab()); + + // Select tab by component... + tabSheet.setSelectedTab(tab2.getComponent()); + assertEquals(tab2.getComponent(), tabSheet.getSelectedTab()); + + // by tab instance + tabSheet.setSelectedTab(tab3); + assertEquals(tab3.getComponent(), tabSheet.getSelectedTab()); + + // by index + tabSheet.setSelectedTab(0); + assertEquals(tab1.getComponent(), tabSheet.getSelectedTab()); + + // Should be no-op... + tabSheet.setSelectedTab(componentNotInSheet); + assertEquals(tab1.getComponent(), tabSheet.getSelectedTab()); + + // this as well + tabSheet.setSelectedTab(tabNotInSheet); + assertEquals(tab1.getComponent(), tabSheet.getSelectedTab()); + + // and this + tabSheet.setSelectedTab(123); + assertEquals(tab1.getComponent(), tabSheet.getSelectedTab()); + } } diff --git a/tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html b/tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html deleted file mode 100644 index 8881c0d2f5..0000000000 --- a/tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8067/" /> -<title>SetCurrentPageFirstItemId</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">SetCurrentPageFirstItemId</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/SetCurrentPageFirstItemId?restartApplication</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>300</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[24]/domChild[0]/domChild[0]</td> - <td>24</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>scrolled-to-bottom</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/tests/testbench/com/vaadin/tests/components/table/TableContextMenu.java b/tests/testbench/com/vaadin/tests/components/table/TableContextMenu.java new file mode 100644 index 0000000000..16323e5024 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableContextMenu.java @@ -0,0 +1,55 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.event.Action; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Table; + +public class TableContextMenu extends TestBase { + + private static final Action ACTION_MYACTION = new Action("Action!!"); + + @Override + protected void setup() { + Table table = new Table(); + table.setSelectable(true); + table.setMultiSelect(true); + + table.addActionHandler(new Action.Handler() { + public void handleAction(Action action, Object sender, Object target) { + getLayout().getRoot().showNotification("Done that :-)"); + } + + public Action[] getActions(Object target, Object sender) { + return new Action[] { ACTION_MYACTION }; + } + }); + + // TODO should work with all combinations + table.setImmediate(true); + table.setSelectable(true); + table.setMultiSelect(true); + + table.addContainerProperty("Foo", String.class, "BAR1"); + table.addContainerProperty("Bar", String.class, "FOO2"); + + // FIXME works with lots of rows (more than pagelength), don't work with + // none + for (int i = 0; i < 3; i++) { + table.addItem(); + } + + addComponent(table); + } + + @Override + protected String getDescription() { + return "Right clicking on an item without a context menu should bring" + + "up the Tables context menu. With touch devices context menu must popup with long touch."; + } + + @Override + protected Integer getTicketNumber() { + return 8639; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html b/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html index 75ad4b5ff5..53709b2a64 100644 --- a/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html +++ b/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html @@ -3,13 +3,13 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>Trees</title> +<link rel="selenium.base" href="http://localhost:8067" /> +<title>TreeShiftMultiSelectNodes</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">Trees</td></tr> +<tr><td rowspan="1" colspan="3">TreeShiftMultiSelectNodes</td></tr> </thead><tbody> <tr> <td>open</td> @@ -32,76 +32,9 @@ <td>23,8</td> </tr> <tr> - <td>shiftKeyDown</td> - <td></td> - <td></td> -</tr> -<tr> <td>mouseClick</td> <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/n[1]</td> - <td>28,8</td> -</tr> -<tr> - <td>shiftKeyUp</td> - <td></td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>all-items-inside-selection-are-selected</td> -</tr> - -</tbody></table> -</body> -</html> -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>Trees</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">Trees</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.tree.Trees/?restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/expand</td> - <td>9,10</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/expand</td> - <td>9,10</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[0]</td> - <td>23,8</td> -</tr> -<tr> - <td>shiftKeyDown</td> - <td></td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/n[1]</td> - <td>28,8</td> -</tr> -<tr> - <td>shiftKeyUp</td> - <td></td> - <td></td> + <td>28,8:shift</td> </tr> <tr> <td>screenCapture</td> |