admin tools improves (#5388):

* added game ids and created time to tables list;
* added popup hints support to tables list;
* fixed wrong sorting and columns resizing in tables list;
* refactored some modules to share table related code between client and admin console;
This commit is contained in:
Oleg Agafonov 2024-03-22 16:48:34 +04:00
parent 50c75f05bd
commit fef37cdc73
14 changed files with 170 additions and 84 deletions

View file

@ -0,0 +1,41 @@
package mage.components.table;
import org.ocpsoft.prettytime.PrettyTime;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.util.Date;
import java.util.Locale;
/**
* GUI: create time ago cell renderer for date values in the table's cell
* <p>
* Usage example:
* tableTables.getColumnModel().getColumn(TablesTableModel.COLUMN_CREATED).setCellRenderer(TimeAgoTableCellRenderer.getInstance());
*
* @author JayDi85
*/
public class TimeAgoTableCellRenderer extends DefaultTableCellRenderer {
static final PrettyTime timeFormatter;
static {
timeFormatter = new PrettyTime(Locale.ENGLISH);
MageTable.fixTimeFormatter(timeFormatter);
}
private static final TimeAgoTableCellRenderer instance = new TimeAgoTableCellRenderer();
public static TimeAgoTableCellRenderer getInstance() {
return instance;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Date d = (Date) value;
label.setText(timeFormatter.format(d));
return label;
}
}