}
csv.append(lineSeparator);
// Selected values
for (int rowIndex : getSelectedRows()) {
TableModel model = getModel();
HomePieceOfFurniture copiedPiece = (HomePieceOfFurniture)model.getValueAt(rowIndex, 0);
for (int columnIndex = 0, n = this.columnModel.getColumnCount(); columnIndex < n; columnIndex++) {
if (columnIndex > 0) {
csv.append("\t");
}
TableColumn column = this.columnModel.getColumn(columnIndex);
Object columnIdentifier = column.getIdentifier();
if (columnIdentifier instanceof HomePieceOfFurniture.SortableProperty) {
switch ((HomePieceOfFurniture.SortableProperty)columnIdentifier) {
case CATALOG_ID :
// Copy piece catalog id
String catalogId = copiedPiece.getCatalogId();
csv.append(catalogId != null ? catalogId : "");
break;
case NAME :
// Copy piece name
csv.append(copiedPiece.getName());
break;
case COLOR :
if (copiedPiece.getColor() != null) {
// Copy piece color at #xxxxxx format
csv.append("#" + Integer.toHexString(copiedPiece.getColor()).substring(2));
}
break;
case TEXTURE :
if (copiedPiece.getTexture() != null) {
csv.append(copiedPiece.getTexture().getName());
}
case WIDTH :
case DEPTH :
case HEIGHT :
case X :
case Y :
case ELEVATION :
case ANGLE :
case PRICE :
case VALUE_ADDED_TAX_PERCENTAGE :
case VALUE_ADDED_TAX :
case PRICE_VALUE_ADDED_TAX_INCLUDED :
// Copy numbers as they are displayed by their renderer
csv.append(((JLabel)column.getCellRenderer().getTableCellRendererComponent(
this, copiedPiece, false, false, rowIndex, columnIndex)).getText());
break;
case MOVABLE :
// Copy boolean as true or false
csv.append(copiedPiece.isMovable());
break;
case DOOR_OR_WINDOW :
csv.append(copiedPiece.isDoorOrWindow());
break;
case VISIBLE :
csv.append(copiedPiece.isVisible());
break;
}
} else {
Component rendererComponent = column.getCellRenderer().getTableCellRendererComponent(
this, copiedPiece, false, false, rowIndex, columnIndex);
if (rendererComponent instanceof JLabel) {
csv.append(((JLabel)rendererComponent).getText());
} else {
csv.append(model.getValueAt(rowIndex, columnIndex));
}
}
}
csv.append(lineSeparator);
}