Search in sources :

Example 1 with UserCellEditor

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);
}
Also used : GenericEnumModel(ultimate.karomuskel.ui.components.GenericEnumModel) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) Label(ultimate.karomuskel.ui.Language.Label) JLabel(javax.swing.JLabel) MouseAdapter(java.awt.event.MouseAdapter) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) TableColumn(javax.swing.table.TableColumn) UserCellEditor(ultimate.karomuskel.ui.components.UserCellEditor) DefaultCellEditor(javax.swing.DefaultCellEditor) SpinnerNumberModel(javax.swing.SpinnerNumberModel) EnumGameDirection(ultimate.karoapi4j.enums.EnumGameDirection) EnumGameTC(ultimate.karoapi4j.enums.EnumGameTC) PlannedGame(ultimate.karoapi4j.model.official.PlannedGame) SpinnerCellEditor(ultimate.karomuskel.ui.components.SpinnerCellEditor) Map(ultimate.karoapi4j.model.official.Map)

Aggregations

MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 TableColumn (javax.swing.table.TableColumn)1 EnumGameDirection (ultimate.karoapi4j.enums.EnumGameDirection)1 EnumGameTC (ultimate.karoapi4j.enums.EnumGameTC)1 Map (ultimate.karoapi4j.model.official.Map)1 PlannedGame (ultimate.karoapi4j.model.official.PlannedGame)1 Label (ultimate.karomuskel.ui.Language.Label)1 GenericEnumModel (ultimate.karomuskel.ui.components.GenericEnumModel)1 SpinnerCellEditor (ultimate.karomuskel.ui.components.SpinnerCellEditor)1 UserCellEditor (ultimate.karomuskel.ui.components.UserCellEditor)1