From 4f6bc36661f0d07a6bafd7af3a0cd386f3ab9675 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Thu, 12 Jan 2012 11:17:28 +0000 Subject: [PATCH] Merge from 6.7 svn changeset:22607/svn branch:6.8 --- WebContent/release-notes.html | 23 +- src/com/vaadin/terminal/gwt/client/Util.java | 2 + .../terminal/gwt/client/ui/VScrollTable.java | 35 ++-- .../terminal/gwt/client/ui/VTextArea.java | 7 + .../vaadin/terminal/gwt/client/ui/VView.java | 8 + src/com/vaadin/ui/Table.java | 10 + .../orderedlayout/OrderedLayoutCases.java | 197 ++++++++++++++++++ .../table/ScrollDetachSynchronization.java | 91 ++++++++ .../components/table/TableHeaderZoom.java | 10 +- .../table/TableRepaintWhenMadeVisibile.java | 43 ++++ .../table/TableRepaintWhenMadeVisible.html | 42 ++++ .../tabsheet/WrapTabSheetInTabSheet.java | 42 ++++ .../textarea/TextAreaCursorPosition.java | 54 +++++ .../TextFieldInputPromptAndClickShortcut.java | 57 +++++ 14 files changed, 579 insertions(+), 42 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java create mode 100644 tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html create mode 100644 tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java create mode 100644 tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java create mode 100644 tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html index 2fe8083556..8813bc343d 100644 --- a/WebContent/release-notes.html +++ b/WebContent/release-notes.html @@ -340,25 +340,6 @@ 6.2.0 release notes for more details.

- - - - -

Known problems and limitations in Vaadin - @version@

- -

Notes and Limitations for Google App Engine

The following instructions and limitations apply when you run a @@ -480,11 +461,11 @@

diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index a72c9c1dc2..3dbbd22329 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -1080,6 +1080,8 @@ public class Util { VConsole.log("\t\t" + var[1] + " (" + var[2] + ")" + " : " + var[0]); } + } else { + VConsole.log("\t" + id + ": Warning: no corresponding paintable!"); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index f1c1927b26..553934bf98 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -2292,26 +2292,17 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, * of the caption container element by the correct amount */ public void resizeCaptionContainer(int rightSpacing) { + + int captionContainerWidth = width + - colResizeWidget.getOffsetWidth() - rightSpacing; + if (BrowserInfo.get().isIE6() || td.getClassName().contains("-asc") || td.getClassName().contains("-desc")) { - /* - * Room for the sort indicator is made by subtracting the styled - * margin and width of the resizer from the width of the caption - * container. - */ - int captionContainerWidth = width - - sortIndicator.getOffsetWidth() - - colResizeWidget.getOffsetWidth() - rightSpacing; - captionContainer.getStyle().setPropertyPx("width", - captionContainerWidth); - } else { - /* - * Set the caption container element as wide as possible when - * the sorting indicator is not visible. - */ - captionContainer.getStyle().setPropertyPx("width", - width - rightSpacing); + // Leave room for the sort indicator + captionContainerWidth -= sortIndicator.getOffsetWidth(); } + captionContainer.getStyle().setPropertyPx("width", + captionContainerWidth); // Apply/Remove spacing if defined if (rightSpacing > 0) { @@ -6071,7 +6062,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, public void onScroll(ScrollEvent event) { scrollLeft = scrollBodyPanel.getElement().getScrollLeft(); scrollTop = scrollBodyPanel.getScrollPosition(); - if (!initializedAndAttached) { + /* + * #6970 - IE sometimes fires scroll events for a detached table. + * + * FIXME initializedAndAttached should probably be renamed - its name + * doesn't seem to reflect its semantics. onDetach() doesn't set it to + * false, and changing that might break something else, so we need to + * check isAttached() separately. + */ + if (!initializedAndAttached || !isAttached()) { return; } if (!enabled) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java index a74fd9f5dc..cd09e24d67 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java @@ -69,4 +69,11 @@ public class VTextArea extends VTextField { super.onBrowserEvent(event); } + @Override + public int getCursorPos() { + // This is needed so that TextBoxImplIE6 is used to return the correct + // position for old Internet Explorer versions where it has to be + // detected in a different way. + return getImpl().getTextAreaCursorPos(getElement()); + } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index f21c0aaac0..07ade6a8b1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -591,6 +591,11 @@ public class VView extends SimplePanel implements Container, ResizeHandler, String ownAppId = connection.getConfiguration().getRootPanelId(); + // Hiding elements causes browser to forget scroll position -> must + // save values and restore when the elements are visible again #7976 + int originalScrollTop = Window.getScrollTop(); + int originalScrollLeft = Window.getScrollLeft(); + // Set display: none for all Vaadin apps for (int i = 0; i < vaadinApps.size(); i++) { String appId = vaadinApps.get(i); @@ -629,6 +634,9 @@ public class VView extends SimplePanel implements Container, ResizeHandler, } } + // Scroll back to original location + Window.scrollTo(originalScrollLeft, originalScrollTop); + return w; } diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index b7235dd37b..d8c59c2e91 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -5148,4 +5148,14 @@ public class Table extends AbstractSelect implements Action.Container, public RowGenerator getRowGenerator() { return rowGenerator; } + + @Override + public void setVisible(boolean visible) { + if (!isVisible() && visible) { + // We need to ensure that the rows are sent to the client when the + // Table is made visible if it has been rendered as invisible. + setRowCacheInvalidated(true); + } + super.setVisible(visible); + } } diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java new file mode 100644 index 0000000000..d8b01c4099 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -0,0 +1,197 @@ +package com.vaadin.tests.components.orderedlayout; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.TestUtils; +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.VerticalLayout; + +public class OrderedLayoutCases extends TestBase { + private static final String[] dimensionValues = { "-1px", "5px", "300px", + "800px", "100%", "50%" }; + + private static class SampleChild extends VerticalLayout { + public SampleChild() { + setStyleName("showBorders"); + addComponent(createSimpleSelector("Child width", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + setWidth(event.getProperty().getValue().toString()); + } + }, dimensionValues)); + addComponent(createSimpleSelector("Child height", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + setHeight(event.getProperty().getValue().toString()); + } + }, dimensionValues)); + addComponent(createSimpleSelector("Caption", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + String value = event.getProperty().getValue() + .toString(); + if (value.length() == 0) { + setCaption(null); + } else if (value.equals("Long")) { + setCaption("A rather long caption just to see what happens"); + } else { + setCaption(value); + } + } + }, "", "Short", "Long")); + + addComponent(createSimpleSelector("Expand ratio", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent(); + if (parent == null) { + return; + } + String value = event.getProperty().getValue() + .toString(); + parent.setExpandRatio(SampleChild.this, + Float.parseFloat(value)); + } + }, "0", "1", "2")); + + // Why is Alignment not an enum? Now we have to use reflection just + // to get the different values as hardcoding is never an option! ;) + List alignmentValues = new ArrayList(); + Field[] fields = Alignment.class.getDeclaredFields(); + for (Field field : fields) { + if (field.getType() == Alignment.class) { + alignmentValues.add(field.getName()); + } + } + addComponent(createSimpleSelector("Alignment", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + String value = event.getProperty().getValue() + .toString(); + AlignmentHandler parent = (AlignmentHandler) getParent(); + if (parent == null) { + return; + } + try { + Field field = Alignment.class + .getDeclaredField(value); + Alignment alignment = (Alignment) field + .get(null); + parent.setComponentAlignment(SampleChild.this, + alignment); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }, alignmentValues, "TOP_LEFT")); // Sorry for not using + // more reflection magic + // just to find the + // default value... + + } + } + + private AbstractOrderedLayout currentLayout; + + @Override + public void setup() { + TestUtils.injectCSS(getMainWindow(), + ".showBorders {border: 1px solid black};"); + + currentLayout = new HorizontalLayout(); + for (int i = 0; i < 3; i++) { + currentLayout.addComponent(new SampleChild()); + } + + HorizontalLayout sizeBar = new HorizontalLayout(); + sizeBar.setSpacing(true); + + sizeBar.addComponent(createSimpleSelector("Layout width", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + currentLayout.setWidth(event.getProperty().getValue() + .toString()); + } + }, dimensionValues)); + sizeBar.addComponent(createSimpleSelector("Layout height", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + currentLayout.setHeight(event.getProperty().getValue() + .toString()); + } + }, dimensionValues)); + sizeBar.addComponent(createSimpleSelector("Direction", + new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + Object value = event.getProperty().getValue(); + + AbstractOrderedLayout newLayout; + if (value.equals("Horizontal")) { + newLayout = new HorizontalLayout(); + } else { + newLayout = new VerticalLayout(); + } + + while (currentLayout.getComponentCount() > 0) { + newLayout.addComponent(currentLayout + .getComponent(0)); + } + newLayout.setStyleName("showBorders"); + + newLayout.setHeight(currentLayout.getHeight(), + currentLayout.getHeightUnits()); + newLayout.setWidth(currentLayout.getWidth(), + currentLayout.getWidthUnits()); + + getLayout().replaceComponent(currentLayout, newLayout); + currentLayout = newLayout; + } + }, "Horizontal", "Vertical")); + + addComponent(sizeBar); + addComponent(currentLayout); + + getLayout().setSpacing(true); + getMainWindow().getContent().setSizeFull(); + getLayout().setSizeFull(); + getLayout().setExpandRatio(currentLayout, 1); + } + + private static NativeSelect createSimpleSelector(String caption, + ValueChangeListener listener, String... values) { + return createSimpleSelector(caption, listener, Arrays.asList(values), + values[0]); + } + + private static NativeSelect createSimpleSelector(String caption, + ValueChangeListener listener, List values, + String defaultValue) { + NativeSelect selector = new NativeSelect(caption, values); + selector.setNullSelectionAllowed(false); + selector.setImmediate(true); + selector.addListener(listener); + selector.setValue(defaultValue); + return selector; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected String getDescription() { + return "Tester application for exploring how Horizontal/VerticalLayout reacts to various settings "; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java new file mode 100644 index 0000000000..fe99cfaf2a --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java @@ -0,0 +1,91 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Layout; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class ScrollDetachSynchronization extends TestBase { + + @Override + public void setup() { + Window mainWindow = new Window("Synctest Application"); + mainWindow.setContent(buildLayout()); + setMainWindow(mainWindow); + } + + @Override + protected String getDescription() { + return "Scrolling, then detaching, a table causes out of sync on IE"; + } + + @Override + protected Integer getTicketNumber() { + return 6970; + } + + private Layout buildLayout() { + final VerticalLayout mainLayout = new VerticalLayout(); + mainLayout.setSizeFull(); + + HorizontalLayout buttonBar = new HorizontalLayout(); + buttonBar.setSizeUndefined(); + Button first = new Button("First layout"); + Button second = new Button("Second layout"); + first.setDebugId("FirstButton"); + second.setDebugId("SecondButton"); + buttonBar.addComponent(first); + buttonBar.addComponent(second); + mainLayout.addComponent(buttonBar); + + final HorizontalLayout firstLayout = buildTestLayout(true); + final HorizontalLayout secondLayout = buildTestLayout(false); + + mainLayout.addComponent(firstLayout); + mainLayout.setExpandRatio(firstLayout, 1); + + first.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + if (mainLayout.getComponent(1).equals(secondLayout)) { + mainLayout.replaceComponent(secondLayout, firstLayout); + mainLayout.setExpandRatio(firstLayout, 1); + } + } + }); + second.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + if (mainLayout.getComponent(1).equals(firstLayout)) { + mainLayout.replaceComponent(firstLayout, secondLayout); + mainLayout.setExpandRatio(secondLayout, 1); + } + } + }); + return mainLayout; + } + + private HorizontalLayout buildTestLayout(boolean first) { + String which = first ? "First" : "Second"; + + HorizontalLayout hl = new HorizontalLayout(); + hl.setSizeFull(); + hl.setDebugId(which + "Layout"); + + Table t = new Table(); + t.addContainerProperty("name", String.class, null); + for (int i = 0; i < 10; i++) { + String id = which + " " + i; + t.addItem(new String[] { id }, id); + } + t.setDebugId(which + "Table"); + t.setItemCaptionPropertyId("name"); + t.setSizeFull(); + + hl.addComponent(t); + + return hl; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java index 90a9191036..f7d85f1a3c 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java @@ -10,10 +10,14 @@ public class TableHeaderZoom extends TestBase { @Override protected void setup() { Table table = new Table(); - table.setHeight("100px"); - table.setWidth("200px"); - table.setEnabled(false); + table.setHeight("400px"); + table.setWidth("400px"); table.addContainerProperty("Column 1", String.class, ""); + table.addContainerProperty("Column 2", String.class, ""); + + for (int i = 0; i < 100; ++i) { + table.addItem(new Object[] { "" + i, "foo" }, i); + } Window main = getMainWindow(); main.setContent(new CssLayout()); diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java new file mode 100644 index 0000000000..a536303061 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java @@ -0,0 +1,43 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Table; + +public class TableRepaintWhenMadeVisibile extends TestBase { + + @Override + public void setup() { + final Table table = new Table(); + table.addContainerProperty("sth", String.class, null); + table.addItem(new Object[] { "something" }, 1); + addComponent(table); + + Button show = new Button("show", new ClickListener() { + + public void buttonClick(ClickEvent event) { + table.setVisible(true); + } + }); + addComponent(show); + Button hide = new Button("hide", new ClickListener() { + + public void buttonClick(ClickEvent event) { + table.setVisible(false); + } + }); + addComponent(hide); + } + + @Override + protected String getDescription() { + return "A Table should be rendered correctly when made visible again after being initially rendered invisible. Click 'hide', refresh the application and then click 'show'"; + } + + @Override + protected Integer getTicketNumber() { + return 7986; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html new file mode 100644 index 0000000000..0563acd4a5 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html @@ -0,0 +1,42 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile?restartApplication
clickvaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
open/run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile
clickvaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturehidden-then-shown
+ + diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java new file mode 100644 index 0000000000..e5947576a2 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.components.tabsheet; + +import com.vaadin.Application; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ComponentContainer; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class WrapTabSheetInTabSheet extends TestBase { + @Override + protected void setup() { + final VerticalLayout mainLayout = new VerticalLayout(); + mainLayout.addComponent(new Label("This is main layout")); + addComponent(mainLayout); + + Button b = new Button("Wrap main layout in a TabSheet"); + b.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + TabSheet tabsheet = new TabSheet(); + ComponentContainer mainParent = (ComponentContainer) mainLayout + .getParent(); + mainParent.replaceComponent(mainLayout, tabsheet); + tabsheet.addTab(mainLayout, "Default tab"); + } + }); + mainLayout.addComponent(b); + } + + @Override + protected String getDescription() { + return "Click the button to add a TabSheet and move the window content into the TabSheet. Every click should wrap the contents with a new TabSheet and the contents should remain visible."; + } + + @Override + protected Integer getTicketNumber() { + return 8238; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java new file mode 100644 index 0000000000..0fc63860e1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java @@ -0,0 +1,54 @@ +package com.vaadin.tests.components.textarea; + +import com.vaadin.event.FieldEvents.TextChangeEvent; +import com.vaadin.event.FieldEvents.TextChangeListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.AbstractTextField; +import com.vaadin.ui.AbstractTextField.TextChangeEventMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; + +public class TextAreaCursorPosition extends TestBase { + + private TextField cursorPosition = new TextField("Cursor position"); + + @Override + public void setup() { + Label label = new Label( + "Test of calculation of cursor position of TextArea"); + TextArea textArea = new TextArea(); + addListener(textArea); + addComponent(label); + addComponent(textArea); + addComponent(cursorPosition); + cursorPosition.setValue("?"); + addComponent(new Button("Force position update")); + } + + public void addListener(AbstractField newField) { + AbstractTextField newTextField = (AbstractTextField) newField; + newTextField.setTextChangeEventMode(TextChangeEventMode.EAGER); + + newTextField.addListener(new TextChangeListener() { + public void textChange(TextChangeEvent event) { + AbstractTextField component = (AbstractTextField) event + .getComponent(); + cursorPosition.setValue(component.getCursorPosition()); + } + }); + } + + @Override + protected String getDescription() { + return "Writing something in the field updates the cursor position field. The position field can also be updated using the button."; + } + + @Override + protected Integer getTicketNumber() { + return 7726; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java new file mode 100644 index 0000000000..6aac7caddd --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java @@ -0,0 +1,57 @@ +package com.vaadin.tests.components.textfield; + +import com.vaadin.event.ShortcutAction.KeyCode; +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.Button.ClickListener; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.TextField; + +public class TextFieldInputPromptAndClickShortcut extends TestBase { + + @Override + protected void setup() { + final Log log = new Log(5); + + final TextField textField = new TextField(); + Button button = new Button("Show Text", new ClickListener() { + public void buttonClick(ClickEvent event) { + log.log("Field value: " + textField.getValue()); + } + }); + button.setClickShortcut(KeyCode.ESCAPE); + + final CheckBox inputPromptSelection = new CheckBox("Input prompt", + new ClickListener() { + public void buttonClick(ClickEvent event) { + if (event.getButton().getValue() == Boolean.TRUE) { + textField.setInputPrompt("Input prompt"); + } else { + textField.setInputPrompt(null); + } + log.log("Set input prompt: " + + textField.getInputPrompt()); + } + }); + inputPromptSelection.setImmediate(true); + + addComponent(textField); + addComponent(button); + addComponent(inputPromptSelection); + addComponent(log); + } + + @Override + protected String getDescription() { + return "With the input propmpt enabled, enter something into the field, press enter, remove the entered text and press the button. The previous text is still reported as the value. Without the input prompt, the new value is instead reported as blank."; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} -- 2.39.5