final Selectable selectable = tree.getSelectableAsEnum();
if (selectable.isSupportedByTree()) {
writer.writeAttribute(DataAttributes.SELECTABLE, selectable.getValue(), false);
}
final SelectedState selectedState = tree.getSelectedState();
final StringBuilder selectedValue = new StringBuilder(",");
final ExpandedState expandedState = tree.getExpandedState();
final StringBuilder expandedValue = new StringBuilder(",");
final int last = tree.isRowsUnlimited() ? Integer.MAX_VALUE : tree.getFirst() + tree.getRows();
for (int rowIndex = tree.getFirst(); rowIndex < last; rowIndex++) {
tree.setRowIndex(rowIndex);
if (!tree.isRowAvailable()) {
break;
}
final TreePath path = tree.getPath();
if (selectedState.isSelected(path)) {
selectedValue.append(rowIndex);
selectedValue.append(",");
}
if (tree.isFolder() && expandedState.isExpanded(path)) {