use of delta.common.ui.swing.tables.CellDataProvider in project lotro-companion by dmorcellet.
the class ItemChoiceTableController method buildStatColumn.
private TableColumnController<Item, FixedDecimalsInteger> buildStatColumn(final STAT stat) {
CellDataProvider<Item, FixedDecimalsInteger> statCell = new CellDataProvider<Item, FixedDecimalsInteger>() {
@Override
public FixedDecimalsInteger getData(Item item) {
BasicStatsSet stats = item.getStats();
FixedDecimalsInteger value = stats.getStat(stat);
return value;
}
};
TableColumnController<Item, FixedDecimalsInteger> statColumn = new TableColumnController<Item, FixedDecimalsInteger>(stat.name(), stat.getName(), FixedDecimalsInteger.class, statCell);
statColumn.setWidthSpecs(55, 55, 50);
return statColumn;
}
use of delta.common.ui.swing.tables.CellDataProvider in project lotro-companion by dmorcellet.
the class CharacterLogTableController method buildTable.
private GenericTableController<CharacterLogItem> buildTable() {
DataProvider<CharacterLogItem> provider = new DataProvider<CharacterLogItem>() {
@Override
public CharacterLogItem getAt(int index) {
return _log.getLogItem(index);
}
@Override
public int getCount() {
return _log.getNbItems();
}
};
GenericTableController<CharacterLogItem> table = new GenericTableController<CharacterLogItem>(provider);
// Date column
{
CellDataProvider<CharacterLogItem, Date> dateCell = new CellDataProvider<CharacterLogItem, Date>() {
@Override
public Date getData(CharacterLogItem item) {
long timestamp = item.getDate();
return new Date(timestamp);
}
};
TableColumnController<CharacterLogItem, Date> dateColumn = new TableColumnController<CharacterLogItem, Date>("Date", Date.class, dateCell);
dateColumn.setWidthSpecs(100, 100, 50);
dateColumn.setCellRenderer(new DateRenderer(Formats.DATE_PATTERN));
table.addColumnController(dateColumn);
}
// Type column
{
CellDataProvider<CharacterLogItem, LogItemType> typeCell = new CellDataProvider<CharacterLogItem, LogItemType>() {
@Override
public LogItemType getData(CharacterLogItem item) {
return item.getLogItemType();
}
};
TableColumnController<CharacterLogItem, LogItemType> typeColumn = new TableColumnController<CharacterLogItem, LogItemType>("Type", LogItemType.class, typeCell);
typeColumn.setWidthSpecs(100, 100, 50);
typeColumn.setCellRenderer(new LogItemTypeRenderer());
typeColumn.setUseToString(Boolean.TRUE);
table.addColumnController(typeColumn);
}
// Label column
{
CellDataProvider<CharacterLogItem, String> labelCell = new CellDataProvider<CharacterLogItem, String>() {
@Override
public String getData(CharacterLogItem item) {
return item.getLabel();
}
};
TableColumnController<CharacterLogItem, String> labelColumn = new TableColumnController<CharacterLogItem, String>("Label", String.class, labelCell);
labelColumn.setWidthSpecs(150, -1, 150);
table.addColumnController(labelColumn);
}
return table;
}
use of delta.common.ui.swing.tables.CellDataProvider in project lotro-companion by dmorcellet.
the class WarbandsTableController method buildCharacterColumn.
private TableColumnController<WarbandDefinition, WarbandStats> buildCharacterColumn(CharacterFile character) {
final WarbandsStats warbandsStats = loadToonStats(character);
CellDataProvider<WarbandDefinition, WarbandStats> cell = new CellDataProvider<WarbandDefinition, WarbandStats>() {
@Override
public WarbandStats getData(WarbandDefinition item) {
return warbandsStats.getWarbandStats(item, true);
}
};
String id = character.getIdentifier();
TableColumnController<WarbandDefinition, WarbandStats> column = new TableColumnController<WarbandDefinition, WarbandStats>(id, "Stats", WarbandStats.class, cell);
// Cell renderer
TableCellRenderer renderer = buildStatCellRenderer(warbandsStats);
column.setCellRenderer(renderer);
// Header renderer
JPanel headerPanel = buildToonHeaderPanel(character);
TableCellRenderer headerRenderer = buildSimpleCellRenderer(headerPanel);
column.setHeaderCellRenderer(headerRenderer);
int minWidth = headerPanel.getPreferredSize().width;
column.setMinWidth(minWidth);
column.setPreferredWidth(minWidth);
// Comparator
Comparator<WarbandStats> statsComparator = new Comparator<WarbandStats>() {
@Override
public int compare(WarbandStats w1, WarbandStats w2) {
Long d1 = w1.getMostRecentDate();
Long d2 = w2.getMostRecentDate();
if (d1 == null) {
if (d2 == null)
return 0;
return -1;
}
if (d2 == null)
return 1;
return d1.compareTo(d2);
}
};
column.setComparator(statsComparator);
return column;
}
use of delta.common.ui.swing.tables.CellDataProvider in project lotro-companion by dmorcellet.
the class CraftingSynopsisTableController method buildProfessionColumn.
private TableColumnController<CraftingSynopsisItem, Profession> buildProfessionColumn() {
CellDataProvider<CraftingSynopsisItem, Profession> professionCell = new CellDataProvider<CraftingSynopsisItem, Profession>() {
@Override
public Profession getData(CraftingSynopsisItem item) {
return item.getProfession();
}
};
TableColumnController<CraftingSynopsisItem, Profession> professionColumn = new TableColumnController<CraftingSynopsisItem, Profession>("Profession", Profession.class, professionCell);
professionColumn.setWidthSpecs(50, 50, 50);
// Header renderer
JPanel emptyHeaderPanel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
TableCellRenderer headerRenderer = buildSimpleCellRenderer(emptyHeaderPanel);
professionColumn.setHeaderCellRenderer(headerRenderer);
// Cell renderer
TableCellRenderer cellRenderer = buildProfessionCellRenderer();
professionColumn.setCellRenderer(cellRenderer);
// Comparator
ProfessionComparator comparator = new ProfessionComparator();
professionColumn.setComparator(comparator);
return professionColumn;
}
use of delta.common.ui.swing.tables.CellDataProvider in project lotro-companion by dmorcellet.
the class CraftingSynopsisTableController method buildGuildColumn.
private TableColumnController<CraftingSynopsisItem, FactionStatus> buildGuildColumn() {
CellDataProvider<CraftingSynopsisItem, FactionStatus> cell = new CellDataProvider<CraftingSynopsisItem, FactionStatus>() {
@Override
public FactionStatus getData(CraftingSynopsisItem item) {
return item.getGuildFaction();
}
};
String columnName = "Guild";
String id = columnName;
TableColumnController<CraftingSynopsisItem, FactionStatus> column = new TableColumnController<CraftingSynopsisItem, FactionStatus>(id, columnName, FactionStatus.class, cell);
// Header cell renderer
JPanel panel = buildGuildPanel();
TableCellRenderer headerRenderer = buildSimpleCellRenderer(panel);
column.setHeaderCellRenderer(headerRenderer);
// Cell renderer
TableCellRenderer renderer = ReputationSynopsisTableController.buildFactionStatusCellRenderer();
column.setCellRenderer(renderer);
// Init widths
column.setMinWidth(150);
column.setPreferredWidth(200);
column.setMaxWidth(300);
// Comparator
final FactionLevelComparator factionLevelComparator = new FactionLevelComparator();
Comparator<FactionStatus> statsComparator = new Comparator<FactionStatus>() {
@Override
public int compare(FactionStatus data1, FactionStatus data2) {
return factionLevelComparator.compare(data1.getFactionLevel(), data2.getFactionLevel());
}
};
column.setComparator(statsComparator);
return column;
}
Aggregations