Skip to content

Commit

Permalink
Fix TreeTableContextClick support (#19056)
Browse files Browse the repository at this point in the history
Change-Id: Ib6bac73ba96c4919df2e1bf5c9c83160707530bb
  • Loading branch information
Teemu Suo-Anttila authored and Henri Sara committed Oct 2, 2015
1 parent 4e02b7e commit 904ae72
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/com/vaadin/client/ui/table/TableConnector.java
Expand Up @@ -104,7 +104,7 @@ protected void sendContextClickEvent(ContextMenuEvent event) {
colKey = w.getColKey();
} else if (getWidget().scrollBody.getElement().isOrHasChild(e)) {
section = Section.BODY;
VScrollTableRow w = WidgetUtil.findWidget(e, VScrollTableRow.class);
VScrollTableRow w = getScrollTableRow(e);
rowKey = w.getKey();
colKey = getWidget().tHead.getHeaderCell(
getElementIndex(e, w.getElement())).getColKey();
Expand All @@ -124,6 +124,10 @@ protected void sendContextClickEvent(ContextMenuEvent event) {
details);
}

protected VScrollTableRow getScrollTableRow(Element e) {
return WidgetUtil.findWidget(e, VScrollTableRow.class);
}

private int getElementIndex(Element e,
com.google.gwt.user.client.Element element) {
int i = 0;
Expand Down
Expand Up @@ -143,4 +143,9 @@ public TooltipInfo getTooltipInfo(Element element) {

return info;
}

@Override
protected VScrollTableRow getScrollTableRow(Element e) {
return WidgetUtil.findWidget(e, VTreeTableRow.class);
}
}
@@ -0,0 +1,53 @@
/*
* 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.contextclick;

import com.vaadin.data.Item;
import com.vaadin.shared.ui.table.TableConstants.Section;
import com.vaadin.tests.util.PersonContainer;
import com.vaadin.ui.Table.TableContextClickEvent;
import com.vaadin.ui.TreeTable;

public class TreeTableContextClick extends
AbstractContextClickUI<TreeTable, TableContextClickEvent> {

@Override
protected TreeTable createTestComponent() {
TreeTable treeTable = new TreeTable();
treeTable.setContainerDataSource(PersonContainer.createWithTestData());
treeTable.setFooterVisible(true);
return treeTable;
}

@Override
protected void handleContextClickEvent(TableContextClickEvent event) {
String value = "";
Object propertyId = event.getPropertyId();
if (event.getItemId() != null) {
Item item = event.getComponent().getContainerDataSource()
.getItem(event.getItemId());
value += item.getItemProperty("firstName").getValue() + " ";
value += item.getItemProperty("lastName").getValue();
} else if (event.getSection() == Section.HEADER) {
value = testComponent.getColumnHeader(propertyId);
} else if (event.getSection() == Section.FOOTER) {
value = testComponent.getColumnFooter(propertyId);
}
log("ContextClickEvent value: " + value + ", propertyId: " + propertyId
+ ", section: " + event.getSection());
}

}
@@ -0,0 +1,32 @@
/*
* 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.contextclick;

import org.openqa.selenium.interactions.Actions;

public class TreeTableContextClickTest extends TableContextClickTest {

@Override
protected Class<?> getUIClass() {
return TreeTableContextClick.class;
}

@Override
protected void contextClick(org.openqa.selenium.WebElement e) {
new Actions(getDriver()).moveToElement(e, 10, 10).contextClick()
.perform();
};
}

0 comments on commit 904ae72

Please sign in to comment.