From e88f71dd6d1d7634e3a90a7e53859ff6dc028e21 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Thu, 16 Oct 2014 13:37:48 +0300 Subject: Moved accessibility shortcut handling to server-side. [#14843] Also allowed multiple shortcuts for closing Window. Change-Id: I35280ad1553af10ae54bc001e5707357f206b0ee --- client/src/com/vaadin/client/ui/VWindow.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 6977cf9e7f..501dedbaa8 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -1338,9 +1338,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, @Override public void onKeyUp(KeyUpEvent event) { - if (isClosable() && event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { - onCloseClick(); - } + // do nothing } @Override -- cgit v1.2.3 From e052d648749312225098093a53dc7a19ea870cfd Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Wed, 10 Dec 2014 18:55:26 +0200 Subject: Avoid client side exception using keyboard navigation (#15343). Change-Id: Ibed97b23de72007a6ffe5450bd8c3f271447f8d1 --- client/src/com/vaadin/client/ui/VTree.java | 4 +- .../tree/TreeKeyboardNavigationToNone.java | 64 +++++++++++++++++++++ .../tree/TreeKeyboardNavigationToNoneTest.java | 66 ++++++++++++++++++++++ 3 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java create mode 100644 uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java (limited to 'client/src') diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java index 6539eb49a9..8729de4a43 100644 --- a/client/src/com/vaadin/client/ui/VTree.java +++ b/client/src/com/vaadin/client/ui/VTree.java @@ -1737,8 +1737,8 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, selectNode(node, true); } } + showTooltipForKeyboardNavigation(node); } - showTooltipForKeyboardNavigation(node); return true; } @@ -1763,8 +1763,8 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, selectNode(node, true); } } + showTooltipForKeyboardNavigation(node); } - showTooltipForKeyboardNavigation(node); return true; } diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java new file mode 100644 index 0000000000..dfea493281 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNone.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tree; + +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.Tree; + +/** + * Test UI for keyboard navigation for first and last tree item. + * + * @author Vaadin Ltd + */ +public class TreeKeyboardNavigationToNone extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Tree tree = new Tree(); + tree.addItem("a"); + tree.addItem("b"); + + tree.select("a"); + addComponents(tree); + tree.focus(); + + Button button = new Button("Select last item", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + tree.select("b"); + tree.focus(); + } + }); + addComponent(button); + } + + @Override + protected Integer getTicketNumber() { + return 15343; + } + + @Override + protected String getTestDescription() { + return "Keyboard navigation should not throw client side exception " + + "when there are no items to navigate."; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java new file mode 100644 index 0000000000..98f1896b82 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeKeyboardNavigationToNoneTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tree; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for keyboard navigation in tree in case when there are no items to + * navigate. + * + * @author Vaadin Ltd + */ +public class TreeKeyboardNavigationToNoneTest extends MultiBrowserTest { + + @Before + public void setUp() { + setDebug(true); + openTestURL(); + } + + @Test + public void navigateUpForTheFirstItem() { + sendKey(Keys.ARROW_UP); + checkNotificationErrorAbsence("first"); + } + + @Test + public void navigateDownForTheLastItem() { + $(ButtonElement.class).first().click(); + sendKey(Keys.ARROW_DOWN); + checkNotificationErrorAbsence("last"); + } + + private void checkNotificationErrorAbsence(String item) { + Assert.assertFalse( + "Notification is found after using keyboard for navigation " + + "from " + item + " tree item", + isElementPresent(By.className("v-Notification"))); + } + + private void sendKey(Keys key) { + Actions actions = new Actions(getDriver()); + actions.sendKeys(key).build().perform(); + } +} -- cgit v1.2.3 From c2225299f9bf7a145c427bc204272faf5bc3f6d3 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 30 Jan 2015 17:07:51 +0200 Subject: Remove DataSource.indexOf (#16542) This change makes it easier to create custom data sources. The implementations in provided implementations are retained as a convenience. Change-Id: If34bfb378eec75a37f28af78e512210ed9d7c304 --- .../src/com/vaadin/client/data/AbstractRemoteDataSource.java | 11 ++++++++++- client/src/com/vaadin/client/data/DataSource.java | 12 ------------ .../client/widget/grid/datasources/ListDataSource.java | 11 ++++++++++- .../client/grid/GridClientColumnRendererConnector.java | 5 ----- 4 files changed, 20 insertions(+), 19 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java index 0ad1631e19..bd676e4ee9 100644 --- a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java +++ b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java @@ -362,7 +362,16 @@ public abstract class AbstractRemoteDataSource implements DataSource { return indexToRowMap.get(Integer.valueOf(rowIndex)); } - @Override + /** + * Retrieves the index for given row object. + *

+ * Note: This method does not verify that the given row object + * exists at all in this DataSource. + * + * @param row + * the row object + * @return index of the row; or -1 if row is not available + */ public int indexOf(T row) { Object key = getRowKey(row); if (keyToIndexMap.containsKey(key)) { diff --git a/client/src/com/vaadin/client/data/DataSource.java b/client/src/com/vaadin/client/data/DataSource.java index 076226bf5c..f3711c3c68 100644 --- a/client/src/com/vaadin/client/data/DataSource.java +++ b/client/src/com/vaadin/client/data/DataSource.java @@ -194,16 +194,4 @@ public interface DataSource { * means that the row is not currently in this data source's cache. */ public RowHandle getHandle(T row); - - /** - * Retrieves the index for given row object. - *

- * Note: This method does not verify that the given row object - * exists at all in this DataSource. - * - * @param row - * the row object - * @return index of the row; or -1 if row is not available - */ - int indexOf(T row); } diff --git a/client/src/com/vaadin/client/widget/grid/datasources/ListDataSource.java b/client/src/com/vaadin/client/widget/grid/datasources/ListDataSource.java index 56e1db5c36..47e072490e 100644 --- a/client/src/com/vaadin/client/widget/grid/datasources/ListDataSource.java +++ b/client/src/com/vaadin/client/widget/grid/datasources/ListDataSource.java @@ -443,7 +443,16 @@ public class ListDataSource implements DataSource { } } - @Override + /** + * Retrieves the index for given row object. + *

+ * Note: This method does not verify that the given row object + * exists at all in this DataSource. + * + * @param row + * the row object + * @return index of the row; or -1 if row is not available + */ public int indexOf(T row) { return ds.indexOf(row); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridClientColumnRendererConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridClientColumnRendererConnector.java index f35f9820e0..2b8f454ed1 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridClientColumnRendererConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridClientColumnRendererConnector.java @@ -114,11 +114,6 @@ public class GridClientColumnRendererConnector extends // TODO Auto-generated method stub (henrik paul: 17.6.) return null; } - - @Override - public int indexOf(String row) { - return ds.indexOf(row); - } } @Override -- cgit v1.2.3