SwingTree extends AbstractSwingContainer implements XulTree { public Object[][] getValues() { TableModel model = table.getModel(); Object[][] data = new Object[getRootChildren().getChildNodes().size()][model.getColumnCount()]; int y = 0; for ( XulComponent item : getRootChildren().getChildNodes() ) { int x = 0; for ( XulComponent tempCell : ( (XulTreeItem) item ).getRow().getChildNodes() ) { SwingTreeCell cell = (SwingTreeCell) tempCell; switch ( columns.getColumn( x ).getColumnType() ) { case CHECKBOX: Boolean flag = (Boolean) cell.getValue(); if ( flag == null ) { flag = Boolean.FALSE; } data[y][x] = flag; break; case COMBOBOX: Vector values = (Vector) cell.getValue(); int idx = cell.getSelectedIndex(); data[y][x] = values.get( idx ); break; default: data[y][x] = cell.getLabel(); break; } x++; } y++; } return data; } SwingTree( Element self, XulComponent parent, XulDomContainer domContainer, String tagName ); JTable getTable(); JTree getTree(); int[] getActiveCellCoordinates(); XulTreeCols getColumns(); String getOnselect(); XulTreeChildren getRootChildren(); int getRows(); String getSeltype(); Object[][] getValues(); int getWidth(); void setWidth( int width ); boolean isDisabled(); boolean isEditable(); boolean isEnableColumnDrag(); boolean isHierarchical(); void setActiveCellCoordinates( int row, int column ); void setDisabled( boolean dis ); void setEditable( boolean edit ); void setEnableColumnDrag( boolean drag ); void setOnselect( final String select ); void setColumns( XulTreeCols columns ); void setRootChildren( final XulTreeChildren rootChildren ); void addTreeRow( XulTreeRow row ); void removeTreeRows( int[] rows ); void setRows( int rows ); void setSeltype( String type ); void setTableModel( TableModel model ); @Override void layout(); @Override void replaceChild( XulComponent oldElement, XulComponent newElement ); @Override Object getManagedObject(); int[] getSelectedRows(); int[] getAbsoluteSelectedRows(); void addRow( XulTreeRow row ); Object getData(); void setData( Object data ); void update(); void clearSelection(); void setSelectedRows( int[] rows ); String getOnedit(); void setOnedit( String onedit ); void setElements( Collection<T> elements ); Collection<T> getElements(); Object getSelectedItem(); void setExpanded( boolean expanded ); boolean getExpanded(); void registerCellEditor( String key, org.pentaho.ui.xul.util.TreeCellEditor editor ); void registerCellRenderer( String key, TreeCellRenderer renderer ); void setBoundObjectExpanded( Object o, boolean expanded ); void setTreeItemExpanded( XulTreeItem item, boolean expanded ); void collapseAll(); void expandAll(); Collection<T> getSelectedItems(); void setSelectedItems( Collection<T> items ); int findIndexOfItem( Object o ); boolean isHiddenrootnode(); void setHiddenrootnode( boolean hidden ); String getCommand(); void setCommand( String command ); boolean isPreserveexpandedstate(); void setPreserveexpandedstate( boolean preserve ); boolean isSortable(); void setSortable( boolean sort ); boolean isTreeLines(); void setTreeLines( boolean visible ); void setNewitembinding( String binding ); String getNewitembinding(); void setAutocreatenewrows( boolean auto ); boolean getAutocreatenewrows(); boolean isPreserveselection(); void setPreserveselection( boolean preserve );  }
@Test public void testGetValues() throws Exception { Object[][] sampleData = new Object[2][5]; sampleData[0] = new Object[] { Boolean.TRUE, "Nick", "bazz", "foo", "Testing" }; sampleData[1] = new Object[] { Boolean.FALSE, "Barb", "bazz", "foo", "Testing 2" }; Object[][] vals = tree.getValues(); for ( int i = 0; i < sampleData.length; i++ ) { for ( int y = 0; y < sampleData[i].length; y++ ) { assertTrue( sampleData[i][y].equals( vals[i][y] ) ); } } }