From 1f4ca4cb82e0144053b8a8d5266535da6af0f21f Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 25 Mar 2014 17:49:15 +0200 Subject: Prevent resize for sorted column if not initialized (#12951) Change-Id: I184625738f6d5d9324f957827f7f11817e311c59 --- client/src/com/vaadin/client/ui/table/TableConnector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index 80a84f0a19..e8b14955ed 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -303,7 +303,9 @@ public class TableConnector extends AbstractHasComponentsConnector implements getWidget().tabIndex = getState().tabIndex; getWidget().setProperTabIndex(); - getWidget().resizeSortedColumnForSortIndicator(); + if (getWidget().initializedAndAttached) { + getWidget().resizeSortedColumnForSortIndicator(); + } // Remember this to detect situations where overflow hack might be // needed during scrolling -- cgit v1.2.3 From f9796817e8557d716a31d9411919431cfbfa63e6 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 26 Mar 2014 10:39:46 +0200 Subject: Fix VScrollTable to clear reported ranges (#13353) Change-Id: Ieb0e2dce37ae1564151bf40d9d51cb013490b865 --- client/src/com/vaadin/client/ui/VScrollTable.java | 5 +- .../table/AddSelectionToRemovedRange.java | 93 ++++++++++++++++++++++ .../table/AddSelectionToRemovedRangeTest.java | 74 +++++++++++++++++ 3 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java create mode 100644 uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.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 e800e7fe79..7c22fa2199 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -324,13 +324,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets, ArrayList ranges = new ArrayList(2); int endOfFirstRange = row.getIndex() - 1; - if (!(endOfFirstRange - startRow.getIndex() < 0)) { + if (endOfFirstRange >= startRow.getIndex()) { // create range of first part unless its length is < 1 ranges.add(new SelectionRange(startRow, endOfFirstRange - startRow.getIndex() + 1)); } int startOfSecondRange = row.getIndex() + 1; - if (!(getEndIndex() - startOfSecondRange < 0)) { + if (getEndIndex() >= startOfSecondRange) { // create range of second part unless its length is < 1 VScrollTableRow startOfRange = scrollBody .getRowByRowIndex(startOfSecondRange); @@ -860,6 +860,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Send the selected row ranges client.updateVariable(paintableId, "selectedRanges", ranges.toArray(new String[selectedRowRanges.size()]), false); + selectedRowRanges.clear(); // clean selectedRowKeys so that they don't contain excess values for (Iterator iterator = selectedRowKeys.iterator(); iterator diff --git a/uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java b/uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java new file mode 100644 index 0000000000..d54a8b467a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java @@ -0,0 +1,93 @@ +/* + * Copyright 2000-2013 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.table; + +import java.util.Set; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.tb3.AbstractTB3Test.RunLocally; +import com.vaadin.ui.Button; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Notification.Type; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +/** + * Test to see if selecting and deselecting a table row after select range has + * been removed. + * + * @since 7.1.13 + * @author Vaadin Ltd + */ +@SuppressWarnings("serial") +@RunLocally() +public class AddSelectionToRemovedRange extends AbstractTestUI { + + @Override + @SuppressWarnings("unchecked") + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + layout.setSpacing(true); + setContent(layout); + + final Table table = new Table(); + table.setMultiSelect(true); + table.setSelectable(true); + table.addContainerProperty("value", String.class, ""); + + for (int i = 0; i < 100; i++) { + table.addItem(i); + table.getContainerProperty(i, "value").setValue("value " + i); + } + + layout.addComponent(table); + + Button button = new Button("Remove"); + button.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(Button.ClickEvent event) { + Set selected = (Set) table.getValue(); + + for (Integer item : selected) { + if (null == item) { + new Notification( + "ERROR", + "Table value has null in Set of selected items!", + Type.ERROR_MESSAGE).show(getPage()); + } + table.removeItem(item); + } + } + }); + + layout.addComponent(button); + + } + + @Override + protected String getTestDescription() { + return "Verify that VScrollTable does not return bad ranges when "; + } + + @Override + protected Integer getTicketNumber() { + return 13353; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java b/uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java new file mode 100644 index 0000000000..f6a503db72 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2013 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.table; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class AddSelectionToRemovedRangeTest extends MultiBrowserTest { + + @Override + public List getBrowsersToTest() { + return Collections.unmodifiableList(Arrays.asList(Browser.CHROME + .getDesiredCapabilities())); + } + + @Override + protected DesiredCapabilities getDesiredCapabilities() { + DesiredCapabilities cap = new DesiredCapabilities( + super.getDesiredCapabilities()); + cap.setCapability("requireWindowFocus", true); + return cap; + } + + @Test + public void addAndRemoveItemToRemovedRange() throws IOException { + openTestURL(); + List rows = driver.findElements(By + .className("v-table-cell-wrapper")); + WebElement rangeStart = rows.get(0); + WebElement rangeEnd = rows.get(1); + rangeStart.click(); + new Actions(driver).keyDown(Keys.SHIFT).perform(); + rangeEnd.click(); + new Actions(driver).keyUp(Keys.SHIFT).perform(); + driver.findElement(By.className("v-button")).click(); + WebElement extraRow = driver.findElements( + By.className("v-table-cell-wrapper")).get(1); + new Actions(driver).keyDown(Keys.CONTROL).click(extraRow) + .click(extraRow).keyUp(Keys.CONTROL).perform(); + driver.findElement(By.className("v-button")).click(); + try { + driver.findElement(By.vaadin("Root/VNotification[0]")); + Assert.fail("Notification is shown"); + } catch (NoSuchElementException e) { + // All is well. + } + } +} -- cgit v1.2.3 From 29e7df26ad034eacdbf37fc03985873aabda6576 Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Tue, 25 Mar 2014 14:55:47 +0200 Subject: Makes combobox work with pasted texts. (#13214). Change-Id: I74db581d7aae1278024db4e5ed8e3a3b3abc56be --- client/src/com/vaadin/client/ui/VFilterSelect.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 63c8d3dbf9..0bc4e0d75b 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -1147,6 +1147,32 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, popupOpener.addClickHandler(this); setStyleName(CLASSNAME); + + sinkEvents(Event.ONPASTE); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.user.client.ui.Composite#onBrowserEvent(com.google.gwt + * .user.client.Event) + */ + @Override + public void onBrowserEvent(Event event) { + super.onBrowserEvent(event); + + if (event.getTypeInt() == Event.ONPASTE) { + if (textInputEnabled) { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + filterOptions(currentPage); + } + }); + } + } } /** -- cgit v1.2.3