Issue with tree grid in 1.0.0 [message #1061243] |
Thu, 30 May 2013 17:53 |
Testr t Messages: 93 Registered: April 2013 |
Member |
|
|
Hi,
I have a tree grid with child rows which worked perfectly in 0.9.0 but with 1.0.0 I am able to see the grid but there is no plus sign.
Here is my expansion model the TreeGridFormat which used to work perfectly
public class DataRow
{
final static int Cols = 3;
DataRow parent;
String Name;
// list of data for each column
List<BigInteger> data = new ArrayList<>();
public DataRow( DataRow parent, String name )
{
this.parent = parent;
Name = name;
}
/*
* Initialize the data for the containers.
*/
public void AddColData( int count )
{
for (int cont = 0; cont < count; cont++)
{
BigInteger colData = new BigInteger( 32, new Random() );
data.add( colData );
}
}
/*
* Adds child rows for the row
*/
public List<DataRow> AddChildren()
{
List<DataRow> childRows = new ArrayList<>();
for (int c = 0; c <= 5; c++)
{
DataRow childRow = new DataRow( this, "Child" + c );
childRow.AddColData( Cols );
childRows.add( childRow );
}
return childRows;
}
public DataRow getParent()
{
return parent;
}
public String getName()
{
return Name;
}
public int Count()
{
return data.size();
}
public String getData( int colIndex )
{
String hexValue = "";
hexValue = Integer.toHexString( colIndex );
return hexValue;
}
public void setData(int col, String value)
{
}
}
/*
* Class that defines the tree structure of a node by expressing the path from the element itself to the tree's root.
*/
private static class TreeFormat implements TreeList.Format<DataRow>
{
public TreeFormat( ISortModel sortModel )
{
}
/*
* Populate path with a list describing the path from a root node to this element.
* Upon returning, the list must have size >= 1, where the provided element identical to the list's last element.
* @param path //a list that the implementor shall add their path elements to via path.add(). This may be a non-empty List and it is an error to call any method other than add().
*/
public void getPath( List<DataRow> path, DataRow row )
{
path.add( row );
DataRow parent = row.getParent();
while( parent != null )
{
path.add(0, parent );
parent = parent.getParent();
}
//Collections.reverse( path );
}
/*
* Indicate whether an element can have children
*/
public boolean allowsChildren( DataRow row )
{
return true;
}
/*
* Returns the comparator used to order path elements of the specified depth.
* If enforcing order at this level is not intended, this method should return null.
*/
public Comparator<DataRow> getComparator( int depth )
{
return null;
}
}
/*
* Tree grid expansion model. Need to be implemented to set the initial expand/collapse state
*/
private class TreeExpansionModel implements ExpansionModel<DataRow>
{
/*
* Determines the specified element's initial expand/collapse state.
*/
public boolean isExpanded( DataRow element, List<DataRow> path )
{
//initial state of the grid would be collapsed
return false;
}
/*
* Handler method when a row expand/collapse state is changed
*/
public void setExpanded( DataRow element, List<DataRow> path, boolean expanded )
{
//currently we don't have to track expand or collapsed state of a row
}
}
And I used the tree grid example to create the lists
// Underlying data source
EventList<DataRow> eventList = GlazedLists.eventList( rows );
SortedList<DataRow> sortedList = new SortedList<>( eventList, null );
int columns = eventList.get( 0 ).Count();
NumCols = FirstValueCol + columns;
//Column accessor
IColumnPropertyAccessor<DataRow> columnPropertyAccessor = new ColumnPropertyAccessor();
// Column header layer
List<String> colNames = new ArrayList<>();
colNames.add( "Name" );
for (int col = 0; col < columns; col++)
colNames.add("Col " + " " + col );
String[] colLabels = (String[]) colNames.toArray( new String[0] );
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider( colLabels );
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer( columnHeaderDataProvider );
ISortModel sortModel = new GlazedListsSortModel<DataRow>( sortedList, columnPropertyAccessor, configRegistry, columnHeaderDataLayer );
final TreeList<DataRow> treeList = new TreeList<DataRow>( sortedList, new TreeFormat( sortModel ), new TreeExpansionModel() );
GlazedListTreeData<DataRow> treeData = new GlazedListTreeData<>( treeList );
bodyDataProvider = new GlazedListsDataProvider<>( treeList, columnPropertyAccessor );
DataLayer bodyDataLayer = new DataLayer( bodyDataProvider );
bodyDataLayer.setDefaultColumnWidthByPosition( 1, 60 );
// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer( bodyDataLayer );
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer( columnReorderLayer );
SelectionLayer selectionLayer = new SelectionLayer( columnHideShowLayer );
// Switch the ITreeRowModel implementation between using native grid
// Hide/Show or GlazedList TreeList Hide/Show
// TreeLayer treeLayer = new TreeLayer(selectionLayer, new TreeRowModel(treeData), true);
TreeLayer treeLayer = new TreeLayer( selectionLayer, new GlazedListTreeRowModel<DataRow>( treeData ), false );
treeLayer.setConfigLabelAccumulator( new CellStateAccumulator() );
ViewportLayer viewportLayer = new ViewportLayer( treeLayer );
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer( columnHeaderDataLayer, viewportLayer, selectionLayer );
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator( columnHeaderDataLayer );
columnHeaderDataLayer.setConfigLabelAccumulator( labelAccumulator );
SortHeaderLayer<DataRow> sortHeaderLayer = new SortHeaderLayer<>( columnHeaderLayer, sortModel, false );
// Row header layer
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider( bodyDataProvider );
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer( rowHeaderDataProvider );
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer( rowHeaderDataLayer, viewportLayer, selectionLayer );
// Corner layer
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider( columnHeaderDataProvider, rowHeaderDataProvider );
DataLayer cornerDataLayer = new DataLayer( cornerDataProvider );
CornerLayer cornerLayer = new CornerLayer( cornerDataLayer, rowHeaderLayer, sortHeaderLayer );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04472 seconds