diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2013-01-23 13:14:18 +0200 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2013-02-14 15:15:11 +0200 |
commit | 7a111fc541dcc507032cdad6799b477df6d4833f (patch) | |
tree | 426d7a0e7f971562cd5c0be265ae374dcca74802 /uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java | |
parent | 12996f599cf5284b4c2994764e26e700011e1a64 (diff) | |
download | vaadin-framework-7a111fc541dcc507032cdad6799b477df6d4833f.tar.gz vaadin-framework-7a111fc541dcc507032cdad6799b477df6d4833f.zip |
Merge of (#6160) and (#10470) to Vaadin 7.
Cache handling update.
Change-Id: I81ba74d457eb484f6f2c350629534ab284ead7b7
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java index c2bd3da860..f792a32f8f 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java @@ -72,13 +72,11 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { public Component generateCell(final com.vaadin.ui.Table source, final Object itemId, Object columnId) { TestBean tb = (TestBean) itemId; - // if (!tb.getCol1().contains("children")) { - // return null; - // } String identifier = "Item " + itemId + "/" + columnId; - System.out.println("Generating new Button for " + identifier); Button btnCol3 = new NativeButton(identifier); - btnCol3.addListener(new Button.ClickListener() { + btnCol3.setId("cacheTestButton-" + tb.getCol1() + "-" + + tb.getCol2()); + btnCol3.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { log.log("Button " + event.getButton().getCaption() @@ -91,6 +89,25 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { } + public class Col4ColumnGenerator implements ColumnGenerator { + public Component generateCell(final com.vaadin.ui.Table source, + final Object itemId, Object columnId) { + TestBean tb = (TestBean) itemId; + String identifier = "Expand/Collapse"; + Button btnCol4 = new NativeButton(identifier); + btnCol4.setId("cacheTestButtonToggle-" + tb.getCol1() + "-" + + tb.getCol2()); + btnCol4.addClickListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + treeTable.setCollapsed(itemId, + !treeTable.isCollapsed(itemId)); + } + }); + return btnCol4; + } + + } + protected int indexOfId(Table source, Object itemId) { Container.Ordered c = (Ordered) source.getContainerDataSource(); if (c instanceof Container.Indexed) { @@ -105,19 +122,17 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { private TreeTable treeTable; private BeanItemContainer<TestBean> testBeanContainer; private static String[] columnHeaders = new String[] { "Col1", "Col2", - "Col3" }; + "Col3", "Col4" }; private static Object[] visibleColumns = new Object[] { "col1", "col2", - "col3" }; + "col3", "col4" }; @Override public void setup() { - setTheme("reindeer-tests"); - // Force row height to be the same in all browsers so scrolling based on // pixels works as expected Button b = new Button("Show first"); addComponent(b); - b.addListener(new ClickListener() { + b.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { @@ -132,7 +147,7 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { cacheRateSelect.addItem(new Integer(1)); cacheRateSelect.addItem(new Integer(2)); cacheRateSelect.setValue(2); - cacheRateSelect.addListener(new ValueChangeListener() { + cacheRateSelect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { @@ -143,7 +158,6 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { addComponent(cacheRateSelect); treeTable = new TreeTable(); treeTable.addStyleName("table-equal-rowheight"); - // treeTable.setPageLength(0); testBeanContainer = new BeanItemContainer<TestBean>(TestBean.class); Map<String, Integer> hasChildren = new HashMap<String, Integer>(); @@ -156,7 +170,8 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { hasChildren.put("99", 20); treeTable.setContainerDataSource(createContainer(100, hasChildren)); treeTable.addGeneratedColumn("col3", new Col3ColumnGenerator()); - treeTable.addListener(new ExpandListener() { + treeTable.addGeneratedColumn("col4", new Col4ColumnGenerator()); + treeTable.addExpandListener(new ExpandListener() { @Override public void nodeExpand(ExpandEvent event) { @@ -164,7 +179,7 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { } }); - treeTable.addListener(new CollapseListener() { + treeTable.addCollapseListener(new CollapseListener() { @Override public void nodeCollapse(CollapseEvent event) { @@ -172,12 +187,11 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { } }); - treeTable.setColumnHeaders(columnHeaders); treeTable.setVisibleColumns(visibleColumns); + treeTable.setColumnHeaders(columnHeaders); treeTable.setColumnWidth("col1", 150); treeTable.setColumnWidth("col2", 50); treeTable.setHeight("430px"); - // treeTable.setColumnWidth("col3", 150); addComponent(log); addComponent(treeTable); } |