use of ultimate.karomuskel.ui.components.UserCellEditor in project KaroToolsCollection by ultimate.
the class SummaryScreen method initTable.
private void initTable(final JTable table) {
table.setRowHeight(20);
TableColumn col;
for (int i = 0; i < table.getColumnCount(); i++) {
col = table.getColumnModel().getColumn(i);
col.setPreferredWidth(this.model.getColumnWidth(i));
if (table.getColumnClass(i).equals(Integer.class)) {
col.setCellEditor(new SpinnerCellEditor(new SpinnerNumberModel(2, 0, Integer.MAX_VALUE, 1)));
} else if (table.getColumnClass(i).equals(EnumGameTC.class)) {
col.setCellEditor(new DefaultCellEditor(new JComboBox<Label<EnumGameTC>>(new GenericEnumModel<EnumGameTC>(EnumGameTC.class, EnumGameTC.free, false))));
} else if (table.getColumnClass(i).equals(EnumGameDirection.class)) {
col.setCellEditor(new DefaultCellEditor(new JComboBox<Label<EnumGameDirection>>(new GenericEnumModel<EnumGameDirection>(EnumGameDirection.class, EnumGameDirection.free, false))));
} else if (table.getColumnClass(i).equals(Map.class)) {
Map[] maps = karoAPICache.getMaps().toArray(new Map[0]);
col.setCellEditor(new DefaultCellEditor(new JComboBox<Map>(new DefaultComboBoxModel<Map>(maps))));
} else if (table.getColumnClass(i).equals(User.class)) {
UserCellEditor editor = new UserCellEditor(this.gui, this.model, karoAPICache);
col.setCellEditor(editor);
col.setCellRenderer(editor);
}
}
// Batch-Update-Support
table.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int col = table.columnAtPoint(e.getPoint());
if (// Title
col == 0)
batchUpdateString(col, Language.getString("screen.summary.table.name"), Language.getString("screen.summary.batchUpdate.note.name"));
else if (// Map
col == 1)
batchUpdateSelection(col, Language.getString("screen.summary.table.map"), new DefaultComboBoxModel<Map>(karoAPICache.getMaps().toArray(new Map[0])));
else if (// Players
col == 2)
batchUpdatePlayers(col, Language.getString("screen.summary.table.players"));
else if (// ZZZ
col == 3)
batchUpdateInt(col, Language.getString("screen.summary.table.zzz"), new SpinnerNumberModel(2, 0, Integer.MAX_VALUE, 1));
else if (// TC
col == 4)
batchUpdateSelection(col, Language.getString("screen.summary.table.crashs"), new GenericEnumModel<EnumGameTC>(EnumGameTC.class, EnumGameTC.free, false));
else if (// CPs
col == 5)
batchUpdateBoolean(col, Language.getString("screen.summary.table.cps"));
else if (// Direction
col == 6)
batchUpdateSelection(col, Language.getString("screen.summary.table.direction"), new GenericEnumModel<EnumGameDirection>(EnumGameDirection.class, EnumGameDirection.free, false));
else if (// Create
col == 7)
batchUpdateBoolean(col, Language.getString("screen.summary.table.createstatus"));
else if (// Leave
col == 8)
batchUpdateBoolean(col, Language.getString("screen.summary.table.leavestatus"));
}
});
if (this.gameSeries.getGames().get(this.key) != null)
for (PlannedGame game : this.gameSeries.getGames().get(this.key)) this.model.addRow(game);
}
Aggregations