summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-21 20:33:05 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-22 09:50:18 +0000
commitde1450300bcc83eb3f6eddcd39bd77e02b24dfeb (patch)
tree6e0da07dbb25d902c1744517e4afa6b761b11f4a
parent1810b99839cb5616e84722c1f767953b7093a08b (diff)
downloadvaadin-framework-de1450300bcc83eb3f6eddcd39bd77e02b24dfeb.tar.gz
vaadin-framework-de1450300bcc83eb3f6eddcd39bd77e02b24dfeb.zip
Fixed tab index handling in broken components (#10315)
Change-Id: I27a1a3541886b126f0798f4d25ae6d22df81aa79
-rw-r--r--client/src/com/vaadin/client/ui/VDateFieldCalendar.java8
-rw-r--r--client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java4
-rw-r--r--client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java7
-rw-r--r--client/src/com/vaadin/client/ui/datefield/TextualDateConnector.java4
-rw-r--r--client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java4
-rw-r--r--client/src/com/vaadin/client/ui/table/TableConnector.java7
-rw-r--r--client/src/com/vaadin/client/ui/tree/TreeConnector.java8
-rw-r--r--uitest/src/com/vaadin/tests/fields/TabIndexes.html176
-rw-r--r--uitest/src/com/vaadin/tests/fields/TabIndexes.java159
9 files changed, 364 insertions, 13 deletions
diff --git a/client/src/com/vaadin/client/ui/VDateFieldCalendar.java b/client/src/com/vaadin/client/ui/VDateFieldCalendar.java
index b7621f00f8..2bcff7f501 100644
--- a/client/src/com/vaadin/client/ui/VDateFieldCalendar.java
+++ b/client/src/com/vaadin/client/ui/VDateFieldCalendar.java
@@ -118,4 +118,12 @@ public class VDateFieldCalendar extends VDateField {
}
}
}
+
+ public void setTabIndex(int tabIndex) {
+ calendarPanel.getElement().setTabIndex(tabIndex);
+ }
+
+ public int getTabIndex() {
+ return calendarPanel.getElement().getTabIndex();
+ }
}
diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index 5f9a3ded58..8f3f758458 100644
--- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -66,9 +66,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
getWidget().setTextInputEnabled(!noTextInput);
// not a FocusWidget -> needs own tabindex handling
- if (uidl.hasAttribute("tabindex")) {
- getWidget().tb.setTabIndex(uidl.getIntAttribute("tabindex"));
- }
+ getWidget().tb.setTabIndex(getState().tabIndex);
if (uidl.hasAttribute("filteringmode")) {
getWidget().filteringmode = FilteringMode.valueOf(uidl
diff --git a/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java b/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java
index ca3488af87..93e720e0ca 100644
--- a/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java
+++ b/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java
@@ -20,6 +20,7 @@ import java.util.Date;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.DateTimeService;
import com.vaadin.client.UIDL;
+import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.client.ui.VCalendarPanel.TimeChangeListener;
import com.vaadin.client.ui.VDateFieldCalendar;
@@ -110,6 +111,12 @@ public class InlineDateFieldConnector extends AbstractDateFieldConnector {
}
@Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
+ getWidget().setTabIndex(getState().tabIndex);
+ }
+
+ @Override
public VDateFieldCalendar getWidget() {
return (VDateFieldCalendar) super.getWidget();
}
diff --git a/client/src/com/vaadin/client/ui/datefield/TextualDateConnector.java b/client/src/com/vaadin/client/ui/datefield/TextualDateConnector.java
index b5297f535a..a592098180 100644
--- a/client/src/com/vaadin/client/ui/datefield/TextualDateConnector.java
+++ b/client/src/com/vaadin/client/ui/datefield/TextualDateConnector.java
@@ -45,9 +45,7 @@ public class TextualDateConnector extends AbstractDateFieldConnector {
getWidget().buildDate();
// not a FocusWidget -> needs own tabindex handling
- if (uidl.hasAttribute("tabindex")) {
- getWidget().text.setTabIndex(uidl.getIntAttribute("tabindex"));
- }
+ getWidget().text.setTabIndex(getState().tabIndex);
if (getWidget().isReadonly()) {
getWidget().text.addStyleDependentName("readonly");
diff --git a/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java b/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java
index 5d50b84833..36b69922fc 100644
--- a/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java
+++ b/client/src/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java
@@ -94,9 +94,7 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector
getWidget().container.remove(getWidget().newItemButton);
}
- getWidget().setTabIndex(
- uidl.hasAttribute("tabindex") ? uidl
- .getIntAttribute("tabindex") : 0);
+ getWidget().setTabIndex(getState().tabIndex);
}
diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java
index ef1b117bcb..aa505a91e9 100644
--- a/client/src/com/vaadin/client/ui/table/TableConnector.java
+++ b/client/src/com/vaadin/client/ui/table/TableConnector.java
@@ -43,8 +43,8 @@ import com.vaadin.shared.ui.table.TableConstants;
import com.vaadin.shared.ui.table.TableState;
@Connect(com.vaadin.ui.Table.class)
-public class TableConnector extends AbstractHasComponentsConnector
- implements Paintable, DirectionalManagedLayout, PostLayoutListener {
+public class TableConnector extends AbstractHasComponentsConnector implements
+ Paintable, DirectionalManagedLayout, PostLayoutListener {
@Override
protected void init() {
@@ -276,8 +276,7 @@ public class TableConnector extends AbstractHasComponentsConnector
getWidget().selectionRangeStart = getWidget().focusedRow;
}
- getWidget().tabIndex = uidl.hasAttribute("tabindex") ? uidl
- .getIntAttribute("tabindex") : 0;
+ getWidget().tabIndex = getState().tabIndex;
getWidget().setProperTabIndex();
getWidget().resizeSortedColumnForSortIndicator();
diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
index 0ddbc7e96c..5a64d7c077 100644
--- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java
+++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
@@ -26,6 +26,7 @@ import com.vaadin.client.Paintable;
import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
+import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.VTree;
import com.vaadin.client.ui.VTree.TreeNode;
@@ -146,6 +147,13 @@ public class TreeConnector extends AbstractComponentConnector implements
}
@Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
+ // VTree does not implement Focusable
+ getWidget().setTabIndex(getState().tabIndex);
+ }
+
+ @Override
public VTree getWidget() {
return (VTree) super.getWidget();
}
diff --git a/uitest/src/com/vaadin/tests/fields/TabIndexes.html b/uitest/src/com/vaadin/tests/fields/TabIndexes.html
new file mode 100644
index 0000000000..1f865627ad
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/fields/TabIndexes.html
@@ -0,0 +1,176 @@
+<?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://arturwin.office.itmill.com:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.fields.TabIndexes?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-1/domChild[1]/domChild[1]@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-2/domChild[0]@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-3/domChild[0]@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-4/domChild[0]@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-5@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-6/domChild[0]@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-7/domChild[0]@tabIndex</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-1/domChild[1]/domChild[1]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-2/domChild[0]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-3/domChild[0]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-4/domChild[0]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-5@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-6/domChild[0]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-7/domChild[0]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-1/domChild[1]/domChild[1]@tabIndex</td>
+ <td>1</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-2/domChild[0]@tabIndex</td>
+ <td>2</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-3/domChild[0]@tabIndex</td>
+ <td>3</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-4/domChild[0]@tabIndex</td>
+ <td>4</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-5@tabIndex</td>
+ <td>5</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-6/domChild[0]@tabIndex</td>
+ <td>6</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-7/domChild[0]@tabIndex</td>
+ <td>7</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-1/domChild[1]/domChild[1]@tabIndex</td>
+ <td>7</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-2/domChild[0]@tabIndex</td>
+ <td>6</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-3/domChild[0]@tabIndex</td>
+ <td>5</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-4/domChild[0]@tabIndex</td>
+ <td>4</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-5@tabIndex</td>
+ <td>3</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-6/domChild[0]@tabIndex</td>
+ <td>2</td>
+</tr>
+<tr>
+ <td>assertAttribute</td>
+ <td>vaadin=runcomvaadintestsfieldsTabIndexes::PID_Sfield-7/domChild[0]@tabIndex</td>
+ <td>1</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/fields/TabIndexes.java b/uitest/src/com/vaadin/tests/fields/TabIndexes.java
new file mode 100644
index 0000000000..c88bb97c73
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/fields/TabIndexes.java
@@ -0,0 +1,159 @@
+package com.vaadin.tests.fields;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.InlineDateField;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.PasswordField;
+import com.vaadin.ui.PopupDateField;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.TwinColSelect;
+
+public class TabIndexes extends AbstractTestUI {
+
+ private List<AbstractField> fields;
+ private Log log = new Log(5);
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(log);
+ HorizontalLayout buttonLayout = new HorizontalLayout();
+ addComponent(buttonLayout);
+ Button clearTabIndexes = new Button("Set all tab indexes to 0");
+ clearTabIndexes.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.log("Setting tab indexes to 0");
+ for (AbstractField f : fields) {
+ f.setTabIndex(0);
+ }
+ updateCaptions();
+ }
+ });
+ Button setTabIndexesToOne = new Button("Set all tab indexes to 1");
+ setTabIndexesToOne.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.log("Setting tab indexes to 1");
+ for (AbstractField f : fields) {
+ f.setTabIndex(1);
+ }
+ updateCaptions();
+ }
+ });
+ Button setTabIndexesInOrder = new Button("Set tab indexes to 1..N");
+ setTabIndexesInOrder.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ int tabIndex = 1;
+ log.log("Setting tab indexes to 1..N");
+ for (AbstractField f : fields) {
+ f.setTabIndex(tabIndex++);
+ }
+ updateCaptions();
+ }
+ });
+ Button setTabIndexesInReverseOrder = new Button(
+ "Set tab indexes to N..1");
+ setTabIndexesInReverseOrder.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ int tabIndex = fields.size();
+ log.log("Setting tab indexes to N..1");
+ for (AbstractField f : fields) {
+ f.setTabIndex(tabIndex--);
+ }
+ updateCaptions();
+ }
+ });
+ fields = new ArrayList<AbstractField>();
+ Table t = new Table();
+ t.setSelectable(true);
+ t.addContainerProperty("foo", String.class, "bar");
+ t.addItem();
+ fields.add(t);
+ fields.add(new ComboBox());
+ fields.add(new NativeSelect());
+ fields.add(new ListSelect());
+ fields.add(new TextField());
+ fields.add(new PopupDateField());
+ fields.add(new InlineDateField());
+ OptionGroup og = new OptionGroup();
+ og.addItem("Item 1");
+ og.addItem("Item 2");
+ fields.add(og);
+ TreeTable tt = new TreeTable();
+ tt.setSelectable(true);
+ tt.addContainerProperty("foo", String.class, "bar");
+ tt.addItem();
+
+ fields.add(tt);
+ Tree tree = new Tree();
+ tree.addItem("Item 1");
+ fields.add(tree);
+ fields.add(new TwinColSelect());
+ fields.add(new PasswordField());
+ fields.add(new TextField());
+ fields.add(new TextArea());
+ fields.add(new RichTextArea());
+ fields.add(new CheckBox());
+ // fields.add(new Slider());
+
+ clearTabIndexes.click();
+
+ buttonLayout.addComponents(clearTabIndexes, setTabIndexesToOne,
+ setTabIndexesInOrder, setTabIndexesInReverseOrder);
+
+ int fieldId = 1;
+ GridLayout gl = new GridLayout(4, 4);
+ for (Field f : fields) {
+ f.setId("field-" + fieldId++);
+ gl.addComponent(f);
+ }
+ addComponent(gl);
+
+ }
+
+ protected void updateCaptions() {
+ for (Field f : fields) {
+ f.setCaption(f.getClass().getSimpleName() + " Tab index: "
+ + f.getTabIndex());
+ }
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10315;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}