Show
Ignore:
Timestamp:
07/23/08 09:06:17 (4 months ago)
Author:
magi@…
Message:

Updated book tests: editable tables.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/tests/book/BookTestApplication.java

    r5111 r5113  
    309309        final Tree tree = new Tree(); 
    310310 
    311         /* Add planets as root items in the tree. */ 
     311        // Add planets as root items in the tree. 
    312312        for (int i = 0; i < planets.length; i++) { 
    313313            final String planet = (String) (planets[i][0]); 
     
    315315 
    316316            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. 
    318318                tree.setChildrenAllowed(planet, false); 
    319319            } else { 
    320                 /* Add children (moons) under the planets. */ 
     320                // Add children (moons) under the planets. 
    321321                for (int j = 1; j < planets[i].length; j++) { 
    322322                    final String moon = (String) planets[i][j]; 
    323323 
    324                     /* Add the item as a regular item. */ 
     324                    // Add the item as a regular item. 
    325325                    tree.addItem(moon); 
    326326 
    327                     /* Set it to be a child. */ 
     327                    // Set it to be a child. 
    328328                    tree.setParent(moon, planet); 
    329329 
    330                     /* Make the moons look like leaves. */ 
     330                    // Make the moons look like leaves. 
    331331                    tree.setChildrenAllowed(moon, false); 
    332332                } 
    333333 
    334                 /* Expand the subtree. */ 
     334                // Expand the subtree. 
    335335                tree.expandItemsRecursively(planet); 
    336336            } 
     
    353353        detailspanel.setLayout(detailslayout); 
    354354         
    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                 
    360373                detailspanel.setCaption("Details on " + planet); 
    361374                detailslayout.removeAllComponents(); 
     
    364377                detailslayout.addComponent(new Label("Where is the cat?")); 
    365378                detailslayout.addComponent(new Label("The cat is in " + planet + ".")); 
     379                 
    366380            } 
    367381        }); 
     
    564578            } else if (param.equals("editable")) { 
    565579                main.addComponent(new TableEditable()); 
     580            } else if (param.equals("bean")) { 
     581                main.addComponent(new TableEditableBean()); 
    566582            } else if (param.equals("paging")) { 
    567583                PagingTable table = new PagingTable();