- Timestamp:
- 07/23/08 09:06:17 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/itmill/toolkit/tests/book/BookTestApplication.java
r5111 r5113 309 309 final Tree tree = new Tree(); 310 310 311 / * Add planets as root items in the tree. */311 // Add planets as root items in the tree. 312 312 for (int i = 0; i < planets.length; i++) { 313 313 final String planet = (String) (planets[i][0]); … … 315 315 316 316 if (planets[i].length == 1) { 317 / * The planet has no moons so make it a leaf. */317 // The planet has no moons so make it a leaf. 318 318 tree.setChildrenAllowed(planet, false); 319 319 } else { 320 / * Add children (moons) under the planets. */320 // Add children (moons) under the planets. 321 321 for (int j = 1; j < planets[i].length; j++) { 322 322 final String moon = (String) planets[i][j]; 323 323 324 / * Add the item as a regular item. */324 // Add the item as a regular item. 325 325 tree.addItem(moon); 326 326 327 / * Set it to be a child. */327 // Set it to be a child. 328 328 tree.setParent(moon, planet); 329 329 330 / * Make the moons look like leaves. */330 // Make the moons look like leaves. 331 331 tree.setChildrenAllowed(moon, false); 332 332 } 333 333 334 / * Expand the subtree. */334 // Expand the subtree. 335 335 tree.expandItemsRecursively(planet); 336 336 } … … 353 353 detailspanel.setLayout(detailslayout); 354 354 355 // When a tree item (planet or moon) is clicked, open the item in Details view. 356 tree.setImmediate(true); 357 tree.addListener(new ValueChangeListener() { 358 public void valueChange(ValueChangeEvent event) { 359 String planet = (String) tree.getValue(); 355 // Allow null selection - this is the default actually. 356 tree.setNullSelectionAllowed(true); 357 358 // When a tree item (planet or moon) is clicked, open the item in Details view. 359 tree.setImmediate(true); 360 tree.addListener(new ValueChangeListener() { 361 String lastselected = null; 362 363 public void valueChange(ValueChangeEvent event) { 364 String planet = (String) tree.getValue(); 365 366 // Reselect a selected item if it is unselected by clicking it. 367 if (planet == null) { 368 planet = lastselected; 369 tree.setValue(planet); 370 } 371 lastselected = planet; 372 360 373 detailspanel.setCaption("Details on " + planet); 361 374 detailslayout.removeAllComponents(); … … 364 377 detailslayout.addComponent(new Label("Where is the cat?")); 365 378 detailslayout.addComponent(new Label("The cat is in " + planet + ".")); 379 366 380 } 367 381 }); … … 564 578 } else if (param.equals("editable")) { 565 579 main.addComponent(new TableEditable()); 580 } else if (param.equals("bean")) { 581 main.addComponent(new TableEditableBean()); 566 582 } else if (param.equals("paging")) { 567 583 PagingTable table = new PagingTable();
