*/
private void setCollapsed(int rowIndex, boolean collapsed,
boolean userOriginated) {
- if (isAwaitingRowChange()) {
+ if (isAwaitingRowChange() || !getState().enabled) {
return;
}
if (collapsed) {
? t -> "level" + t.getDepth()
: t -> null))
.setCheckable(true);
+ MenuItem enabled = componentMenu.addItem("Enabled",
+ menuItem -> tree.setEnabled(!tree.isEnabled()));
+ enabled.setCheckable(true);
+ enabled.setChecked(true);
+
+ componentMenu.addItem("Expand 0 | 0",
+ menuItem -> tree.expand(new HierarchicalTestBean(null, 0, 0)));
+ componentMenu.addItem("Collapse 0 | 0", menuItem -> tree
+ .collapse(new HierarchicalTestBean(null, 0, 0)));
return menu;
}
$(TreeElement.class).first().getItem(0).showTooltip();
assertEquals("", "0 | 0", getTooltipElement().getText());
}
+
+ @Test
+ public void tree_disable_enable_expand_collapse() {
+ TreeElement tree = $(TreeElement.class).first();
+ selectMenuPath("Component", "Enabled");
+ assertTrue(tree.hasClassName("v-disabled"));
+ // ensure expanding doesn't work
+ tree.expand(0);
+ assertEquals("0 | 1", tree.getItem(1).getText());
+ selectMenuPath("Component", "Enabled");
+ assertFalse(tree.hasClassName("v-disabled"));
+ // ensure expanding and collapsing works again
+ tree.expand(0);
+ assertEquals("1 | 0", tree.getItem(1).getText());
+ tree.collapse(0);
+ assertEquals("0 | 1", tree.getItem(1).getText());
+ // same test for server-side expanding and collapsing
+ selectMenuPath("Component", "Expand 0 | 0");
+ assertEquals("1 | 0", tree.getItem(1).getText());
+ selectMenuPath("Component", "Collapse 0 | 0");
+ assertEquals("0 | 1", tree.getItem(1).getText());
+ }
}
assertEquals("Not expanded", "1 | 0", grid.getCell(1, 0).getText());
}
+ @Test
+ public void disable_enable_expand_collapse() {
+ TreeGridElement treeGrid = $(TreeGridElement.class).first();
+ selectMenuPath("Component", "State", "Enabled");
+ assertTrue(treeGrid.hasClassName("v-disabled"));
+ // ensure expanding doesn't work
+ treeGrid.expandWithClick(0);
+ assertCellTexts(1, 0, new String[] { "0 | 1" });
+ selectMenuPath("Component", "State", "Enabled");
+ assertFalse(treeGrid.hasClassName("v-disabled"));
+ // ensure expanding and collapsing works again
+ treeGrid.expandWithClick(0);
+ assertCellTexts(1, 0, new String[] { "1 | 0" });
+ treeGrid.collapseWithClick(0);
+ assertCellTexts(1, 0, new String[] { "0 | 1" });
+ // same test for server-side expanding and collapsing
+ selectMenuPath("Component", "Features", "Server-side expand",
+ "Expand 0 | 0");
+ assertCellTexts(1, 0, new String[] { "1 | 0" });
+ selectMenuPath("Component", "Features", "Server-side collapse",
+ "Collapse 0 | 0");
+ assertCellTexts(1, 0, new String[] { "0 | 1" });
+ }
+
private void assertCellTexts(int startRowIndex, int cellIndex,
String[] cellTexts) {
int index = startRowIndex;