| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.homeunix.thecave.buddi.view.swing; |
| 5 | |
|
| 6 | |
import java.awt.Component; |
| 7 | |
|
| 8 | |
import javax.swing.JTable; |
| 9 | |
import javax.swing.table.DefaultTableCellRenderer; |
| 10 | |
|
| 11 | |
import org.homeunix.thecave.buddi.plugin.api.util.TextFormatter; |
| 12 | |
|
| 13 | 0 | public class DecimalCellRenderer extends DefaultTableCellRenderer { |
| 14 | |
public static final long serialVersionUID = 0; |
| 15 | |
|
| 16 | |
@Override |
| 17 | |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
| 18 | 0 | super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
| 19 | |
|
| 20 | 0 | if (value instanceof Long) |
| 21 | 0 | this.setText(TextFormatter.getHtmlWrapper(TextFormatter.getFormattedCurrency((Long) value))); |
| 22 | |
else |
| 23 | 0 | this.setText(TextFormatter.getFormattedCurrency(0)); |
| 24 | |
|
| 25 | 0 | if (hasFocus && isSelected) { |
| 26 | 0 | table.editCellAt(row,column); |
| 27 | 0 | table.getCellEditor(row, column).getTableCellEditorComponent(table, value, isSelected, row, column).requestFocus(); |
| 28 | |
} |
| 29 | |
|
| 30 | 0 | return this; |
| 31 | |
} |
| 32 | |
} |