From f5532dc74c1f20018059365e15e414270c902070 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Fri, 2 Jan 2026 17:06:33 +0100 Subject: [PATCH 01/31] #2379 Enable focus in FixedColumnsTable.kt --- src/main/java/core/gui/comp/table/FixedColumnsTable.kt | 5 +++-- .../java/module/playerOverview/PlayerOverviewPanel.java | 1 + .../java/module/playerOverview/PlayerOverviewTable.kt | 9 +++++---- src/main/java/module/youth/YouthPlayerView.java | 6 ++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/core/gui/comp/table/FixedColumnsTable.kt b/src/main/java/core/gui/comp/table/FixedColumnsTable.kt index bbab6017f..79dd1afa3 100644 --- a/src/main/java/core/gui/comp/table/FixedColumnsTable.kt +++ b/src/main/java/core/gui/comp/table/FixedColumnsTable.kt @@ -79,10 +79,11 @@ open class FixedColumnsTable @JvmOverloads constructor( if (fixedColumnsCount > 0) { fixed = JTable(model) - fixed!!.setFocusable(false) - fixed!!.setSelectionModel(getSelectionModel()) + fixed!!.setFocusable(true) fixed!!.getTableHeader().reorderingAllowed = false fixed!!.setSelectionModel(getSelectionModel()) + fixed!!.columnModel.selectionModel = getSelectionModel() + // Remove the non-fixed columns from the fixed table while (fixed!!.getColumnCount() > fixedColumnsCount) { val _columnModel = fixed!!.getColumnModel() diff --git a/src/main/java/module/playerOverview/PlayerOverviewPanel.java b/src/main/java/module/playerOverview/PlayerOverviewPanel.java index 1b680cdaa..60557a7a8 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playerOverview/PlayerOverviewPanel.java @@ -165,6 +165,7 @@ private Component initPlayersTable() { private boolean areSelecting = false; + /** * Adds ListSelectionListener which keep the row selection of the table with * the players name and the table with the players details in sync. diff --git a/src/main/java/module/playerOverview/PlayerOverviewTable.kt b/src/main/java/module/playerOverview/PlayerOverviewTable.kt index e37a0f88a..c40764028 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewTable.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTable.kt @@ -38,6 +38,11 @@ class PlayerOverviewTable : FixedColumnsTable(UserColumnController.instance().pl init { playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) isOpaque = false + if ( playerTableModel.players != null) { + if ( playerTableModel.players!!.size > 0){ + setRowSelectionInterval(0,0) + } + } RefreshManager.instance().registerRefreshable(this) // Add a mouse listener that, when clicking on the “Last match” column @@ -112,8 +117,4 @@ class PlayerOverviewTable : FixedColumnsTable(UserColumnController.instance().pl playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) } - companion object { - @Serial - private val serialVersionUID = -6074136156090331418L - } } diff --git a/src/main/java/module/youth/YouthPlayerView.java b/src/main/java/module/youth/YouthPlayerView.java index 98601dd10..931f0ef01 100644 --- a/src/main/java/module/youth/YouthPlayerView.java +++ b/src/main/java/module/youth/YouthPlayerView.java @@ -155,7 +155,9 @@ private void refreshPlayerOverview() { isRefreshingPlayerOverview = true; var selection = this.playerOverviewTable.getSelectedModelIndex(); playerOverviewTableModel.initData(); - this.playerOverviewTable.selectModelIndex(selection); + SwingUtilities.invokeLater(() -> { + this.playerOverviewTable.selectModelIndex(selection); + }); } finally { isRefreshingPlayerOverview=false; @@ -312,7 +314,7 @@ private void initSelection(int row) { @Override public void valueChanged(ListSelectionEvent e) { - if ( !e.getValueIsAdjusting() && !isSelectionInitialized) { + if (!isSelectionInitialized) { refreshPlayerDetails(); } } From 2debcca8ae268357e3845afb3556f6a77bcd6af9 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 3 Jan 2026 14:06:25 +0100 Subject: [PATCH 02/31] #2379 PlayerOverview uses PlayersTable --- src/main/java/core/gui/HOMainFrame.java | 16 +- .../core/gui/comp/table/FixedColumnsTable.kt | 7 +- .../core/gui/model/UserColumnController.java | 1 + src/main/java/module/lineup/LineupPanel.java | 2 +- .../module/lineup/LineupPlayersTable.java | 6 +- .../lineup/lineup/PlayerPositionPanel.java | 7 +- .../playerOverview/PlayerDetailsPanel.java | 13 +- .../playerOverview/PlayerOverviewPanel.java | 101 ++++---- .../playerOverview/PlayerOverviewTable.kt | 240 +++++++++--------- .../PlayerOverviewTableModel.kt | 58 ++--- .../playerOverview/RemoveGruppenPanel.java | 4 +- .../RemoveGruppenPanelTest.java | 2 +- 12 files changed, 232 insertions(+), 225 deletions(-) rename src/main/java/{core/gui/model => module/playerOverview}/PlayerOverviewTableModel.kt (89%) diff --git a/src/main/java/core/gui/HOMainFrame.java b/src/main/java/core/gui/HOMainFrame.java index 5dab06de6..a46837b40 100644 --- a/src/main/java/core/gui/HOMainFrame.java +++ b/src/main/java/core/gui/HOMainFrame.java @@ -190,14 +190,14 @@ public static boolean isHOMainFrame_initialized() { return m_HOMainFrame_initialized; } - public void selectPlayer(Player player) { - if (m_selectedPlayer != player) { - m_selectedPlayer = player; - var lineupPanel = getLineupPanel(); - if (lineupPanel != null) lineupPanel.setPlayer(player.getPlayerId()); - getSpielerUebersichtPanel().setPlayer(player); - } - } +// public void selectPlayer(Player player) { +// if (m_selectedPlayer != player) { +// m_selectedPlayer = player; +// var lineupPanel = getLineupPanel(); +// if (lineupPanel != null) lineupPanel.setPlayer(player.getPlayerId()); +// getSpielerUebersichtPanel().setPlayer(player); +// } +// } public LineupPanel getLineupPanel() { Container c = getTabbedPane().getModulePanel(IModule.LINEUP); diff --git a/src/main/java/core/gui/comp/table/FixedColumnsTable.kt b/src/main/java/core/gui/comp/table/FixedColumnsTable.kt index 79dd1afa3..aaf648211 100644 --- a/src/main/java/core/gui/comp/table/FixedColumnsTable.kt +++ b/src/main/java/core/gui/comp/table/FixedColumnsTable.kt @@ -85,7 +85,7 @@ open class FixedColumnsTable @JvmOverloads constructor( fixed!!.columnModel.selectionModel = getSelectionModel() // Remove the non-fixed columns from the fixed table - while (fixed!!.getColumnCount() > fixedColumnsCount) { + while (fixed!!.columnCount > fixedColumnsCount) { val _columnModel = fixed!!.getColumnModel() _columnModel.removeColumn(_columnModel.getColumn(fixedColumnsCount)) } @@ -174,7 +174,6 @@ open class FixedColumnsTable @JvmOverloads constructor( } } - /** * Show the horizontal scroll bar of the scroll pane when the other horizontal scroll bar appeared in case of pane resizing * @param scrollPane The scroll pane that has to be synchronized with the other scroll pane @@ -190,8 +189,8 @@ open class FixedColumnsTable @JvmOverloads constructor( /** * Hide the horizontal scroll bar of the scroll pane when the other horizontal scroll bar disappeared in case of pane resizing - * If the other scroll bar does not require a scroll bar, its scroll bar will be removed - * otherwise the disappearance in hidden scroll bar will be reset. + * If the other scroll bar does not require a scroll bar, its scroll bar will be removed, + * otherwise the disappearance in hidden scroll bar will reset. * @param hiddenScrollPane The scroll pane that removed the scroll bar * @param otherScrollPane The scroll pane that has to be adapted */ diff --git a/src/main/java/core/gui/model/UserColumnController.java b/src/main/java/core/gui/model/UserColumnController.java index 287cbbd85..b6545f118 100644 --- a/src/main/java/core/gui/model/UserColumnController.java +++ b/src/main/java/core/gui/model/UserColumnController.java @@ -4,6 +4,7 @@ import core.gui.comp.table.HOTableModel; import module.hallOfFame.HallOfFameTableModel; import module.matches.statistics.MatchesOverviewColumnModel; +import module.playerOverview.PlayerOverviewTableModel; import module.specialEvents.SpecialEventsTableModel; import module.teamAnalyzer.ui.RecapPanelTableModel; import module.training.ui.TrainingProgressTableModel; diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index 8a392f807..814a8ba78 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -149,7 +149,7 @@ private Component initSpielerTabelle() { lineupPlayersTable.setPlayer(player.getPlayerId()); } } else { - HOMainFrame.instance().selectPlayer(player); +// HOMainFrame.instance().selectPlayer(player); } areSelecting = false; } diff --git a/src/main/java/module/lineup/LineupPlayersTable.java b/src/main/java/module/lineup/LineupPlayersTable.java index b3de78416..b4f7ae4b9 100644 --- a/src/main/java/module/lineup/LineupPlayersTable.java +++ b/src/main/java/module/lineup/LineupPlayersTable.java @@ -6,7 +6,7 @@ import core.gui.comp.renderer.BooleanTableCellRenderer; import core.gui.comp.renderer.HODefaultTableCellRenderer; import core.gui.comp.table.FixedColumnsTable; -import core.gui.model.PlayerOverviewTableModel; +import module.playerOverview.PlayerOverviewTableModel; import core.gui.model.UserColumnController; import core.gui.model.UserColumnFactory; import core.model.HOVerwaltung; @@ -30,7 +30,7 @@ public final class LineupPlayersTable extends FixedColumnsTable implements core. LineupPlayersTable() { super(UserColumnController.instance().getLineupModel()); tableModel = (PlayerOverviewTableModel) this.getModel(); - tableModel.setValues(HOVerwaltung.instance().getModel().getCurrentPlayers()); +// tableModel.setValues(HOVerwaltung.instance().getModel().getCurrentPlayers()); setDefaultRenderer(Object.class, new HODefaultTableCellRenderer()); setDefaultRenderer(Boolean.class, new BooleanTableCellRenderer()); RefreshManager.instance().registerRefreshable(this); @@ -71,7 +71,7 @@ public void saveColumnOrder() { } private void resetPlayers() { - tableModel.setValues(HOVerwaltung.instance().getModel().getCurrentPlayers()); + tableModel.setPlayers(HOVerwaltung.instance().getModel().getCurrentPlayers()); } private void initListeners() { diff --git a/src/main/java/module/lineup/lineup/PlayerPositionPanel.java b/src/main/java/module/lineup/lineup/PlayerPositionPanel.java index e8ad5b842..824643d53 100644 --- a/src/main/java/module/lineup/lineup/PlayerPositionPanel.java +++ b/src/main/java/module/lineup/lineup/PlayerPositionPanel.java @@ -4,6 +4,7 @@ import core.gui.HOMainFrame; import core.gui.Updatable; import core.gui.comp.panel.ImagePanel; +import core.gui.comp.table.PlayersTable; import core.gui.model.PlayerCBItem; import core.gui.model.PlayerCBItemRenderer; import core.gui.theme.HOColorName; @@ -104,7 +105,8 @@ private byte getTactic() { @Override public void focusGained(FocusEvent event) { if (getSelectedPlayer() != null) { - HOMainFrame.instance().selectPlayer(getSelectedPlayer()); + PlayersTable.Companion.setSelectedPlayer(getSelectedPlayer()); +// HOMainFrame.instance().selectPlayer(getSelectedPlayer()); } } @@ -203,7 +205,8 @@ else if (m_iPositionID == IMatchRoleID.captain) { } if (player != null) { - HOMainFrame.instance().selectPlayer(player); + PlayersTable.Companion.setSelectedPlayer(player); +// HOMainFrame.instance().selectPlayer(player); } //Update all other positions diff --git a/src/main/java/module/playerOverview/PlayerDetailsPanel.java b/src/main/java/module/playerOverview/PlayerDetailsPanel.java index ba77c3cd4..afe148b5f 100644 --- a/src/main/java/module/playerOverview/PlayerDetailsPanel.java +++ b/src/main/java/module/playerOverview/PlayerDetailsPanel.java @@ -59,7 +59,7 @@ public final class PlayerDetailsPanel extends ImagePanel implements Refreshable, private final Color URL = ThemeManager.getColor(HOColorName.URL_PANEL_BG); private final Color FGcolor = ColorLabelEntry.FG_STANDARD; private final Color BORDER_COLOR = ThemeManager.getColor(HOColorName.PLAYER_DETAILS_BAR_BORDER_COLOR); - private final PlayerOverviewTable m_playerOverviewTable; +// private final PlayerOverviewTable m_playerOverviewTable; private final JLabel jlName = new JLabel(""); private final JLabel m_jlPlayerDescription = new JLabel(""); private final JPanel jpPlayerGeneral = new JPanel(); @@ -103,8 +103,7 @@ public final class PlayerDetailsPanel extends ImagePanel implements Refreshable, /** * Constructor */ - PlayerDetailsPanel(PlayerOverviewTable playerOverviewTable) { - m_playerOverviewTable = playerOverviewTable; + PlayerDetailsPanel() { initComponents(); RefreshManager.instance().registerRefreshable(this); } @@ -118,10 +117,10 @@ public void setPlayer(Player player) { player = HOMainFrame.instance().getSelectedPlayer(); } } - if ( player == null) { - // at initialisation select first player to ensure clean display ===== - player = m_playerOverviewTable.getPlayerTableModel().getPlayerAtRow(0); - } +// if ( player == null) { +// // at initialisation select first player to ensure clean display ===== +// player = m_playerOverviewTable.getPlayerTableModel().getPlayerAtRow(0); +// } m_clPlayer = player; if (m_clPlayer != null) { diff --git a/src/main/java/module/playerOverview/PlayerOverviewPanel.java b/src/main/java/module/playerOverview/PlayerOverviewPanel.java index 60557a7a8..fd3162032 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playerOverview/PlayerOverviewPanel.java @@ -2,10 +2,11 @@ import core.gui.HOMainFrame; import core.gui.comp.panel.ImagePanel; +import core.gui.comp.table.PlayersTable; +import core.gui.model.UserColumnController; import core.model.HOVerwaltung; import core.model.TranslationFacility; import core.model.UserParameter; -import core.model.player.Player; import javax.swing.*; import java.awt.*; @@ -20,27 +21,27 @@ public class PlayerOverviewPanel extends ImagePanel { private JSplitPane verticalSplitPane; private PlayerDetailsPanel playerDetailsPanel; private SpielerTrainingsSimulatorPanel spielerTrainingsSimulatorPanel; - private PlayerOverviewTable playerOverviewTable; + private PlayersTable playerOverviewTable; private TeamSummaryPanel teamSummaryPanel; /** - * Creates a new SpielerUebersichtsPanel object. (Players view panel) + * Creates a new player overview. (Players view panel) */ public PlayerOverviewPanel() { initComponents(); - addTableSelectionListeners(); + this.playerOverviewTable.addListSelectionListener(e -> selectPlayer()); + this.playerOverviewTable.setRowSelectionInterval(0, 0); } /** - * Selects the player with the given id. - * - * @param player - * the id of the player to select. + * Selects the player */ - public void setPlayer(Player player) { - playerOverviewTable.selectPlayer(player.getPlayerId()); - playerDetailsPanel.setPlayer(player); - spielerTrainingsSimulatorPanel.setSpieler(player); + public void selectPlayer() { + var players = this.playerOverviewTable.getSelectedPlayers(); + for (var player : players ) { + playerDetailsPanel.setPlayer(player); + spielerTrainingsSimulatorPanel.setSpieler(player); + } } /** @@ -66,8 +67,9 @@ public final void refresh() { * Updates all the columns affected by a comparison. */ public final void refreshHRFComparison() { - playerOverviewTable.refreshHRFComparison(); - playerDetailsPanel.setPlayer(playerOverviewTable.getSelectedPlayer()); + var playerTableModel = (PlayerOverviewTableModel)playerOverviewTable.getModel(); + playerTableModel.reInitDataHRFComparison(); +// playerDetailsPanel.setPlayer(playerOverviewTable.getSelectedPlayer()); } /** @@ -100,11 +102,11 @@ private void initComponents() { } /* - * Initialise the players details + * Initialize the players details */ private Component initSpielerDetail() { JTabbedPane tabbedPane = new JTabbedPane(); - playerDetailsPanel = new PlayerDetailsPanel(playerOverviewTable); + playerDetailsPanel = new PlayerDetailsPanel(); JScrollPane scrollPane = new JScrollPane(playerDetailsPanel); scrollPane.getVerticalScrollBar().setBlockIncrement(100); @@ -121,7 +123,7 @@ private Component initSpielerDetail() { } /* - * Initialise the players history + * Initialize the players history */ private Component initSpielerHistory() { JPanel panel = new ImagePanel(); @@ -132,7 +134,7 @@ private Component initSpielerHistory() { scrollPane.getVerticalScrollBar().setBlockIncrement(100); scrollPane.getVerticalScrollBar().setUnitIncrement(20); panel.add(spielerTrainingsVergleichsPanel, BorderLayout.CENTER); - panel.add(new JScrollPane(new RemoveGruppenPanel(playerOverviewTable)), BorderLayout.NORTH); + panel.add(new JScrollPane(new RemoveGruppenPanel()), BorderLayout.NORTH); if (teamSummaryPanel != null) { spielerTrainingsVergleichsPanel.addChangeListener(teamSummaryPanel); @@ -149,7 +151,8 @@ private Component initPlayersTable() { overviewPanel.setLayout(new BorderLayout()); // table with the player's details - playerOverviewTable = new PlayerOverviewTable(); + var playerOverviewTableModel = UserColumnController.instance().getPlayerOverviewModel(); + playerOverviewTable = new PlayersTable(playerOverviewTableModel, 1); overviewPanel.add(playerOverviewTable.getContainerComponent(), BorderLayout.CENTER); TeamSummaryModel teamSummaryModel = new TeamSummaryModel(); teamSummaryModel.setPlayers(HOVerwaltung.instance().getModel().getCurrentPlayers()); @@ -160,37 +163,41 @@ private Component initPlayersTable() { scrollPane.setPreferredSize(new Dimension((int) teamSummaryPanel.getPreferredSize().getWidth(), (int) teamSummaryPanel.getPreferredSize().getHeight() + 22)); overviewPanel.add(scrollPane, BorderLayout.SOUTH); + + playerOverviewTableModel.initData(); return overviewPanel; } - private boolean areSelecting = false; - - /** - * Adds ListSelectionListener which keep the row selection of the table with - * the players name and the table with the players details in sync. - */ - private void addTableSelectionListeners() { - playerOverviewTable.getSelectionModel().addListSelectionListener( - e -> { - if (!areSelecting) { - areSelecting = true; - var player = playerOverviewTable.getSelectedPlayer(); - if (player == null) { - player = HOMainFrame.instance().getSelectedPlayer(); - if ( player != null) { - playerOverviewTable.selectPlayer(player.getPlayerId()); - } - } else { - HOMainFrame.instance().selectPlayer(player); - } - areSelecting = false; - } - } - ); - } - - public void storeUserSettings() { - playerOverviewTable.getPlayerTableModel().storeUserSettings(); +// private boolean areSelecting = false; +// +// /** +// * Adds ListSelectionListener which keep the row selection of the table with +// * the players name and the table with the players details in sync. +// */ +// private void addTableSelectionListeners() { +// playerOverviewTable.getSelectionModel().addListSelectionListener( +// e -> { +// if (!areSelecting) { +// areSelecting = true; +// var player = playerOverviewTable.getSelectedPlayer(); +// if (player == null) { +// player = HOMainFrame.instance().getSelectedPlayer(); +// if ( player != null) { +// playerOverviewTable.selectPlayer(player.getPlayerId()); +// } +// } else { +// HOMainFrame.instance().selectPlayer(player); +// } +// areSelecting = false; +// } +// } +// ); +// } + + public void storeUserSettings() + { + var playerOverviewTableModel = (PlayerOverviewTableModel)playerOverviewTable.getModel(); + playerOverviewTableModel.storeUserSettings(); } } \ No newline at end of file diff --git a/src/main/java/module/playerOverview/PlayerOverviewTable.kt b/src/main/java/module/playerOverview/PlayerOverviewTable.kt index c40764028..3d71401f4 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewTable.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTable.kt @@ -1,120 +1,120 @@ -package module.playerOverview - -import core.db.DBManager -import core.gui.HOMainFrame -import core.gui.RefreshManager -import core.gui.Refreshable -import core.gui.comp.table.FixedColumnsTable -import core.gui.model.PlayerOverviewTableModel -import core.gui.model.UserColumnController -import core.model.HOVerwaltung -import core.model.TranslationFacility -import core.model.player.Player -import core.net.HattrickLink -import java.awt.event.MouseAdapter -import java.awt.event.MouseEvent -import java.io.Serial - -/** - * The Squad table, listing all the players on the team. - * - * - * The actual model for that table is defined in [PlayerOverviewTableModel], which defines - * all the columns to be displayed; the columns are initiated by a factory, [UserColumnFactory], - * which in particular sets their preferred width. - * - * - * Sorting in the table is handled by [TableSorter] which decorates the model, and is set - * as the [javax.swing.table.TableModel] for this table. Triggering sorting by a click sorts - * the entries in the table model itself. The new sorting order is then used by re-displaying the - * table. This approach differs from the “normal” Swing approach of using - * [JTable.setRowSorter]. - * - * @author Thorsten Dietz - */ -class PlayerOverviewTable : FixedColumnsTable(UserColumnController.instance().playerOverviewModel), Refreshable { - val playerTableModel: PlayerOverviewTableModel = this.model as PlayerOverviewTableModel - - init { - playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) - isOpaque = false - if ( playerTableModel.players != null) { - if ( playerTableModel.players!!.size > 0){ - setRowSelectionInterval(0,0) - } - } - RefreshManager.instance().registerRefreshable(this) - - // Add a mouse listener that, when clicking on the “Last match” column - // - opens the Hattrick page for the player if you shift-click, - // - or opens the match in HO if you double-click. - addMouseListener(object : MouseAdapter() { - override fun mouseReleased(e: MouseEvent) { - val player: Player? = selectedPlayer - if (player != null) { - // Last match column - val columnAtPoint = columnAtPoint(e.point) - // Get name of the actual column at columnAtPoint, i.e. post-ordering of the columns - // based on preferences. - val columnName = playerTableModel.getColumnName(columnAtPoint) - val lastMatchRating = TranslationFacility.tr("LastMatchRating") - if (columnName != null && columnName.equals(lastMatchRating, ignoreCase = true)) { - if (e.isShiftDown) { - val matchId = player.lastMatchId - val matchType = player.lastMatchType - val info = DBManager.instance().getMatchesKurzInfoByMatchID(matchId, matchType) - HattrickLink.showMatch(matchId.toString(), info.matchType.isOfficial) - } else if (e.clickCount == 2) { - HOMainFrame.instance().showMatch(player.lastMatchId) - } - } - } - } - }) - } - - val selectedPlayer: Player? - get() { - val rowIndex = selectedRow - if (rowIndex >= 0) { - return playerTableModel.players!![convertRowIndexToModel(rowIndex)] - } - return null - } - - fun selectPlayer(playerId: Int) { - playerTableModel.selectPlayer(playerId) - } - - override fun reInit() { - val player = selectedPlayer - resetPlayers() - repaint() - if (player != null) { - selectPlayer(player.playerId) - } - } - - fun reInitModel() { - playerTableModel.reInitData() - } - - fun reInitModelHRFComparison() { - playerTableModel.reInitDataHRFComparison() - } - - override fun refresh() { - reInitModel() - repaint() - } - - fun refreshHRFComparison() { - reInitModelHRFComparison() - repaint() - } - - private fun resetPlayers() { - playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) - } - -} +//package module.playerOverview +// +//import core.db.DBManager +//import core.gui.HOMainFrame +//import core.gui.RefreshManager +//import core.gui.Refreshable +//import core.gui.comp.table.FixedColumnsTable +//import module.playerOverview.PlayerOverviewTableModel +//import core.gui.model.UserColumnController +//import core.model.HOVerwaltung +//import core.model.TranslationFacility +//import core.model.player.Player +//import core.net.HattrickLink +//import java.awt.event.MouseAdapter +//import java.awt.event.MouseEvent +//import java.io.Serial +// +///** +// * The Squad table, listing all the players on the team. +// * +// * +// * The actual model for that table is defined in [PlayerOverviewTableModel], which defines +// * all the columns to be displayed; the columns are initiated by a factory, [UserColumnFactory], +// * which in particular sets their preferred width. +// * +// * +// * Sorting in the table is handled by [TableSorter] which decorates the model, and is set +// * as the [javax.swing.table.TableModel] for this table. Triggering sorting by a click sorts +// * the entries in the table model itself. The new sorting order is then used by re-displaying the +// * table. This approach differs from the “normal” Swing approach of using +// * [JTable.setRowSorter]. +// * +// * @author Thorsten Dietz +// */ +//class PlayerOverviewTable : FixedColumnsTable(UserColumnController.instance().playerOverviewModel), Refreshable { +// val playerTableModel: PlayerOverviewTableModel = this.model as PlayerOverviewTableModel +// +// init { +// playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) +// isOpaque = false +// if ( playerTableModel.players != null) { +// if ( playerTableModel.players!!.size > 0){ +// setRowSelectionInterval(0,0) +// } +// } +// RefreshManager.instance().registerRefreshable(this) +// +// // Add a mouse listener that, when clicking on the “Last match” column +// // - opens the Hattrick page for the player if you shift-click, +// // - or opens the match in HO if you double-click. +// addMouseListener(object : MouseAdapter() { +// override fun mouseReleased(e: MouseEvent) { +// val player: Player? = selectedPlayer +// if (player != null) { +// // Last match column +// val columnAtPoint = columnAtPoint(e.point) +// // Get name of the actual column at columnAtPoint, i.e. post-ordering of the columns +// // based on preferences. +// val columnName = playerTableModel.getColumnName(columnAtPoint) +// val lastMatchRating = TranslationFacility.tr("LastMatchRating") +// if (columnName != null && columnName.equals(lastMatchRating, ignoreCase = true)) { +// if (e.isShiftDown) { +// val matchId = player.lastMatchId +// val matchType = player.lastMatchType +// val info = DBManager.instance().getMatchesKurzInfoByMatchID(matchId, matchType) +// HattrickLink.showMatch(matchId.toString(), info.matchType.isOfficial) +// } else if (e.clickCount == 2) { +// HOMainFrame.instance().showMatch(player.lastMatchId) +// } +// } +// } +// } +// }) +// } +// +// val selectedPlayer: Player? +// get() { +// val rowIndex = selectedRow +// if (rowIndex >= 0) { +// return playerTableModel.players!![convertRowIndexToModel(rowIndex)] +// } +// return null +// } +// +// fun selectPlayer(playerId: Int) { +// playerTableModel.selectPlayer(playerId) +// } +// +// override fun reInit() { +// val player = selectedPlayer +// resetPlayers() +// repaint() +// if (player != null) { +// selectPlayer(player.playerId) +// } +// } +// +// fun reInitModel() { +// playerTableModel.reInitData() +// } +// +// fun reInitModelHRFComparison() { +// playerTableModel.reInitDataHRFComparison() +// } +// +// override fun refresh() { +// reInitModel() +// repaint() +// } +// +// fun refreshHRFComparison() { +// reInitModelHRFComparison() +// repaint() +// } +// +// private fun resetPlayers() { +// playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) +// } +// +//} diff --git a/src/main/java/core/gui/model/PlayerOverviewTableModel.kt b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt similarity index 89% rename from src/main/java/core/gui/model/PlayerOverviewTableModel.kt rename to src/main/java/module/playerOverview/PlayerOverviewTableModel.kt index fd967b4a5..cad6db70a 100644 --- a/src/main/java/core/gui/model/PlayerOverviewTableModel.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt @@ -1,13 +1,16 @@ -package core.gui.model +package module.playerOverview import core.db.DBManager import core.gui.comp.table.BooleanColumn -import core.gui.comp.table.HOTableModel +import core.gui.comp.table.HOPlayersTableModel import core.gui.comp.table.UserColumn -import core.gui.model.UserColumnController.ColumnModelId +import core.gui.model.PlayerColumn +import core.gui.model.PlayerPositionColumn +import core.gui.model.PlayerSkillColumn +import core.gui.model.UserColumnController +import core.gui.model.UserColumnFactory import core.model.player.Player import core.util.HODateTime -import module.playerOverview.SpielerTrainingsVergleichsPanel /** * Model used to display players in the Squad table. @@ -15,16 +18,13 @@ import module.playerOverview.SpielerTrainingsVergleichsPanel * @author Thorsten Dietz * @since 1.36 */ -class PlayerOverviewTableModel(id: ColumnModelId, name: String) : HOTableModel(id, name) { - /** all players */ - var players: List? = null - private set +class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: String) : HOPlayersTableModel(id, name) { /** * constructor * */ - internal constructor(id: ColumnModelId) : this(id, "Spieleruebersicht") + internal constructor(id: UserColumnController.ColumnModelId) : this(id, "Spieleruebersicht") init { val basic: Array? = UserColumnFactory.createPlayerBasicArray() @@ -127,18 +127,18 @@ class PlayerOverviewTableModel(id: ColumnModelId, name: String) : HOTableModel(i return null } - fun getPlayer(playerId: Int): Player? { - // Can be negative for temp player - if (playerId != 0) { - for (m_vPlayer in players!!) { - if (m_vPlayer.playerId == playerId) { - return m_vPlayer - } - } - } - - return null - } +// fun getPlayer(playerId: Int): Player? { +// // Can be negative for temp player +// if (playerId != 0) { +// for (m_vPlayer in players!!) { +// if (m_vPlayer.playerId == playerId) { +// return m_vPlayer +// } +// } +// } +// +// return null +// } fun getPlayerIndex(playerId: Int): Int { var i = 0 @@ -151,13 +151,13 @@ class PlayerOverviewTableModel(id: ColumnModelId, name: String) : HOTableModel(i return -1 } - /** - * Sets the new list of players. - */ - fun setValues(player: List?) { - players = player - initData() - } +// /** +// * Sets the new list of players. +// */ +// fun setValues(player: List?) { +// players = player +// initData() +// } /** * Resets the data for an HRF comparison. @@ -246,4 +246,4 @@ class PlayerOverviewTableModel(id: ColumnModelId, name: String) : HOTableModel(i } } } -} +} \ No newline at end of file diff --git a/src/main/java/module/playerOverview/RemoveGruppenPanel.java b/src/main/java/module/playerOverview/RemoveGruppenPanel.java index 8414b4824..a08b79bca 100644 --- a/src/main/java/module/playerOverview/RemoveGruppenPanel.java +++ b/src/main/java/module/playerOverview/RemoveGruppenPanel.java @@ -24,8 +24,6 @@ */ public class RemoveGruppenPanel extends ImagePanel implements ActionListener { - private static final long serialVersionUID = 3606384591123088694L; - //~ Instance fields ---------------------------------------------------------------------------- private final JButton doButton = new JButton(ImageUtilities.getSvgIcon(HOIconName.TURN)); private final JButton m_jbClean = new JButton(ImageUtilities.getSvgIcon(HOIconName.GROUP_TEAM_CLEAN, Map.of("fillColor", HOColorName.TABLEENTRY_DECLINE_FG))); @@ -80,7 +78,7 @@ public class RemoveGruppenPanel extends ImagePanel implements ActionListener { * Creates a new RemoveGruppenPanel object. * */ - public RemoveGruppenPanel(PlayerOverviewTable spielerTable) { + public RemoveGruppenPanel() { initComponents(); } diff --git a/src/test/java/module/playerOverview/RemoveGruppenPanelTest.java b/src/test/java/module/playerOverview/RemoveGruppenPanelTest.java index 4858b53e2..7449ac286 100644 --- a/src/test/java/module/playerOverview/RemoveGruppenPanelTest.java +++ b/src/test/java/module/playerOverview/RemoveGruppenPanelTest.java @@ -28,7 +28,7 @@ public static void main(String[] args) { JPanel content = new JPanel(); content.setLayout(new BorderLayout()); - RemoveGruppenPanel panel = new RemoveGruppenPanel(null); + RemoveGruppenPanel panel = new RemoveGruppenPanel(); content.add(panel, BorderLayout.CENTER); frame.setContentPane(content); From 25eeb5b34bcae0e2c6a1eaf59add7f2703470b61 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 3 Jan 2026 14:13:58 +0100 Subject: [PATCH 03/31] #2379 PlayerOverview uses PlayersTable --- src/main/java/core/gui/HOMainFrame.java | 14 +++-- .../java/core/gui/comp/table/PlayersTable.kt | 2 +- src/main/java/module/lineup/LineupPanel.java | 4 +- .../lineup/lineup/PlayerPositionPanel.java | 1 - .../PlayerOverviewTableModel.kt | 54 +++++++++---------- .../playerOverview/RemoveGruppenPanel.java | 7 +-- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/main/java/core/gui/HOMainFrame.java b/src/main/java/core/gui/HOMainFrame.java index a46837b40..f7974715c 100644 --- a/src/main/java/core/gui/HOMainFrame.java +++ b/src/main/java/core/gui/HOMainFrame.java @@ -14,7 +14,6 @@ import core.model.UserParameter; import core.model.match.Weather; import core.model.player.Player; -import core.module.DefaultModule; import core.module.IModule; import core.module.ModuleManager; import core.module.config.ModuleConfig; @@ -45,7 +44,6 @@ import java.util.*; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; /** * The Main HO window @@ -71,12 +69,12 @@ public final class HOMainFrame extends JFrame implements Refreshable { private final Color c_beta = new Color(162, 201, 255); private final Color c_dev = new Color(235, 170, 170); - // TODO: Move this to a model backing the main window - public Player getSelectedPlayer() { - return m_selectedPlayer; - } - - private Player m_selectedPlayer; +// // TODO: Move this to a model backing the main window +// public Player getSelectedPlayer() { +// return m_selectedPlayer; +// } +// +// private Player m_selectedPlayer; // ~ Constructors // ------------------------------------------------------------------------------- diff --git a/src/main/java/core/gui/comp/table/PlayersTable.kt b/src/main/java/core/gui/comp/table/PlayersTable.kt index d9ba86dfa..a155c6970 100644 --- a/src/main/java/core/gui/comp/table/PlayersTable.kt +++ b/src/main/java/core/gui/comp/table/PlayersTable.kt @@ -64,7 +64,7 @@ class PlayersTable @JvmOverloads constructor(tableModel: HOPlayersTableModel, fi } fun getSelectedPlayers() : List{ - var players = mutableListOf() + val players = mutableListOf() val allPLayers = getPlayers() for (viewRow in this.selectedRows){ players.add(allPLayers.get(this.convertRowIndexToModel(viewRow))) diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index 814a8ba78..da2b3a48e 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -2,6 +2,7 @@ import core.gui.HOMainFrame; import core.gui.Updatable; +import core.gui.comp.table.PlayersTable; import core.gui.theme.HOColorName; import core.gui.theme.ThemeManager; import core.model.UserParameter; @@ -144,7 +145,8 @@ private Component initSpielerTabelle() { areSelecting = true; var player = lineupPlayersTable.getPlayer(e.getFirstIndex()); if (player == null) { - player = HOMainFrame.instance().getSelectedPlayer(); +// player = HOMainFrame.instance().getSelectedPlayer(); + player = PlayersTable.Companion.getSelectedPlayer(); if (player != null) { lineupPlayersTable.setPlayer(player.getPlayerId()); } diff --git a/src/main/java/module/lineup/lineup/PlayerPositionPanel.java b/src/main/java/module/lineup/lineup/PlayerPositionPanel.java index 824643d53..e7ea064f5 100644 --- a/src/main/java/module/lineup/lineup/PlayerPositionPanel.java +++ b/src/main/java/module/lineup/lineup/PlayerPositionPanel.java @@ -1,7 +1,6 @@ package module.lineup.lineup; import core.datatype.CBItem; -import core.gui.HOMainFrame; import core.gui.Updatable; import core.gui.comp.panel.ImagePanel; import core.gui.comp.table.PlayersTable; diff --git a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt index cad6db70a..14d5b1fb3 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt @@ -105,7 +105,7 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str get() { val rowIndex = table!!.selectedRow if (rowIndex >= 0 && rowIndex < this.rowCount) { - return players!![table!!.convertRowIndexToModel(rowIndex)] + return players[table!!.convertRowIndexToModel(rowIndex)] } return null } @@ -118,10 +118,10 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str } fun getPlayerAtRow(tableRow: Int): Player? { - if (players != null && tableRow > -1 && tableRow < this.rowCount) { + if (tableRow > -1 && tableRow < this.rowCount) { val modelIndex = table!!.convertRowIndexToModel(tableRow) if (modelIndex > -1 && modelIndex < this.rowCount) { - return players!![modelIndex] + return players[modelIndex] } } return null @@ -142,7 +142,7 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str fun getPlayerIndex(playerId: Int): Int { var i = 0 - for (m_vPlayer in players!!) { + for (m_vPlayer in players) { if (m_vPlayer.playerId == playerId) { return i } @@ -210,10 +210,10 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str */ override fun initData() { val tmpDisplayedColumns = getDisplayedColumns() - m_clData = Array(players!!.size) { arrayOfNulls(tmpDisplayedColumns.size) } + m_clData = Array(players.size) { arrayOfNulls(tmpDisplayedColumns.size) } - for (i in players!!.indices) { - val currentPlayer = players!![i] + for (i in players.indices) { + val currentPlayer = players[i] val comparisonPlayer = getPreviousPlayerDevelopmentStage(currentPlayer) for (j in tmpDisplayedColumns.indices) { if (tmpDisplayedColumns[j] is PlayerColumn) { @@ -226,24 +226,24 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str fireTableDataChanged() } - /** - * Initializes the lineup only - */ - fun reInitData() { - val tmpDisplayedColumns = getDisplayedColumns() - for (i in players!!.indices) { - val currentPlayer = players!![i] - for (j in tmpDisplayedColumns.indices) { - if (tmpDisplayedColumns[j].id == UserColumnFactory.NAME || - tmpDisplayedColumns[j].id == UserColumnFactory.LINEUP || - tmpDisplayedColumns[j].id == UserColumnFactory.BEST_POSITION || - tmpDisplayedColumns[j].id == UserColumnFactory.SCHUM_RANK_BENCHMARK || - tmpDisplayedColumns[j].id == UserColumnFactory.GROUP) { - m_clData!![i][j] = (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, null) - } else if (tmpDisplayedColumns[j].id == UserColumnFactory.AUTO_LINEUP) { - m_clData!![i][j] = (tmpDisplayedColumns[j] as BooleanColumn).getValue(currentPlayer) - } - } - } - } +// /** +// * Initializes the lineup only +// */ +// fun reInitData() { +// val tmpDisplayedColumns = getDisplayedColumns() +// for (i in players!!.indices) { +// val currentPlayer = players!![i] +// for (j in tmpDisplayedColumns.indices) { +// if (tmpDisplayedColumns[j].id == UserColumnFactory.NAME || +// tmpDisplayedColumns[j].id == UserColumnFactory.LINEUP || +// tmpDisplayedColumns[j].id == UserColumnFactory.BEST_POSITION || +// tmpDisplayedColumns[j].id == UserColumnFactory.SCHUM_RANK_BENCHMARK || +// tmpDisplayedColumns[j].id == UserColumnFactory.GROUP) { +// m_clData!![i][j] = (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, null) +// } else if (tmpDisplayedColumns[j].id == UserColumnFactory.AUTO_LINEUP) { +// m_clData!![i][j] = (tmpDisplayedColumns[j] as BooleanColumn).getValue(currentPlayer) +// } +// } +// } +// } } \ No newline at end of file diff --git a/src/main/java/module/playerOverview/RemoveGruppenPanel.java b/src/main/java/module/playerOverview/RemoveGruppenPanel.java index a08b79bca..5008042dc 100644 --- a/src/main/java/module/playerOverview/RemoveGruppenPanel.java +++ b/src/main/java/module/playerOverview/RemoveGruppenPanel.java @@ -17,6 +17,7 @@ import java.awt.event.ActionListener; import java.util.List; import java.util.Map; +import java.util.Objects; /** @@ -159,14 +160,14 @@ private void groupsClear() { boolean update = false; for (Player player : allePlayer) { - if (!player.getTeamGroup().equals("")) { + if (!player.getTeamGroup().isEmpty()) { player.setTeamInfoSmilie(""); update = true; } } if (update) { - HOMainFrame.instance().getLineupPanel().update(); + Objects.requireNonNull(HOMainFrame.instance().getLineupPanel()).update(); } } @@ -185,7 +186,7 @@ private void gruppenMarkierung() { } } - core.gui.HOMainFrame.instance().getLineupPanel().update(); + Objects.requireNonNull(HOMainFrame.instance().getLineupPanel()).update(); } } From 52df56415c63ccc996fd4debd233b0475ed2faca Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sun, 4 Jan 2026 13:32:49 +0100 Subject: [PATCH 04/31] #2379 Fix HOTableModel.kt rowsorter --- src/main/java/core/gui/comp/table/HOTableModel.kt | 1 + .../module/playerOverview/PlayerDetailsPanel.java | 3 ++- .../module/playerOverview/PlayerOverviewPanel.java | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index 0cf21b4e5..ae9cf7da1 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -337,6 +337,7 @@ abstract class HOTableModel protected constructor( val newSelectedRow = table.convertRowIndexToView(modelIndex) table.setRowSelectionInterval(newSelectedRow, newSelectedRow) } + selectedRow = -1 } } } diff --git a/src/main/java/module/playerOverview/PlayerDetailsPanel.java b/src/main/java/module/playerOverview/PlayerDetailsPanel.java index afe148b5f..2a64eabf7 100644 --- a/src/main/java/module/playerOverview/PlayerDetailsPanel.java +++ b/src/main/java/module/playerOverview/PlayerDetailsPanel.java @@ -10,6 +10,7 @@ import core.gui.comp.entry.DoubleLabelEntries; import core.gui.comp.panel.ImagePanel; import core.gui.comp.renderer.SmilieListCellRenderer; +import core.gui.comp.table.PlayersTable; import core.gui.theme.*; import core.model.FactorObject; import core.model.FormulaFactors; @@ -114,7 +115,7 @@ public final class PlayerDetailsPanel extends ImagePanel implements Refreshable, public void setPlayer(Player player) { if (player == null) { if (HOMainFrame.isHOMainFrame_initialized()) { - player = HOMainFrame.instance().getSelectedPlayer(); + player = PlayersTable.Companion.getSelectedPlayer(); } } // if ( player == null) { diff --git a/src/main/java/module/playerOverview/PlayerOverviewPanel.java b/src/main/java/module/playerOverview/PlayerOverviewPanel.java index fd3162032..b1ffd4656 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playerOverview/PlayerOverviewPanel.java @@ -1,6 +1,8 @@ package module.playerOverview; import core.gui.HOMainFrame; +import core.gui.RefreshManager; +import core.gui.Refreshable; import core.gui.comp.panel.ImagePanel; import core.gui.comp.table.PlayersTable; import core.gui.model.UserColumnController; @@ -15,7 +17,7 @@ /** * Overview of all the players on the team (main class of the package) */ -public class PlayerOverviewPanel extends ImagePanel { +public class PlayerOverviewPanel extends ImagePanel implements Refreshable { private JSplitPane horizontalRightSplitPane; private JSplitPane verticalSplitPane; @@ -29,6 +31,7 @@ public class PlayerOverviewPanel extends ImagePanel { */ public PlayerOverviewPanel() { initComponents(); + RefreshManager.instance().registerRefreshable(this); this.playerOverviewTable.addListSelectionListener(e -> selectPlayer()); this.playerOverviewTable.setRowSelectionInterval(0, 0); } @@ -59,8 +62,8 @@ public final int[] getDividerLocations() { * Refresh, if a player is changed in the lineup */ public final void refresh() { - playerDetailsPanel.refresh(); playerOverviewTable.refresh(); + playerDetailsPanel.refresh(); } /** @@ -200,4 +203,9 @@ public void storeUserSettings() var playerOverviewTableModel = (PlayerOverviewTableModel)playerOverviewTable.getModel(); playerOverviewTableModel.storeUserSettings(); } + + @Override + public void reInit() { + refresh(); + } } \ No newline at end of file From fd5b12a7f40ea68650d5649f818d7d9abef582ff Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 17 Jan 2026 11:20:08 +0100 Subject: [PATCH 05/31] #2379 CheckBoxTableEntry (not yet editable) --- src/main/java/core/gui/HOMainFrame.java | 2 +- .../gui/comp/entry/CheckBoxTableEntry.java | 92 ++++++++++++++++++ .../gui/comp/entry/IHOTableCellEntry.java | 4 +- .../core/gui/comp/entry/TorLabelEntry.java | 97 ------------------- .../renderer/HODefaultTableCellRenderer.java | 6 +- .../core/gui/comp/table/BooleanColumn.java | 19 ---- .../java/core/gui/comp/table/HOTableModel.kt | 5 +- .../gui/comp/table/PlayerCheckBoxColumn.java | 19 ++++ .../java/core/gui/comp/table/UserColumn.java | 4 + .../java/core/gui/model/PlayerColumn.java | 6 +- .../core/gui/model/UserColumnFactory.java | 20 +++- src/main/java/core/model/player/Player.java | 9 +- .../java/module/lineup/LineupMasterView.java | 4 + src/main/java/module/lineup/LineupModule.java | 11 ++- src/main/java/module/lineup/LineupPanel.java | 79 +++++++++------ .../module/lineup/LineupPlayersTable.java | 10 ++ .../playerOverview/PlayerOverviewPanel.java | 30 +----- .../PlayerOverviewTableModel.kt | 27 +++--- 18 files changed, 242 insertions(+), 202 deletions(-) create mode 100644 src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java delete mode 100644 src/main/java/core/gui/comp/entry/TorLabelEntry.java delete mode 100644 src/main/java/core/gui/comp/table/BooleanColumn.java create mode 100644 src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java diff --git a/src/main/java/core/gui/HOMainFrame.java b/src/main/java/core/gui/HOMainFrame.java index f7974715c..40d8f430e 100644 --- a/src/main/java/core/gui/HOMainFrame.java +++ b/src/main/java/core/gui/HOMainFrame.java @@ -682,7 +682,7 @@ private void saveUserParameter() { final int[] ap = getLineupPanel().getDividerLocations(); parameter.lineupPanel_verticalSplitLocation = ap[0]; parameter.lineupPanel_horizontalSplitLocation = ap[1]; - getLineupPanel().saveColumnOrder(); +// getLineupPanel().saveColumnOrder(); } // TransferScoutPanel diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java new file mode 100644 index 000000000..547110c38 --- /dev/null +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -0,0 +1,92 @@ +package core.gui.comp.entry; + +import core.gui.comp.renderer.HODefaultTableCellRenderer; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; + +public class CheckBoxTableEntry extends JCheckBox implements IHOTableCellEntry { + private final Color fgStandard; + private final Color bgStandard; + + private Boolean value; + + public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard, int center) { + this.value = value; + this.fgStandard = fgStandard; + this.bgStandard = bgStandard; + createComponent(); + setEnabled(isEnabled); + } + + protected void setValue(boolean b) { + this.value = b; + this.updateComponent(); + } + + public Boolean getValue() {return this.value; } + + + @Override + public JComponent getComponent(boolean selected) { + if (selected) { + this.setBackground(HODefaultTableCellRenderer.SELECTION_BG); + + } else { + this.setBackground(bgStandard); + } + this.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); + return this; + } + + @Override + public void clear() { + this.setSelected(false); + } + + @Override + public int compareTo(@NotNull IHOTableCellEntry obj) { + if (obj instanceof CheckBoxTableEntry entry) { + if (this.getValue() == entry.getValue()){ + return 0; + } + else if (this.getValue()){ + return 1; + } + } + //Not a checkbox + return -1; + } + + @Override + public int compareToThird(IHOTableCellEntry obj) { + return this.compareTo(obj); + } + + @Override + public void createComponent() { + this.setSelected(this.value); + this.setOpaque(true); + this.setForeground(fgStandard); + } + + @Override + public void updateComponent() { + this.setSelected(this.value); + this.setBackground(bgStandard); + this.setForeground(fgStandard); + } + + public void setEnabled(boolean b) { + super.setEnabled(b); + if ( b){ + this.setFocusable(true); + this.addItemListener(event -> { + setValue(event.getStateChange()== ItemEvent.SELECTED);}); +// var editor = new DefaultCellEditor(this.checkBox); +// editor.setClickCountToStart(1); + } + } +} diff --git a/src/main/java/core/gui/comp/entry/IHOTableCellEntry.java b/src/main/java/core/gui/comp/entry/IHOTableCellEntry.java index b991ca878..fd08d3be5 100644 --- a/src/main/java/core/gui/comp/entry/IHOTableCellEntry.java +++ b/src/main/java/core/gui/comp/entry/IHOTableCellEntry.java @@ -5,7 +5,7 @@ /** * Classes implementing this interface create a {@link javax.swing.JComponent} that will * be displayed as a cell in a {@link javax.swing.JTable}: they act as factories to - * create and initialise the UI component. + * create and update the UI component. * *

To display the component, call {@link #getComponent(boolean)}

. */ @@ -14,7 +14,7 @@ public interface IHOTableCellEntry extends Comparable { /** * This method returns the JComponent, which shall be shown in the Table. The component should - * be created be createComponent and only the background should be changed according to the + * be created by createComponent and only the background should be changed according to the * isSelected-Flag. Nevertheless, you can ignore the createComponent and updateComponent and * create a new one everytime getComponent is called, but that is much slower! */ diff --git a/src/main/java/core/gui/comp/entry/TorLabelEntry.java b/src/main/java/core/gui/comp/entry/TorLabelEntry.java deleted file mode 100644 index 3ade935c0..000000000 --- a/src/main/java/core/gui/comp/entry/TorLabelEntry.java +++ /dev/null @@ -1,97 +0,0 @@ -package core.gui.comp.entry; - -import core.gui.comp.renderer.HODefaultTableCellRenderer; -import core.gui.theme.HOIconName; -import core.gui.theme.ThemeManager; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - - -public class TorLabelEntry extends AbstractHOTableEntry { - - private static Icon BALLIMAGEICON; - - private JComponent m_clComponent = new JPanel(); - private int m_iTore; - - - public TorLabelEntry() { - this(0); - } - - public TorLabelEntry(int tore) { - if (BALLIMAGEICON == null) { - BALLIMAGEICON = ThemeManager.getScaledIcon(HOIconName.BALL, 14, 14); - } - - setTore(tore); - createComponent(); - } - - public final javax.swing.JComponent getComponent(boolean isSelected) { - m_clComponent.setBackground(isSelected?HODefaultTableCellRenderer.SELECTION_BG:ColorLabelEntry.BG_STANDARD); - return m_clComponent; - } - - public final void setTore(int tore) { - if (tore != m_iTore) { - m_iTore = tore; - updateComponent(); - } - } - - public final int getTore() { - return m_iTore; - } - - - public final void clear() { - m_clComponent.removeAll(); - } - - - public final int compareTo(@NotNull IHOTableCellEntry obj) { - if (obj instanceof TorLabelEntry) { - final TorLabelEntry entry = (TorLabelEntry) obj; - - if (getTore() < entry.getTore()) { - return -1; - } else if (getTore() > entry.getTore()) { - return 1; - } else { - return 0; - } - } - - return 0; - } - - public final void createComponent() { - JPanel renderer = new JPanel(); - renderer.setLayout(new BoxLayout(renderer, 0)); - renderer.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - - for (float f = m_iTore; f > 0; f--) { - final JLabel jlabel = new JLabel(BALLIMAGEICON); - jlabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - renderer.add(jlabel); - } - - m_clComponent = renderer; - } - - public final void incTore() { - setTore(getTore() + 1); - } - - public final void updateComponent() { - m_clComponent.removeAll(); - - for (float f = m_iTore; f > 0; f--) { - final JLabel jlabel = new JLabel(BALLIMAGEICON); - jlabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - m_clComponent.add(jlabel); - } - } -} diff --git a/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java b/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java index c4914d4aa..bff059e9c 100644 --- a/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java +++ b/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java @@ -30,8 +30,10 @@ public java.awt.Component getTableCellRendererComponent(JTable table, Object val { if (value instanceof IHOTableCellEntry ihoTableCellEntry) { final JComponent component = ihoTableCellEntry.getComponent(isSelected); - if (isSelected) { - component.setOpaque(true); + if ( component != null) { + if (isSelected) { + component.setOpaque(true); + } } return component; } else if (value instanceof JComponent component) { diff --git a/src/main/java/core/gui/comp/table/BooleanColumn.java b/src/main/java/core/gui/comp/table/BooleanColumn.java deleted file mode 100644 index 296d55b3e..000000000 --- a/src/main/java/core/gui/comp/table/BooleanColumn.java +++ /dev/null @@ -1,19 +0,0 @@ -package core.gui.comp.table; - -import core.model.player.Player; - -public class BooleanColumn extends UserColumn { - - public BooleanColumn(int id, String name, String tooltip, int minWidth){ - super(id,name,tooltip); - this.minWidth = minWidth; - preferredWidth = minWidth; - } - - public Boolean getValue(Player player){ - - return player.getCanBeSelectedByAssistant(); - } - - -} diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index ae9cf7da1..72e59cb4f 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -138,8 +138,9 @@ abstract class HOTableModel protected constructor( } override fun isCellEditable(row: Int, column: Int): Boolean { - if (column > -1 && column < columns.size) { - return columns[column].isEditable + val cols = getDisplayedColumns() + if (column > -1 && column < cols.size) { + return cols[column].isEditable } return false } diff --git a/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java b/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java new file mode 100644 index 000000000..8b58e95e6 --- /dev/null +++ b/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java @@ -0,0 +1,19 @@ +package core.gui.comp.table; + +import core.gui.comp.entry.IHOTableCellEntry; +import core.gui.model.PlayerColumn; +import core.model.player.Player; +import org.jetbrains.annotations.NotNull; + +public class PlayerCheckBoxColumn extends PlayerColumn { + + public PlayerCheckBoxColumn(int id, String name, String tooltip, int minWidth){ + super(id,name,tooltip); + this.minWidth = minWidth; + preferredWidth = minWidth; + } + + public IHOTableCellEntry getTableEntry(@NotNull Player player) { + return null; + } +} diff --git a/src/main/java/core/gui/comp/table/UserColumn.java b/src/main/java/core/gui/comp/table/UserColumn.java index 99b22d28f..65acaa20a 100644 --- a/src/main/java/core/gui/comp/table/UserColumn.java +++ b/src/main/java/core/gui/comp/table/UserColumn.java @@ -1,6 +1,8 @@ package core.gui.comp.table; import core.model.TranslationFacility; +import org.jetbrains.annotations.NotNull; + import javax.swing.*; import javax.swing.table.TableColumn; @@ -194,4 +196,6 @@ public void setSortOrder(SortOrder sortOrder) { } public boolean isEditable() {return false;} + + public DefaultCellEditor getEditor() {return null;} } diff --git a/src/main/java/core/gui/model/PlayerColumn.java b/src/main/java/core/gui/model/PlayerColumn.java index 82126b31a..33a7596f7 100644 --- a/src/main/java/core/gui/model/PlayerColumn.java +++ b/src/main/java/core/gui/model/PlayerColumn.java @@ -7,6 +7,8 @@ import core.model.player.Player; import org.jetbrains.annotations.Nullable; +import javax.swing.*; + /** * Column shows skill of a player * @author Thorsten Dietz @@ -62,7 +64,7 @@ public IHOTableCellEntry getTableEntry(Player player, @Nullable Player comparePl return new ColorLabelEntry(getValue(player), ColorLabelEntry.BG_STANDARD, false, 0); } - + /** * return the individual playerValue * overwritten by created columns @@ -72,6 +74,4 @@ public IHOTableCellEntry getTableEntry(Player player, @Nullable Player comparePl public int getValue(Player player){ return player.getPlayerId(); } - - } diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index 7d775b6ec..73bf8577c 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -4,6 +4,7 @@ import core.constants.player.PlayerSkill; import core.db.DBManager; import core.gui.comp.entry.*; +import core.gui.comp.table.PlayerCheckBoxColumn; import core.gui.theme.HOColorName; import core.gui.theme.HOIconName; import core.gui.theme.ImageUtilities; @@ -21,6 +22,7 @@ import core.util.Helper; import core.util.StringUtils; import module.playerOverview.PlayerStatusLabelEntry; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.table.TableColumn; @@ -499,7 +501,7 @@ public IHOTableCellEntry getTableEntry(PlayerMatchCBItem spielerCBItem) { * @return PlayerColumn[] */ public static PlayerColumn[] createPlayerAdditionalArray() { - final PlayerColumn[] playerAdditionalArray = new PlayerColumn[31]; + final PlayerColumn[] playerAdditionalArray = new PlayerColumn[32]; playerAdditionalArray[0] = new PlayerColumn(10, "ls.player.shirtnumber.short", "ls.player.shirtnumber", 25) { @Override @@ -958,6 +960,22 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { return new ColorLabelEntry(player.getNote().replace('\n', '/'), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT); } }; + + playerAdditionalArray[31] = new PlayerCheckBoxColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) { + @Override + public IHOTableCellEntry getTableEntry(@NotNull Player player) { + return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.CENTER){ + @Override + protected void setValue(boolean value) { + player.setCanBeSelectedByAssistant(value); + super.setValue(value); + } + }; + } + @Override + public boolean isEditable() {return true;} + + }; return playerAdditionalArray; } diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index 004163f36..aea0436fe 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -1233,16 +1233,21 @@ public int getPlaymakingSkill() { * set whether that player can be selected by the assistant */ public void setCanBeSelectedByAssistant(boolean flag) { + if (flag == canBeSelectedByAssistant) return; // nothing changed if (this.isExternallyRecruitedCoach()) flag = false; getNotes().setEligibleToPlay(flag); DBManager.instance().storePlayerNotes(notes); + canBeSelectedByAssistant = flag; } + private Boolean canBeSelectedByAssistant; + /** * get whether that player can be selected by the assistant */ - public boolean getCanBeSelectedByAssistant() { - return !this.isExternallyRecruitedCoach() && getNotes().isEligibleToPlay(); + public Boolean getCanBeSelectedByAssistant() { + if (canBeSelectedByAssistant == null) {canBeSelectedByAssistant = !this.isExternallyRecruitedCoach() && getNotes().isEligibleToPlay();} + return canBeSelectedByAssistant; } public void setPlayerId(int m_iSpielerID) { diff --git a/src/main/java/module/lineup/LineupMasterView.java b/src/main/java/module/lineup/LineupMasterView.java index 28137740c..894a33798 100644 --- a/src/main/java/module/lineup/LineupMasterView.java +++ b/src/main/java/module/lineup/LineupMasterView.java @@ -99,4 +99,8 @@ private void refreshView() { this.penaltyTakersView.setPlayers(HOVerwaltung.instance().getModel().getCurrentPlayers()); this.penaltyTakersView.setLineup(HOVerwaltung.instance().getModel().getCurrentLineup()); } + + public void storeUserSettings() { + this.lineupPanel.storeUserSettings(); + } } diff --git a/src/main/java/module/lineup/LineupModule.java b/src/main/java/module/lineup/LineupModule.java index 85816479a..811820be4 100644 --- a/src/main/java/module/lineup/LineupModule.java +++ b/src/main/java/module/lineup/LineupModule.java @@ -8,6 +8,7 @@ public final class LineupModule extends DefaultModule { + private LineupMasterView lineupMasterView; public LineupModule() { super(true); } @@ -24,7 +25,8 @@ public String getDescription() { @Override public JPanel createTabPanel() { - return new LineupMasterView(); + this.lineupMasterView = new LineupMasterView(); + return this.lineupMasterView; } @Override @@ -32,4 +34,11 @@ public KeyStroke getKeyStroke() { return KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0); } + @Override + public void storeUserSettings() + { + if (this.lineupMasterView != null) this.lineupMasterView.storeUserSettings(); + } + + } diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index da2b3a48e..331949285 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -1,8 +1,10 @@ package module.lineup; -import core.gui.HOMainFrame; +import core.gui.Refreshable; import core.gui.Updatable; +import core.gui.comp.entry.CheckBoxTableEntry; import core.gui.comp.table.PlayersTable; +import core.gui.model.UserColumnController; import core.gui.theme.HOColorName; import core.gui.theme.ThemeManager; import core.model.UserParameter; @@ -12,6 +14,8 @@ import module.lineup.lineup.MatchAndLineupSelectionPanel; import module.lineup.lineup.PlayerPositionPanel; import module.lineup.ratings.LineupRatingPanel; +import module.playerOverview.PlayerOverviewTableModel; + import javax.swing.*; import java.awt.*; import java.util.ArrayList; @@ -21,28 +25,31 @@ /** * Master panel of the Lineup module */ -public class LineupPanel extends core.gui.comp.panel.ImagePanel { +public class LineupPanel extends core.gui.comp.panel.ImagePanel implements Refreshable { public static final Color TITLE_FG = ThemeManager.getColor(HOColorName.LINEUP_HIGHLIGHT_FG); private LineupPositionsPanel lineupPositionsPanel; - private LineupPlayersTable lineupPlayersTable; + private PlayersTable lineupPlayersTable; private LineupRatingAssistantPanel lineupRatingAssistantPanel; private JSplitPane horizontalSplitPane; private JSplitPane verticalSplitPane; private final List updatable = new ArrayList<>(); - private boolean areSelecting = false; +// private boolean areSelecting = false; public LineupPanel() { initComponents(); + var playerOverviewTableModel = (PlayerOverviewTableModel)this.lineupPlayersTable.getModel(); + playerOverviewTableModel.reInitData(); } public void storeUserSettings(){ - this.lineupPlayersTable.getTableModel().storeUserSettings(); + var playerOverviewTableModel = (PlayerOverviewTableModel)this.lineupPlayersTable.getModel(); + playerOverviewTableModel.storeUserSettings(); } - public void setPlayer(int idPlayer) { - lineupPlayersTable.setPlayer(idPlayer); - } +// public void setPlayer(int idPlayer) { +// lineupPlayersTable.setPlayer(idPlayer); +// } public void refresh() { lineupPlayersTable.refresh(); @@ -80,9 +87,9 @@ public final int[] getDividerLocations() { return locations; } - public void saveColumnOrder() { - lineupPlayersTable.saveColumnOrder(); - } +// public void saveColumnOrder() { +// lineupPlayersTable.saveColumnOrder(); +// } /** * Refresh the players and tactics of each Lineup panels @@ -138,25 +145,32 @@ private LineupRatingAssistantPanel getLineupRatingAssistantPanel() { } private Component initSpielerTabelle() { - lineupPlayersTable = new LineupPlayersTable(); - lineupPlayersTable.getSelectionModel().addListSelectionListener( - e -> { - if (!areSelecting) { - areSelecting = true; - var player = lineupPlayersTable.getPlayer(e.getFirstIndex()); - if (player == null) { -// player = HOMainFrame.instance().getSelectedPlayer(); - player = PlayersTable.Companion.getSelectedPlayer(); - if (player != null) { - lineupPlayersTable.setPlayer(player.getPlayerId()); - } - } else { -// HOMainFrame.instance().selectPlayer(player); - } - areSelecting = false; - } - } - ); + var model = UserColumnController.instance().getLineupModel(); + lineupPlayersTable = new PlayersTable(model); +// for ( var modelColumn : model.getColumns()){ +// if ( modelColumn.isEditable()){ +// var tableColumn = lineupPlayersTable.getColumn(modelColumn.getId()); +// tableColumn.setCellEditor(new DefaultCellEditor(new JCheckBox())); +// } +// } +// lineupPlayersTable.getSelectionModel().addListSelectionListener( +// e -> { +// if (!areSelecting) { +// areSelecting = true; +// var player = lineupPlayersTable.getPlayer(e.getFirstIndex()); +// if (player == null) { +//// player = HOMainFrame.instance().getSelectedPlayer(); +// player = PlayersTable.Companion.getSelectedPlayer(); +// if (player != null) { +// lineupPlayersTable.setPlayer(player.getPlayerId()); +// } +// } else { +//// HOMainFrame.instance().selectPlayer(player); +// } +// areSelecting = false; +// } +// } +// ); return lineupPlayersTable.getContainerComponent(); } @@ -255,4 +269,9 @@ public ArrayList getAllPositions() { public int getSelectedMatchMinute() { return this.lineupRatingAssistantPanel.getLineupRatingPanel().getSelectedMatchMinute(); } + + @Override + public void reInit() { + refresh(); + } } diff --git a/src/main/java/module/lineup/LineupPlayersTable.java b/src/main/java/module/lineup/LineupPlayersTable.java index b4f7ae4b9..85b0bf8f0 100644 --- a/src/main/java/module/lineup/LineupPlayersTable.java +++ b/src/main/java/module/lineup/LineupPlayersTable.java @@ -6,6 +6,7 @@ import core.gui.comp.renderer.BooleanTableCellRenderer; import core.gui.comp.renderer.HODefaultTableCellRenderer; import core.gui.comp.table.FixedColumnsTable; +import core.util.HOLogger; import module.playerOverview.PlayerOverviewTableModel; import core.gui.model.UserColumnController; import core.gui.model.UserColumnFactory; @@ -16,6 +17,8 @@ import core.net.HattrickLink; import module.playerOverview.PlayerTable; import org.jetbrains.annotations.Nullable; + +import javax.swing.event.TableModelEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -31,12 +34,19 @@ public final class LineupPlayersTable extends FixedColumnsTable implements core. super(UserColumnController.instance().getLineupModel()); tableModel = (PlayerOverviewTableModel) this.getModel(); // tableModel.setValues(HOVerwaltung.instance().getModel().getCurrentPlayers()); + tableModel.addTableModelListener(this::editPlayerAutoLineup); + setDefaultRenderer(Object.class, new HODefaultTableCellRenderer()); setDefaultRenderer(Boolean.class, new BooleanTableCellRenderer()); RefreshManager.instance().registerRefreshable(this); initListeners(); } + private void editPlayerAutoLineup(TableModelEvent tableModelEvent) { + + HOLogger.instance().info(this.getClass(), "editPlayerLineupEnabled"); + } + @Override public void setPlayer(int iPlayerID) { tableModel.selectPlayer(iPlayerID); diff --git a/src/main/java/module/playerOverview/PlayerOverviewPanel.java b/src/main/java/module/playerOverview/PlayerOverviewPanel.java index b1ffd4656..881d06a2f 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playerOverview/PlayerOverviewPanel.java @@ -71,8 +71,7 @@ public final void refresh() { */ public final void refreshHRFComparison() { var playerTableModel = (PlayerOverviewTableModel)playerOverviewTable.getModel(); - playerTableModel.reInitDataHRFComparison(); -// playerDetailsPanel.setPlayer(playerOverviewTable.getSelectedPlayer()); + playerTableModel.reInitData(); } /** @@ -171,33 +170,6 @@ private Component initPlayersTable() { return overviewPanel; } - -// private boolean areSelecting = false; -// -// /** -// * Adds ListSelectionListener which keep the row selection of the table with -// * the players name and the table with the players details in sync. -// */ -// private void addTableSelectionListeners() { -// playerOverviewTable.getSelectionModel().addListSelectionListener( -// e -> { -// if (!areSelecting) { -// areSelecting = true; -// var player = playerOverviewTable.getSelectedPlayer(); -// if (player == null) { -// player = HOMainFrame.instance().getSelectedPlayer(); -// if ( player != null) { -// playerOverviewTable.selectPlayer(player.getPlayerId()); -// } -// } else { -// HOMainFrame.instance().selectPlayer(player); -// } -// areSelecting = false; -// } -// } -// ); -// } - public void storeUserSettings() { var playerOverviewTableModel = (PlayerOverviewTableModel)playerOverviewTable.getModel(); diff --git a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt index 14d5b1fb3..25fa88fc1 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt @@ -1,7 +1,7 @@ package module.playerOverview import core.db.DBManager -import core.gui.comp.table.BooleanColumn +import core.gui.comp.table.PlayerCheckBoxColumn import core.gui.comp.table.HOPlayersTableModel import core.gui.comp.table.UserColumn import core.gui.model.PlayerColumn @@ -75,7 +75,8 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str columns[60] = additionalArray?.get(22) columns[61] = additionalArray?.get(23) // schum-rank columns[62] = additionalArray?.get(24) // schum-rank benchmark - columns[63] = BooleanColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) +// columns[63] = BooleanColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) + columns[63] = additionalArray?.get(31) columns[64] = additionalArray?.get(25) columns[65] = additionalArray?.get(26) columns[66] = additionalArray?.get(27) @@ -87,11 +88,11 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str assert(this.columns.size == columns.size) } - // TODO: table column model should control isEditable - // Refactoring player overview table model should replace the class BooleanColumn - override fun isCellEditable(row: Int, column: Int): Boolean { - return getValueAt(row, column) is Boolean - } +// // TODO: table column model should control isEditable +// // Refactoring player overview table model should replace the class BooleanColumn +// override fun isCellEditable(row: Int, column: Int): Boolean { +// return getValueAt(row, column) is Boolean +// } fun getRowIndexOfPlayer(playerId: Int): Int { val modelIndex = getPlayerIndex(playerId) @@ -160,9 +161,9 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str // } /** - * Resets the data for an HRF comparison. + * Resets the data. */ - fun reInitDataHRFComparison() { + fun reInitData() { initData() } @@ -216,10 +217,10 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str val currentPlayer = players[i] val comparisonPlayer = getPreviousPlayerDevelopmentStage(currentPlayer) for (j in tmpDisplayedColumns.indices) { - if (tmpDisplayedColumns[j] is PlayerColumn) { - m_clData!!.get(i)[j] = (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, comparisonPlayer) - } else if (tmpDisplayedColumns[j] is BooleanColumn) { - m_clData!!.get(i)[j] = (tmpDisplayedColumns[j] as BooleanColumn).getValue(currentPlayer) + if (tmpDisplayedColumns[j] is PlayerCheckBoxColumn) { + m_clData!!.get(i)[j] = (tmpDisplayedColumns[j] as PlayerCheckBoxColumn).getTableEntry(currentPlayer) + } else if (tmpDisplayedColumns[j] is PlayerColumn) { + m_clData!!.get(i)[j] = (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, comparisonPlayer) } } } From 67d7704584ced0b38fd7b76a38d6882a59ee1563 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 17 Jan 2026 11:34:02 +0100 Subject: [PATCH 06/31] #2379 CheckBoxTableEntry (not yet editable) --- src/main/java/core/gui/HOMainFrame.java | 1 - src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java | 5 ++--- src/main/java/core/gui/comp/table/UserColumn.java | 1 - src/main/java/core/gui/model/UserColumnFactory.java | 2 +- src/main/java/module/lineup/LineupPanel.java | 1 - 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/core/gui/HOMainFrame.java b/src/main/java/core/gui/HOMainFrame.java index 40d8f430e..a424cd9c7 100644 --- a/src/main/java/core/gui/HOMainFrame.java +++ b/src/main/java/core/gui/HOMainFrame.java @@ -13,7 +13,6 @@ import core.model.TranslationFacility; import core.model.UserParameter; import core.model.match.Weather; -import core.model.player.Player; import core.module.IModule; import core.module.ModuleManager; import core.module.config.ModuleConfig; diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java index 547110c38..e246b02b6 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -13,7 +13,7 @@ public class CheckBoxTableEntry extends JCheckBox implements IHOTableCellEntry { private Boolean value; - public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard, int center) { + public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { this.value = value; this.fgStandard = fgStandard; this.bgStandard = bgStandard; @@ -83,8 +83,7 @@ public void setEnabled(boolean b) { super.setEnabled(b); if ( b){ this.setFocusable(true); - this.addItemListener(event -> { - setValue(event.getStateChange()== ItemEvent.SELECTED);}); + this.addItemListener(event -> setValue(event.getStateChange()== ItemEvent.SELECTED)); // var editor = new DefaultCellEditor(this.checkBox); // editor.setClickCountToStart(1); } diff --git a/src/main/java/core/gui/comp/table/UserColumn.java b/src/main/java/core/gui/comp/table/UserColumn.java index 65acaa20a..0f73e9d3d 100644 --- a/src/main/java/core/gui/comp/table/UserColumn.java +++ b/src/main/java/core/gui/comp/table/UserColumn.java @@ -1,7 +1,6 @@ package core.gui.comp.table; import core.model.TranslationFacility; -import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.table.TableColumn; diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index 73bf8577c..a4b976c16 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -964,7 +964,7 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { playerAdditionalArray[31] = new PlayerCheckBoxColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) { @Override public IHOTableCellEntry getTableEntry(@NotNull Player player) { - return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.CENTER){ + return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD){ @Override protected void setValue(boolean value) { player.setCanBeSelectedByAssistant(value); diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index 331949285..4a7c64c3f 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -2,7 +2,6 @@ import core.gui.Refreshable; import core.gui.Updatable; -import core.gui.comp.entry.CheckBoxTableEntry; import core.gui.comp.table.PlayersTable; import core.gui.model.UserColumnController; import core.gui.theme.HOColorName; From cf61a25357a7601d4408e6ecc29e90a2a17ba9c9 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 17 Jan 2026 11:56:19 +0100 Subject: [PATCH 07/31] #2379 Fix PlayerColumn.getTableEntry --- src/main/java/core/gui/model/PlayerColumn.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/core/gui/model/PlayerColumn.java b/src/main/java/core/gui/model/PlayerColumn.java index 33a7596f7..5d5a901bc 100644 --- a/src/main/java/core/gui/model/PlayerColumn.java +++ b/src/main/java/core/gui/model/PlayerColumn.java @@ -62,7 +62,7 @@ public PlayerColumn(int id,String name, String tooltip,int minWidth){ */ public IHOTableCellEntry getTableEntry(Player player, @Nullable Player comparePlayer){ return new ColorLabelEntry(getValue(player), - ColorLabelEntry.BG_STANDARD, false, 0); + ColorLabelEntry.BG_STANDARD, 0); } /** From 830db306a0e3747d72f1e3d2850563b60b48408b Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Wed, 21 Jan 2026 19:39:31 +0100 Subject: [PATCH 08/31] #2379 Debug CheckBoxTableEntry --- .../gui/comp/entry/CheckBoxTableEntry.java | 87 ++++++++++++++----- .../java/core/gui/comp/table/HOTableModel.kt | 12 ++- .../java/core/gui/comp/table/UserColumn.java | 2 - src/main/java/module/lineup/LineupPanel.java | 15 ++++ 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java index e246b02b6..4fec02190 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -1,24 +1,60 @@ package core.gui.comp.entry; import core.gui.comp.renderer.HODefaultTableCellRenderer; +import core.gui.comp.table.PlayersTable; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; import java.awt.*; import java.awt.event.ItemEvent; -public class CheckBoxTableEntry extends JCheckBox implements IHOTableCellEntry { +public class CheckBoxTableEntry implements IHOTableCellEntry { + + public static class Editor implements CellEditorListener { + + private JCheckBox checkBox; + private DefaultCellEditor cellEditor; + + public Editor() { + this.checkBox = new JCheckBox(); + cellEditor = new DefaultCellEditor(this.checkBox); + cellEditor.setClickCountToStart(1); + cellEditor.addCellEditorListener(this); + } + + public DefaultCellEditor getCellEditor() {return cellEditor; } + public JCheckBox getCheckBox() { return checkBox; } + + @Override + public void editingStopped(ChangeEvent e) { + + } + + @Override + public void editingCanceled(ChangeEvent e) { + + } + + } + + private static Editor editor = new Editor(); + public static Editor getEditor() { return editor; } + private final Color fgStandard; private final Color bgStandard; private Boolean value; + private boolean isEnabled; + private JCheckBox getCheckbox(){return this.getEditor().getCheckBox();} public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { this.value = value; + this.isEnabled=isEnabled; this.fgStandard = fgStandard; this.bgStandard = bgStandard; createComponent(); - setEnabled(isEnabled); } protected void setValue(boolean b) { @@ -26,24 +62,27 @@ protected void setValue(boolean b) { this.updateComponent(); } - public Boolean getValue() {return this.value; } + public Boolean getValue() { + return this.value; + } @Override public JComponent getComponent(boolean selected) { + var checkbox = getCheckbox(); if (selected) { - this.setBackground(HODefaultTableCellRenderer.SELECTION_BG); + checkbox.setBackground(HODefaultTableCellRenderer.SELECTION_BG); } else { - this.setBackground(bgStandard); + checkbox.setBackground(bgStandard); } - this.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); - return this; + checkbox.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); + return checkbox; } @Override public void clear() { - this.setSelected(false); + getCheckbox().setSelected(false); } @Override @@ -67,25 +106,27 @@ public int compareToThird(IHOTableCellEntry obj) { @Override public void createComponent() { - this.setSelected(this.value); - this.setOpaque(true); - this.setForeground(fgStandard); + updateComponent(); } @Override public void updateComponent() { - this.setSelected(this.value); - this.setBackground(bgStandard); - this.setForeground(fgStandard); + var checkbox = getCheckbox(); + checkbox.setEnabled(this.isEnabled); + checkbox.setSelected(this.value); + checkbox.setBackground(bgStandard); + checkbox.setForeground(fgStandard); } - public void setEnabled(boolean b) { - super.setEnabled(b); - if ( b){ - this.setFocusable(true); - this.addItemListener(event -> setValue(event.getStateChange()== ItemEvent.SELECTED)); -// var editor = new DefaultCellEditor(this.checkBox); -// editor.setClickCountToStart(1); - } - } +// public void setEnabled(boolean b) { +// var checkbox = getCheckbox(); +// checkbox.setEnabled(b); +// if ( b){ +// checkbox.setFocusable(true); +//// checkbox.addItemListener(event -> +//// setValue(event.getStateChange()== ItemEvent.SELECTED)); +//// var editor = new DefaultCellEditor(this.checkBox); +//// editor.setClickCountToStart(1); +// } +// } } diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index 72e59cb4f..2e84289b1 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -1,11 +1,14 @@ package core.gui.comp.table import core.db.DBManager +import core.gui.comp.entry.CheckBoxTableEntry import core.gui.comp.renderer.HODefaultTableCellRenderer import core.gui.model.UserColumnController.ColumnModelId import core.model.TranslationFacility import core.util.HOLogger +import okhttp3.internal.checkOffsetAndCount import java.util.* +import javax.swing.JCheckBox import javax.swing.JTable import javax.swing.RowSorter import javax.swing.SortOrder @@ -132,7 +135,11 @@ abstract class HOTableModel protected constructor( */ override fun getValueAt(row: Int, column: Int): Any? { if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size ) { - return m_clData!![row][column] + var ret = m_clData!![row][column] + if ( ret is CheckBoxTableEntry){ + return ret.value + } + return ret } return null } @@ -162,6 +169,9 @@ abstract class HOTableModel protected constructor( val obj = getValueAt(0, columnIndex) if (obj != null) { + if ( obj is CheckBoxTableEntry) { + return Boolean::class.java + } return obj.javaClass } diff --git a/src/main/java/core/gui/comp/table/UserColumn.java b/src/main/java/core/gui/comp/table/UserColumn.java index 0f73e9d3d..a39091997 100644 --- a/src/main/java/core/gui/comp/table/UserColumn.java +++ b/src/main/java/core/gui/comp/table/UserColumn.java @@ -195,6 +195,4 @@ public void setSortOrder(SortOrder sortOrder) { } public boolean isEditable() {return false;} - - public DefaultCellEditor getEditor() {return null;} } diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index 4a7c64c3f..58e039ac5 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -2,6 +2,8 @@ import core.gui.Refreshable; import core.gui.Updatable; +import core.gui.comp.entry.CheckBoxTableEntry; +import core.gui.comp.table.PlayerCheckBoxColumn; import core.gui.comp.table.PlayersTable; import core.gui.model.UserColumnController; import core.gui.theme.HOColorName; @@ -38,6 +40,18 @@ public class LineupPanel extends core.gui.comp.panel.ImagePanel implements Refre public LineupPanel() { initComponents(); var playerOverviewTableModel = (PlayerOverviewTableModel)this.lineupPlayersTable.getModel(); + +// for (var c : playerOverviewTableModel.getColumns()) { +// if (c instanceof PlayerCheckBoxColumn playerCheckBoxColumn) { +// if (playerCheckBoxColumn.isEditable()) { +// var tableColumn = lineupPlayersTable.getColumn(c.getId()); +// if (tableColumn != null) { +// tableColumn.setCellEditor(CheckBoxTableEntry.getEditor().getCellEditor()); +// } +// } +// } +// } + playerOverviewTableModel.reInitData(); } @@ -273,4 +287,5 @@ public int getSelectedMatchMinute() { public void reInit() { refresh(); } + } From 58d599956dddaa8cc4fcf4c1a2e608bdab9ca15b Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Wed, 21 Jan 2026 22:39:07 +0100 Subject: [PATCH 09/31] #2379 Fix CheckBoxTableEntry --- .../gui/comp/entry/CheckBoxTableEntry.java | 72 ++++--------------- .../java/core/gui/comp/table/HOTableModel.kt | 6 +- .../core/gui/model/UserColumnFactory.java | 2 +- 3 files changed, 19 insertions(+), 61 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java index 4fec02190..865e39e38 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -12,77 +12,47 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { - public static class Editor implements CellEditorListener { - - private JCheckBox checkBox; - private DefaultCellEditor cellEditor; - - public Editor() { - this.checkBox = new JCheckBox(); - cellEditor = new DefaultCellEditor(this.checkBox); - cellEditor.setClickCountToStart(1); - cellEditor.addCellEditorListener(this); - } - - public DefaultCellEditor getCellEditor() {return cellEditor; } - public JCheckBox getCheckBox() { return checkBox; } - - @Override - public void editingStopped(ChangeEvent e) { - - } - - @Override - public void editingCanceled(ChangeEvent e) { - - } - - } - - private static Editor editor = new Editor(); - public static Editor getEditor() { return editor; } - private final Color fgStandard; private final Color bgStandard; + private JCheckBox checkBox; private Boolean value; - private boolean isEnabled; - private JCheckBox getCheckbox(){return this.getEditor().getCheckBox();} public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { this.value = value; - this.isEnabled=isEnabled; + this.checkBox = new JCheckBox(); + this.checkBox.setSelected(value != null && value); + this.checkBox.setEnabled(isEnabled); this.fgStandard = fgStandard; this.bgStandard = bgStandard; createComponent(); } - protected void setValue(boolean b) { + public void setValue(boolean b) { this.value = b; + this.checkBox.setSelected(b); this.updateComponent(); } public Boolean getValue() { return this.value; } - @Override public JComponent getComponent(boolean selected) { - var checkbox = getCheckbox(); if (selected) { - checkbox.setBackground(HODefaultTableCellRenderer.SELECTION_BG); + this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG); } else { - checkbox.setBackground(bgStandard); + this.checkBox.setBackground(bgStandard); } - checkbox.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); - return checkbox; + this.checkBox.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); + return this.checkBox; } @Override public void clear() { - getCheckbox().setSelected(false); + this.checkBox.setSelected(false); } @Override @@ -111,22 +81,8 @@ public void createComponent() { @Override public void updateComponent() { - var checkbox = getCheckbox(); - checkbox.setEnabled(this.isEnabled); - checkbox.setSelected(this.value); - checkbox.setBackground(bgStandard); - checkbox.setForeground(fgStandard); + this.checkBox.setSelected(this.value); + this.checkBox.setBackground(bgStandard); + this.checkBox.setForeground(fgStandard); } - -// public void setEnabled(boolean b) { -// var checkbox = getCheckbox(); -// checkbox.setEnabled(b); -// if ( b){ -// checkbox.setFocusable(true); -//// checkbox.addItemListener(event -> -//// setValue(event.getStateChange()== ItemEvent.SELECTED)); -//// var editor = new DefaultCellEditor(this.checkBox); -//// editor.setClickCountToStart(1); -// } -// } } diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index 2e84289b1..e76596cdc 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -6,9 +6,7 @@ import core.gui.comp.renderer.HODefaultTableCellRenderer import core.gui.model.UserColumnController.ColumnModelId import core.model.TranslationFacility import core.util.HOLogger -import okhttp3.internal.checkOffsetAndCount import java.util.* -import javax.swing.JCheckBox import javax.swing.JTable import javax.swing.RowSorter import javax.swing.SortOrder @@ -198,6 +196,10 @@ abstract class HOTableModel protected constructor( */ override fun setValueAt(value: Any, row: Int, column: Int) { if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size ) { + var ret = m_clData!![row][column] + if ( ret is CheckBoxTableEntry){ + ret.value = value as Boolean? + } m_clData!![row][column] = value } for (table in tables) { diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index a4b976c16..cec37665b 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -966,7 +966,7 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { public IHOTableCellEntry getTableEntry(@NotNull Player player) { return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD){ @Override - protected void setValue(boolean value) { + public void setValue(boolean value) { player.setCanBeSelectedByAssistant(value); super.setValue(value); } From 9fd04c853008019712fdd59dca3c1f837072d9d5 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Wed, 21 Jan 2026 22:40:38 +0100 Subject: [PATCH 10/31] #2379 Fix CheckBoxTableEntry --- src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java | 7 +------ src/main/java/core/gui/comp/table/HOTableModel.kt | 4 ++-- src/main/java/module/lineup/LineupPanel.java | 2 -- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java index 865e39e38..03320e11a 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -1,21 +1,16 @@ package core.gui.comp.entry; import core.gui.comp.renderer.HODefaultTableCellRenderer; -import core.gui.comp.table.PlayersTable; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import javax.swing.event.CellEditorListener; -import javax.swing.event.ChangeEvent; import java.awt.*; -import java.awt.event.ItemEvent; public class CheckBoxTableEntry implements IHOTableCellEntry { private final Color fgStandard; private final Color bgStandard; - - private JCheckBox checkBox; + private final JCheckBox checkBox; private Boolean value; public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index e76596cdc..d023f5cbc 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -133,7 +133,7 @@ abstract class HOTableModel protected constructor( */ override fun getValueAt(row: Int, column: Int): Any? { if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size ) { - var ret = m_clData!![row][column] + val ret = m_clData!![row][column] if ( ret is CheckBoxTableEntry){ return ret.value } @@ -196,7 +196,7 @@ abstract class HOTableModel protected constructor( */ override fun setValueAt(value: Any, row: Int, column: Int) { if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size ) { - var ret = m_clData!![row][column] + val ret = m_clData!![row][column] if ( ret is CheckBoxTableEntry){ ret.value = value as Boolean? } diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index 58e039ac5..8b7c8392a 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -2,8 +2,6 @@ import core.gui.Refreshable; import core.gui.Updatable; -import core.gui.comp.entry.CheckBoxTableEntry; -import core.gui.comp.table.PlayerCheckBoxColumn; import core.gui.comp.table.PlayersTable; import core.gui.model.UserColumnController; import core.gui.theme.HOColorName; From ef758926f8b5a7dbc35f479d4d35b9d13c6483be Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Wed, 21 Jan 2026 23:51:00 +0100 Subject: [PATCH 11/31] #2379 Review --- src/main/java/core/gui/HOMainFrame.java | 21 --- .../gui/comp/entry/CheckBoxTableEntry.java | 41 +++++- .../renderer/HODefaultTableCellRenderer.java | 8 +- .../java/core/gui/comp/table/HOTableModel.kt | 30 ++-- .../core/gui/model/UserColumnFactory.java | 17 ++- src/main/java/core/model/player/Player.java | 22 +-- src/main/java/module/lineup/LineupModule.java | 8 +- src/main/java/module/lineup/LineupPanel.java | 53 +------ .../module/lineup/LineupPlayersTable.java | 138 ------------------ .../lineup/lineup/PlayerPositionPanel.java | 10 +- .../playerOverview/PlayerDetailsPanel.java | 9 -- .../playerOverview/PlayerOverviewPanel.java | 11 +- .../playerOverview/PlayerOverviewTable.kt | 120 --------------- .../PlayerOverviewTableModel.kt | 73 +-------- .../java/module/youth/YouthPlayerView.java | 5 +- 15 files changed, 101 insertions(+), 465 deletions(-) delete mode 100644 src/main/java/module/lineup/LineupPlayersTable.java delete mode 100644 src/main/java/module/playerOverview/PlayerOverviewTable.kt diff --git a/src/main/java/core/gui/HOMainFrame.java b/src/main/java/core/gui/HOMainFrame.java index a424cd9c7..882f7bba4 100644 --- a/src/main/java/core/gui/HOMainFrame.java +++ b/src/main/java/core/gui/HOMainFrame.java @@ -68,16 +68,6 @@ public final class HOMainFrame extends JFrame implements Refreshable { private final Color c_beta = new Color(162, 201, 255); private final Color c_dev = new Color(235, 170, 170); -// // TODO: Move this to a model backing the main window -// public Player getSelectedPlayer() { -// return m_selectedPlayer; -// } -// -// private Player m_selectedPlayer; - - // ~ Constructors - // ------------------------------------------------------------------------------- - /** * Singleton */ @@ -187,15 +177,6 @@ public static boolean isHOMainFrame_initialized() { return m_HOMainFrame_initialized; } -// public void selectPlayer(Player player) { -// if (m_selectedPlayer != player) { -// m_selectedPlayer = player; -// var lineupPanel = getLineupPanel(); -// if (lineupPanel != null) lineupPanel.setPlayer(player.getPlayerId()); -// getSpielerUebersichtPanel().setPlayer(player); -// } -// } - public LineupPanel getLineupPanel() { Container c = getTabbedPane().getModulePanel(IModule.LINEUP); if (c instanceof LineupPanel) { @@ -673,7 +654,6 @@ private void saveUserParameter() { parameter.spielerUebersichtsPanel_horizontalLeftSplitPane = sup[0]; parameter.spielerUebersichtsPanel_horizontalRightSplitPane = sup[1]; parameter.spielerUebersichtsPanel_verticalSplitPane = sup[2]; -// getSpielerUebersichtPanel().saveColumnOrder(); } // Lineup Panel @@ -681,7 +661,6 @@ private void saveUserParameter() { final int[] ap = getLineupPanel().getDividerLocations(); parameter.lineupPanel_verticalSplitLocation = ap[0]; parameter.lineupPanel_horizontalSplitLocation = ap[1]; -// getLineupPanel().saveColumnOrder(); } // TransferScoutPanel diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java index 03320e11a..0169bdbcb 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -13,6 +13,13 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { private final JCheckBox checkBox; private Boolean value; + /** + * Create table cell entry for booleans by check box + * @param isEnabled boolean + * @param value Boolean - Checked + * @param fgStandard Color + * @param bgStandard Color + */ public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { this.value = value; this.checkBox = new JCheckBox(); @@ -23,16 +30,29 @@ public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Co createComponent(); } + /** + * Set value is called from HOTableModel + * @param b boolean + */ public void setValue(boolean b) { this.value = b; this.checkBox.setSelected(b); this.updateComponent(); } + /** + * Get value is called from HOTableModel + * @return Boolean + */ public Boolean getValue() { return this.value; } + /** + * Return the checkbox component + * @param selected + * @return JComponent + */ @Override public JComponent getComponent(boolean selected) { if (selected) { @@ -45,11 +65,19 @@ public JComponent getComponent(boolean selected) { return this.checkBox; } + /** + * Reset the checkbox + */ @Override public void clear() { this.checkBox.setSelected(false); } + /** + * Compare with other cell entry + * @param obj the object to be compared. + * @return int [-1,0,1] + */ @Override public int compareTo(@NotNull IHOTableCellEntry obj) { if (obj instanceof CheckBoxTableEntry entry) { @@ -60,20 +88,31 @@ else if (this.getValue()){ return 1; } } - //Not a checkbox + // Not a checkbox return -1; } + /** + * Same as compareTo + * @param obj + * @return + */ @Override public int compareToThird(IHOTableCellEntry obj) { return this.compareTo(obj); } + /** + * Update the component + */ @Override public void createComponent() { updateComponent(); } + /** + * Update the component + */ @Override public void updateComponent() { this.checkBox.setSelected(this.value); diff --git a/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java b/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java index bff059e9c..ec8aa79df 100644 --- a/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java +++ b/src/main/java/core/gui/comp/renderer/HODefaultTableCellRenderer.java @@ -11,7 +11,6 @@ import javax.swing.JLabel; import javax.swing.JTable; - /** * Renderer for tables with JLabels as table objects */ @@ -26,11 +25,10 @@ public java.awt.Component getTableCellRendererComponent(JTable table, Object val boolean isSelected, boolean hasFocus, int row, - int column) - { + int column) { if (value instanceof IHOTableCellEntry ihoTableCellEntry) { final JComponent component = ihoTableCellEntry.getComponent(isSelected); - if ( component != null) { + if (component != null) { if (isSelected) { component.setOpaque(true); } @@ -49,4 +47,4 @@ public java.awt.Component getTableCellRendererComponent(JTable table, Object val return component; } } -} +} \ No newline at end of file diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index d023f5cbc..614a844c5 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -35,8 +35,8 @@ abstract class HOTableModel protected constructor( * Identifier of the column model. * It is used for saving columns in db */ - @JvmField - val id: Int = id.value + @JvmField + val id: Int = id.value /** * Return all columns of the model @@ -52,7 +52,7 @@ abstract class HOTableModel protected constructor( /** Data of table */ @JvmField - protected var m_clData: Array>? = null + protected var m_clData: Array>? = null // TODO: Check if a list of tables is necessary (See SpielerMatchesTable, which uses two instances of same table model type) @@ -132,9 +132,9 @@ abstract class HOTableModel protected constructor( * @return Object */ override fun getValueAt(row: Int, column: Int): Any? { - if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size ) { - val ret = m_clData!![row][column] - if ( ret is CheckBoxTableEntry){ + if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size) { + val ret = m_clData!![row][column] + if (ret is CheckBoxTableEntry) { return ret.value } return ret @@ -167,7 +167,7 @@ abstract class HOTableModel protected constructor( val obj = getValueAt(0, columnIndex) if (obj != null) { - if ( obj is CheckBoxTableEntry) { + if (obj is CheckBoxTableEntry) { return Boolean::class.java } return obj.javaClass @@ -195,9 +195,9 @@ abstract class HOTableModel protected constructor( * @param column column of cell */ override fun setValueAt(value: Any, row: Int, column: Int) { - if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size ) { - val ret = m_clData!![row][column] - if ( ret is CheckBoxTableEntry){ + if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size) { + val ret = m_clData!![row][column] + if (ret is CheckBoxTableEntry) { ret.value = value as Boolean? } m_clData!![row][column] = value @@ -325,14 +325,14 @@ abstract class HOTableModel protected constructor( // Copy user columns' identifiers to table's columns val displayedColumns = getDisplayedColumns() - var i=0 + var i = 0 for (userColumn in displayedColumns) { val tableColumn = getTableColumn(table, i++) tableColumn.identifier = userColumn.getId() - if (userColumn.isHidden){ - tableColumn.preferredWidth=0 - tableColumn.minWidth=0 - tableColumn.maxWidth=0 + if (userColumn.isHidden) { + tableColumn.preferredWidth = 0 + tableColumn.minWidth = 0 + tableColumn.maxWidth = 0 } } getUserColumnSettings(table) diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index cec37665b..28dafedce 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -964,16 +964,19 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { playerAdditionalArray[31] = new PlayerCheckBoxColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) { @Override public IHOTableCellEntry getTableEntry(@NotNull Player player) { - return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD){ - @Override - public void setValue(boolean value) { - player.setCanBeSelectedByAssistant(value); - super.setValue(value); - } + return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD) { + @Override + public void setValue(boolean value) { + player.setCanBeSelectedByAssistant(value); + super.setValue(value); + } }; } + @Override - public boolean isEditable() {return true;} + public boolean isEditable() { + return true; + } }; return playerAdditionalArray; diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index aea0436fe..b31ee3734 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -334,10 +334,6 @@ public void setContractDate(String contractDate) { private List skillChanges; - - //~ Constructors ------------------------------------------------------------------------------- - - /** * Creates a new instance of Player */ @@ -345,11 +341,12 @@ public Player() { } /** - * Erstellt einen Player aus den Properties einer HRF Datei + * Create player from properties of a hrf file + * @param properties HOProperties hrf properties + * @param hrfDate HODateTime Date from the hrf file + * @param hrfId int Identifier of the hrf file */ public Player(HOProperties properties, HODateTime hrfDate, int hrfId) { - // Separate first, nick and last names are available. Utilize them? - this.hrfId = hrfId; spielerId = properties.getInt("id", 0); firstName = properties.getProperty("firstname", ""); @@ -467,6 +464,7 @@ public Integer getOrDownloadMotherClubId() { downloadMotherClubInfoIfMissing(); return this.motherClubId; } + private void downloadMotherClubInfoIfMissing() { var isCurrentPlayer = HOVerwaltung.instance().getModel().getCurrentPlayer(this.getPlayerId()) != null; if (isCurrentPlayer && motherClubId == null ) { @@ -1158,7 +1156,6 @@ public int getMarktwert() { return tsi; } - String latestTSIInjured; String latestTSINotInjured; @@ -1231,6 +1228,8 @@ public int getPlaymakingSkill() { /** * set whether that player can be selected by the assistant + * The value is stored to the database + * @param flag boolean */ public void setCanBeSelectedByAssistant(boolean flag) { if (flag == canBeSelectedByAssistant) return; // nothing changed @@ -1243,10 +1242,13 @@ public void setCanBeSelectedByAssistant(boolean flag) { private Boolean canBeSelectedByAssistant; /** - * get whether that player can be selected by the assistant + * Get whether that player can be selected by the assistant + * @return Boolean */ public Boolean getCanBeSelectedByAssistant() { - if (canBeSelectedByAssistant == null) {canBeSelectedByAssistant = !this.isExternallyRecruitedCoach() && getNotes().isEligibleToPlay();} + if (canBeSelectedByAssistant == null) { + canBeSelectedByAssistant = !this.isExternallyRecruitedCoach() && getNotes().isEligibleToPlay(); + } return canBeSelectedByAssistant; } diff --git a/src/main/java/module/lineup/LineupModule.java b/src/main/java/module/lineup/LineupModule.java index 811820be4..401370e7a 100644 --- a/src/main/java/module/lineup/LineupModule.java +++ b/src/main/java/module/lineup/LineupModule.java @@ -8,7 +8,8 @@ public final class LineupModule extends DefaultModule { - private LineupMasterView lineupMasterView; + private LineupMasterView lineupMasterView; + public LineupModule() { super(true); } @@ -35,10 +36,7 @@ public KeyStroke getKeyStroke() { } @Override - public void storeUserSettings() - { + public void storeUserSettings() { if (this.lineupMasterView != null) this.lineupMasterView.storeUserSettings(); } - - } diff --git a/src/main/java/module/lineup/LineupPanel.java b/src/main/java/module/lineup/LineupPanel.java index 8b7c8392a..36fa41007 100644 --- a/src/main/java/module/lineup/LineupPanel.java +++ b/src/main/java/module/lineup/LineupPanel.java @@ -33,35 +33,18 @@ public class LineupPanel extends core.gui.comp.panel.ImagePanel implements Refre private JSplitPane horizontalSplitPane; private JSplitPane verticalSplitPane; private final List updatable = new ArrayList<>(); -// private boolean areSelecting = false; public LineupPanel() { initComponents(); - var playerOverviewTableModel = (PlayerOverviewTableModel)this.lineupPlayersTable.getModel(); - -// for (var c : playerOverviewTableModel.getColumns()) { -// if (c instanceof PlayerCheckBoxColumn playerCheckBoxColumn) { -// if (playerCheckBoxColumn.isEditable()) { -// var tableColumn = lineupPlayersTable.getColumn(c.getId()); -// if (tableColumn != null) { -// tableColumn.setCellEditor(CheckBoxTableEntry.getEditor().getCellEditor()); -// } -// } -// } -// } - + var playerOverviewTableModel = (PlayerOverviewTableModel) this.lineupPlayersTable.getModel(); playerOverviewTableModel.reInitData(); } - public void storeUserSettings(){ - var playerOverviewTableModel = (PlayerOverviewTableModel)this.lineupPlayersTable.getModel(); + public void storeUserSettings() { + var playerOverviewTableModel = (PlayerOverviewTableModel) this.lineupPlayersTable.getModel(); playerOverviewTableModel.storeUserSettings(); } -// public void setPlayer(int idPlayer) { -// lineupPlayersTable.setPlayer(idPlayer); -// } - public void refresh() { lineupPlayersTable.refresh(); } @@ -86,7 +69,6 @@ private LineupPositionsPanel getLineupPositionsPanel() { return lineupPositionsPanel; } - /** * Get the divider location to restore user previous view organization */ @@ -98,10 +80,6 @@ public final int[] getDividerLocations() { return locations; } -// public void saveColumnOrder() { -// lineupPlayersTable.saveColumnOrder(); -// } - /** * Refresh the players and tactics of each Lineup panels */ @@ -111,7 +89,6 @@ public final void update() { lineupPlayersTable.refresh(); // Refresh the table and details of the player overview core.gui.HOMainFrame.instance().getSpielerUebersichtPanel().refresh(); - fireUpdate(); } @@ -158,30 +135,6 @@ private LineupRatingAssistantPanel getLineupRatingAssistantPanel() { private Component initSpielerTabelle() { var model = UserColumnController.instance().getLineupModel(); lineupPlayersTable = new PlayersTable(model); -// for ( var modelColumn : model.getColumns()){ -// if ( modelColumn.isEditable()){ -// var tableColumn = lineupPlayersTable.getColumn(modelColumn.getId()); -// tableColumn.setCellEditor(new DefaultCellEditor(new JCheckBox())); -// } -// } -// lineupPlayersTable.getSelectionModel().addListSelectionListener( -// e -> { -// if (!areSelecting) { -// areSelecting = true; -// var player = lineupPlayersTable.getPlayer(e.getFirstIndex()); -// if (player == null) { -//// player = HOMainFrame.instance().getSelectedPlayer(); -// player = PlayersTable.Companion.getSelectedPlayer(); -// if (player != null) { -// lineupPlayersTable.setPlayer(player.getPlayerId()); -// } -// } else { -//// HOMainFrame.instance().selectPlayer(player); -// } -// areSelecting = false; -// } -// } -// ); return lineupPlayersTable.getContainerComponent(); } diff --git a/src/main/java/module/lineup/LineupPlayersTable.java b/src/main/java/module/lineup/LineupPlayersTable.java deleted file mode 100644 index 85b0bf8f0..000000000 --- a/src/main/java/module/lineup/LineupPlayersTable.java +++ /dev/null @@ -1,138 +0,0 @@ -package module.lineup; - -import core.db.DBManager; -import core.gui.HOMainFrame; -import core.gui.RefreshManager; -import core.gui.comp.renderer.BooleanTableCellRenderer; -import core.gui.comp.renderer.HODefaultTableCellRenderer; -import core.gui.comp.table.FixedColumnsTable; -import core.util.HOLogger; -import module.playerOverview.PlayerOverviewTableModel; -import core.gui.model.UserColumnController; -import core.gui.model.UserColumnFactory; -import core.model.HOVerwaltung; -import core.model.match.MatchKurzInfo; -import core.model.player.IMatchRoleID; -import core.model.player.Player; -import core.net.HattrickLink; -import module.playerOverview.PlayerTable; -import org.jetbrains.annotations.Nullable; - -import javax.swing.event.TableModelEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** - * Table displaying the players' details in Lineup tab. - * which is the same table class used in the Squad tab - */ -public final class LineupPlayersTable extends FixedColumnsTable implements core.gui.Refreshable, PlayerTable { - - private final PlayerOverviewTableModel tableModel; - - LineupPlayersTable() { - super(UserColumnController.instance().getLineupModel()); - tableModel = (PlayerOverviewTableModel) this.getModel(); -// tableModel.setValues(HOVerwaltung.instance().getModel().getCurrentPlayers()); - tableModel.addTableModelListener(this::editPlayerAutoLineup); - - setDefaultRenderer(Object.class, new HODefaultTableCellRenderer()); - setDefaultRenderer(Boolean.class, new BooleanTableCellRenderer()); - RefreshManager.instance().registerRefreshable(this); - initListeners(); - } - - private void editPlayerAutoLineup(TableModelEvent tableModelEvent) { - - HOLogger.instance().info(this.getClass(), "editPlayerLineupEnabled"); - } - - @Override - public void setPlayer(int iPlayerID) { - tableModel.selectPlayer(iPlayerID); - } - - @Override - public @Nullable Player getPlayer(int row) { - return tableModel.getPlayerAtRow(row); - } - - @Override - public void reInit() { - var selectedPlayer = tableModel.getSelectedPlayer(); - resetPlayers(); - repaint(); - if (selectedPlayer != null) { - tableModel.selectPlayer(selectedPlayer.getPlayerId()); - } - } - - @Override - public void refresh() { - reInit(); - } - - public PlayerOverviewTableModel getTableModel() { - return this.tableModel; - } - - public void saveColumnOrder() { - tableModel.storeUserSettings(); - } - - private void resetPlayers() { - tableModel.setPlayers(HOVerwaltung.instance().getModel().getCurrentPlayers()); - } - - private void initListeners() { - this.getTableModel().addTableModelListener(e -> { - var r = e.getFirstRow(); - var c = e.getColumn(); - var player = tableModel.getPlayerAtRow(r); - if (player != null) { - var userColumn = this.getUserColumn(e); - if (userColumn != null && userColumn.getId() == UserColumnFactory.AUTO_LINEUP) { - var autoLineup = tableModel.getValueAt(convertRowIndexToModel(r),convertColumnIndexToModel(c)); - if (autoLineup != null){ - player.setCanBeSelectedByAssistant((boolean) autoLineup); - if( player.getCanBeSelectedByAssistant()){ - // this player has been made selectable from the Lineup tab, for consistency we set its position to undefined - player.setUserPosFlag(IMatchRoleID.UNKNOWN); - } - else { - player.setUserPosFlag(IMatchRoleID.UNSELECTABLE); - } - HOMainFrame.instance().getSpielerUebersichtPanel().update(); - } - } - } - }); - - addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - int rowindex = getSelectedRow(); - if (rowindex >= 0) { - // Last match column - Player selectedPlayer = tableModel.getPlayerAtRow(rowindex); - if (selectedPlayer != null) { - var viewColumn = columnAtPoint(e.getPoint()); - if (viewColumn > -1) { - var column = getColumnModel().getColumn(viewColumn); - if ((Integer)column.getIdentifier() == UserColumnFactory.LAST_MATCH_RATING) { - if (e.isShiftDown()) { - int matchId = selectedPlayer.getLastMatchId(); - // TODO get the match type of last match from player. For the moment we hope, that going with no type will work - MatchKurzInfo info = DBManager.instance().getMatchesKurzInfoByMatchID(matchId, null); - HattrickLink.showMatch(matchId + "", info.getMatchType().isOfficial()); - } else if (e.getClickCount() == 2) { - HOMainFrame.instance().showMatch(selectedPlayer.getLastMatchId()); - } - } - } - } - } - } - }); - } -} \ No newline at end of file diff --git a/src/main/java/module/lineup/lineup/PlayerPositionPanel.java b/src/main/java/module/lineup/lineup/PlayerPositionPanel.java index e7ea064f5..d4634ee54 100644 --- a/src/main/java/module/lineup/lineup/PlayerPositionPanel.java +++ b/src/main/java/module/lineup/lineup/PlayerPositionPanel.java @@ -100,12 +100,15 @@ private byte getTactic() { return null; } - + /** + * Handle the focus gained event. + * If a player is selected the PlayersTable's selection is updated + * @param event the event to be processed + */ @Override public void focusGained(FocusEvent event) { if (getSelectedPlayer() != null) { PlayersTable.Companion.setSelectedPlayer(getSelectedPlayer()); -// HOMainFrame.instance().selectPlayer(getSelectedPlayer()); } } @@ -159,7 +162,6 @@ private void initComponents() { add(jlp, BorderLayout.CENTER); } - @Override public void itemStateChanged(java.awt.event.ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { @@ -205,7 +207,6 @@ else if (m_iPositionID == IMatchRoleID.captain) { if (player != null) { PlayersTable.Companion.setSelectedPlayer(player); -// HOMainFrame.instance().selectPlayer(player); } //Update all other positions @@ -357,7 +358,6 @@ protected void setPlayersList(List oCandidates, @Nullable Player oSelect cbModel.removeAllElements(); //Ensure the number of m_clCBItems objects match what is needed - assert m_clCBItems != null; if (m_clCBItems.length != oCandidates.size()) { PlayerCBItem[] tempCB = new PlayerCBItem[oCandidates.size()]; diff --git a/src/main/java/module/playerOverview/PlayerDetailsPanel.java b/src/main/java/module/playerOverview/PlayerDetailsPanel.java index 2a64eabf7..49170ee9b 100644 --- a/src/main/java/module/playerOverview/PlayerDetailsPanel.java +++ b/src/main/java/module/playerOverview/PlayerDetailsPanel.java @@ -47,7 +47,6 @@ import static core.util.Helper.DEFAULTDEZIMALFORMAT; import static core.util.Helper.INTEGERFORMAT; - /** * Shows player details for the selected player */ @@ -60,7 +59,6 @@ public final class PlayerDetailsPanel extends ImagePanel implements Refreshable, private final Color URL = ThemeManager.getColor(HOColorName.URL_PANEL_BG); private final Color FGcolor = ColorLabelEntry.FG_STANDARD; private final Color BORDER_COLOR = ThemeManager.getColor(HOColorName.PLAYER_DETAILS_BAR_BORDER_COLOR); -// private final PlayerOverviewTable m_playerOverviewTable; private final JLabel jlName = new JLabel(""); private final JLabel m_jlPlayerDescription = new JLabel(""); private final JPanel jpPlayerGeneral = new JPanel(); @@ -118,11 +116,6 @@ public void setPlayer(Player player) { player = PlayersTable.Companion.getSelectedPlayer(); } } -// if ( player == null) { -// // at initialisation select first player to ensure clean display ===== -// player = m_playerOverviewTable.getPlayerTableModel().getPlayerAtRow(0); -// } - m_clPlayer = player; if (m_clPlayer != null) { findComparisonPlayer(); @@ -155,7 +148,6 @@ else if ( actionevent.getSource().equals(jlPlayerAvatar)){ } } - @Override public void itemStateChanged(java.awt.event.ItemEvent itemEvent) { if (itemEvent.getStateChange() == java.awt.event.ItemEvent.SELECTED) { @@ -336,7 +328,6 @@ private void setLabels() { jlPlayerAvatar.setEnabled(true); formatBar(jpbForm, m_clPlayer.getForm(), true); - //m_clPlayer.getValue4Skill(6) formatBar(jpbStamina, m_clPlayer.getStamina(), true); formatBar(jpbGK, (float)Helper.round(m_clPlayer.getSkill(PlayerSkill.KEEPER), 2)); formatBar(jpbDE, (float)Helper.round(m_clPlayer.getSkill(PlayerSkill.DEFENDING), 2)); diff --git a/src/main/java/module/playerOverview/PlayerOverviewPanel.java b/src/main/java/module/playerOverview/PlayerOverviewPanel.java index 881d06a2f..945dd7fe2 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playerOverview/PlayerOverviewPanel.java @@ -104,7 +104,7 @@ private void initComponents() { } /* - * Initialize the players details + * Initialise the players details */ private Component initSpielerDetail() { JTabbedPane tabbedPane = new JTabbedPane(); @@ -125,7 +125,7 @@ private Component initSpielerDetail() { } /* - * Initialize the players history + * Initialise the players history */ private Component initSpielerHistory() { JPanel panel = new ImagePanel(); @@ -170,11 +170,10 @@ private Component initPlayersTable() { return overviewPanel; } - public void storeUserSettings() - { - var playerOverviewTableModel = (PlayerOverviewTableModel)playerOverviewTable.getModel(); + public void storeUserSettings() { + var playerOverviewTableModel = (PlayerOverviewTableModel) playerOverviewTable.getModel(); playerOverviewTableModel.storeUserSettings(); - } + } @Override public void reInit() { diff --git a/src/main/java/module/playerOverview/PlayerOverviewTable.kt b/src/main/java/module/playerOverview/PlayerOverviewTable.kt deleted file mode 100644 index 3d71401f4..000000000 --- a/src/main/java/module/playerOverview/PlayerOverviewTable.kt +++ /dev/null @@ -1,120 +0,0 @@ -//package module.playerOverview -// -//import core.db.DBManager -//import core.gui.HOMainFrame -//import core.gui.RefreshManager -//import core.gui.Refreshable -//import core.gui.comp.table.FixedColumnsTable -//import module.playerOverview.PlayerOverviewTableModel -//import core.gui.model.UserColumnController -//import core.model.HOVerwaltung -//import core.model.TranslationFacility -//import core.model.player.Player -//import core.net.HattrickLink -//import java.awt.event.MouseAdapter -//import java.awt.event.MouseEvent -//import java.io.Serial -// -///** -// * The Squad table, listing all the players on the team. -// * -// * -// * The actual model for that table is defined in [PlayerOverviewTableModel], which defines -// * all the columns to be displayed; the columns are initiated by a factory, [UserColumnFactory], -// * which in particular sets their preferred width. -// * -// * -// * Sorting in the table is handled by [TableSorter] which decorates the model, and is set -// * as the [javax.swing.table.TableModel] for this table. Triggering sorting by a click sorts -// * the entries in the table model itself. The new sorting order is then used by re-displaying the -// * table. This approach differs from the “normal” Swing approach of using -// * [JTable.setRowSorter]. -// * -// * @author Thorsten Dietz -// */ -//class PlayerOverviewTable : FixedColumnsTable(UserColumnController.instance().playerOverviewModel), Refreshable { -// val playerTableModel: PlayerOverviewTableModel = this.model as PlayerOverviewTableModel -// -// init { -// playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) -// isOpaque = false -// if ( playerTableModel.players != null) { -// if ( playerTableModel.players!!.size > 0){ -// setRowSelectionInterval(0,0) -// } -// } -// RefreshManager.instance().registerRefreshable(this) -// -// // Add a mouse listener that, when clicking on the “Last match” column -// // - opens the Hattrick page for the player if you shift-click, -// // - or opens the match in HO if you double-click. -// addMouseListener(object : MouseAdapter() { -// override fun mouseReleased(e: MouseEvent) { -// val player: Player? = selectedPlayer -// if (player != null) { -// // Last match column -// val columnAtPoint = columnAtPoint(e.point) -// // Get name of the actual column at columnAtPoint, i.e. post-ordering of the columns -// // based on preferences. -// val columnName = playerTableModel.getColumnName(columnAtPoint) -// val lastMatchRating = TranslationFacility.tr("LastMatchRating") -// if (columnName != null && columnName.equals(lastMatchRating, ignoreCase = true)) { -// if (e.isShiftDown) { -// val matchId = player.lastMatchId -// val matchType = player.lastMatchType -// val info = DBManager.instance().getMatchesKurzInfoByMatchID(matchId, matchType) -// HattrickLink.showMatch(matchId.toString(), info.matchType.isOfficial) -// } else if (e.clickCount == 2) { -// HOMainFrame.instance().showMatch(player.lastMatchId) -// } -// } -// } -// } -// }) -// } -// -// val selectedPlayer: Player? -// get() { -// val rowIndex = selectedRow -// if (rowIndex >= 0) { -// return playerTableModel.players!![convertRowIndexToModel(rowIndex)] -// } -// return null -// } -// -// fun selectPlayer(playerId: Int) { -// playerTableModel.selectPlayer(playerId) -// } -// -// override fun reInit() { -// val player = selectedPlayer -// resetPlayers() -// repaint() -// if (player != null) { -// selectPlayer(player.playerId) -// } -// } -// -// fun reInitModel() { -// playerTableModel.reInitData() -// } -// -// fun reInitModelHRFComparison() { -// playerTableModel.reInitDataHRFComparison() -// } -// -// override fun refresh() { -// reInitModel() -// repaint() -// } -// -// fun refreshHRFComparison() { -// reInitModelHRFComparison() -// repaint() -// } -// -// private fun resetPlayers() { -// playerTableModel.setValues(HOVerwaltung.instance().model.currentPlayers) -// } -// -//} diff --git a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt index 25fa88fc1..2e36b36c8 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt @@ -28,7 +28,7 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str init { val basic: Array? = UserColumnFactory.createPlayerBasicArray() - val columns : Array = arrayOfNulls(70) + val columns: Array = arrayOfNulls(70) columns[0] = basic?.get(0) columns[48] = basic?.get(1) @@ -75,7 +75,6 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str columns[60] = additionalArray?.get(22) columns[61] = additionalArray?.get(23) // schum-rank columns[62] = additionalArray?.get(24) // schum-rank benchmark -// columns[63] = BooleanColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) columns[63] = additionalArray?.get(31) columns[64] = additionalArray?.get(25) columns[65] = additionalArray?.get(26) @@ -88,12 +87,6 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str assert(this.columns.size == columns.size) } -// // TODO: table column model should control isEditable -// // Refactoring player overview table model should replace the class BooleanColumn -// override fun isCellEditable(row: Int, column: Int): Boolean { -// return getValueAt(row, column) is Boolean -// } - fun getRowIndexOfPlayer(playerId: Int): Int { val modelIndex = getPlayerIndex(playerId) if (modelIndex > -1 && modelIndex < this.rowCount) { @@ -111,36 +104,6 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str return null } - fun selectPlayer(playerId: Int) { - val row = getRowIndexOfPlayer(playerId) - if (row > -1 && row < this.rowCount) { - table!!.setRowSelectionInterval(row, row) - } - } - - fun getPlayerAtRow(tableRow: Int): Player? { - if (tableRow > -1 && tableRow < this.rowCount) { - val modelIndex = table!!.convertRowIndexToModel(tableRow) - if (modelIndex > -1 && modelIndex < this.rowCount) { - return players[modelIndex] - } - } - return null - } - -// fun getPlayer(playerId: Int): Player? { -// // Can be negative for temp player -// if (playerId != 0) { -// for (m_vPlayer in players!!) { -// if (m_vPlayer.playerId == playerId) { -// return m_vPlayer -// } -// } -// } -// -// return null -// } - fun getPlayerIndex(playerId: Int): Int { var i = 0 for (m_vPlayer in players) { @@ -152,14 +115,6 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str return -1 } -// /** -// * Sets the new list of players. -// */ -// fun setValues(player: List?) { -// players = player -// initData() -// } - /** * Resets the data. */ @@ -172,7 +127,7 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str */ private fun getPreviousPlayerDevelopmentStage(currentDevelopmentStage: Player): Player? { val id = currentDevelopmentStage.playerId - if ( id >= 0 ) { + if (id >= 0) { // not a temporary player val selectedPlayerDevelopmentStage = SpielerTrainingsVergleichsPanel.getSelectedPlayerDevelopmentStage() var i = 0 @@ -220,31 +175,11 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str if (tmpDisplayedColumns[j] is PlayerCheckBoxColumn) { m_clData!!.get(i)[j] = (tmpDisplayedColumns[j] as PlayerCheckBoxColumn).getTableEntry(currentPlayer) } else if (tmpDisplayedColumns[j] is PlayerColumn) { - m_clData!!.get(i)[j] = (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, comparisonPlayer) + m_clData!!.get(i)[j] = + (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, comparisonPlayer) } } } fireTableDataChanged() } - -// /** -// * Initializes the lineup only -// */ -// fun reInitData() { -// val tmpDisplayedColumns = getDisplayedColumns() -// for (i in players!!.indices) { -// val currentPlayer = players!![i] -// for (j in tmpDisplayedColumns.indices) { -// if (tmpDisplayedColumns[j].id == UserColumnFactory.NAME || -// tmpDisplayedColumns[j].id == UserColumnFactory.LINEUP || -// tmpDisplayedColumns[j].id == UserColumnFactory.BEST_POSITION || -// tmpDisplayedColumns[j].id == UserColumnFactory.SCHUM_RANK_BENCHMARK || -// tmpDisplayedColumns[j].id == UserColumnFactory.GROUP) { -// m_clData!![i][j] = (tmpDisplayedColumns[j] as PlayerColumn).getTableEntry(currentPlayer, null) -// } else if (tmpDisplayedColumns[j].id == UserColumnFactory.AUTO_LINEUP) { -// m_clData!![i][j] = (tmpDisplayedColumns[j] as BooleanColumn).getValue(currentPlayer) -// } -// } -// } -// } } \ No newline at end of file diff --git a/src/main/java/module/youth/YouthPlayerView.java b/src/main/java/module/youth/YouthPlayerView.java index 931f0ef01..89a0e1ad6 100644 --- a/src/main/java/module/youth/YouthPlayerView.java +++ b/src/main/java/module/youth/YouthPlayerView.java @@ -155,9 +155,7 @@ private void refreshPlayerOverview() { isRefreshingPlayerOverview = true; var selection = this.playerOverviewTable.getSelectedModelIndex(); playerOverviewTableModel.initData(); - SwingUtilities.invokeLater(() -> { - this.playerOverviewTable.selectModelIndex(selection); - }); + SwingUtilities.invokeLater(() -> this.playerOverviewTable.selectModelIndex(selection)); } finally { isRefreshingPlayerOverview=false; @@ -267,7 +265,6 @@ private String getScoutComment(YouthPlayer player) { } private String formatLine(String text) { - /*if ( !text.endsWith(" ")) */ return text + "
"; } From 3d3ae1b6467eeb49c9f5fdb08d8f09cc9ead7049 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Wed, 21 Jan 2026 23:54:44 +0100 Subject: [PATCH 12/31] #2379 Review --- .../gui/comp/entry/CheckBoxTableEntry.java | 6 +++--- .../PlayerOverviewTableModel.kt | 19 ------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java index 0169bdbcb..48f7e7a9a 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java @@ -50,7 +50,7 @@ public Boolean getValue() { /** * Return the checkbox component - * @param selected + * @param selected boolean * @return JComponent */ @Override @@ -94,8 +94,8 @@ else if (this.getValue()){ /** * Same as compareTo - * @param obj - * @return + * @param obj IHOTableCellEntry The other entry + * @return int */ @Override public int compareToThird(IHOTableCellEntry obj) { diff --git a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt index 2e36b36c8..a904f43f7 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt +++ b/src/main/java/module/playerOverview/PlayerOverviewTableModel.kt @@ -87,14 +87,6 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str assert(this.columns.size == columns.size) } - fun getRowIndexOfPlayer(playerId: Int): Int { - val modelIndex = getPlayerIndex(playerId) - if (modelIndex > -1 && modelIndex < this.rowCount) { - return table!!.convertRowIndexToView(modelIndex) - } - return -1 - } - val selectedPlayer: Player? get() { val rowIndex = table!!.selectedRow @@ -104,17 +96,6 @@ class PlayerOverviewTableModel(id: UserColumnController.ColumnModelId, name: Str return null } - fun getPlayerIndex(playerId: Int): Int { - var i = 0 - for (m_vPlayer in players) { - if (m_vPlayer.playerId == playerId) { - return i - } - i++ - } - return -1 - } - /** * Resets the data. */ From a608eef40f4bfaba467326752571b82e3922896d Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Thu, 22 Jan 2026 19:55:55 +0100 Subject: [PATCH 13/31] #2379 Review --- src/main/java/module/playeroverview/PlayerTable.java | 10 ---------- .../java/module/teamanalyzer/vo/RosterRoleData.java | 11 +---------- src/test/java/core/model/TranslatorTest.java | 3 +-- src/test/java/tool/arenasizer/ArenaSizerTest.java | 3 +-- src/test/java/tool/arenasizer/StadiumTest.java | 1 - 5 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 src/main/java/module/playeroverview/PlayerTable.java diff --git a/src/main/java/module/playeroverview/PlayerTable.java b/src/main/java/module/playeroverview/PlayerTable.java deleted file mode 100644 index a870be2aa..000000000 --- a/src/main/java/module/playeroverview/PlayerTable.java +++ /dev/null @@ -1,10 +0,0 @@ -package module.playeroverview; - -import core.model.player.Player; - -public interface PlayerTable { - - Player getPlayer(int row); - void setPlayer(int spielerid); - -} diff --git a/src/main/java/module/teamanalyzer/vo/RosterRoleData.java b/src/main/java/module/teamanalyzer/vo/RosterRoleData.java index b961c0746..e1564c72d 100644 --- a/src/main/java/module/teamanalyzer/vo/RosterRoleData.java +++ b/src/main/java/module/teamanalyzer/vo/RosterRoleData.java @@ -1,15 +1,12 @@ package module.teamanalyzer.vo; -import core.model.player.MatchRoleID; -import core.util.HelperWrapper; - public class RosterRoleData { //~ Instance fields ---------------------------------------------------------------------------- private double avg; private double max; private double min; private int app; - private int pos; + private final int pos; //~ Constructors ------------------------------------------------------------------------------- /** @@ -42,12 +39,6 @@ public int getPos() { return pos; } - public String getPositionDesc() { - int posCode = HelperWrapper.instance().getPosition(pos); - - return MatchRoleID.getNameForPosition((byte) posCode); - } - public void addMatch(double rating) { if (rating > max) { max = rating; diff --git a/src/test/java/core/model/TranslatorTest.java b/src/test/java/core/model/TranslatorTest.java index 3e93b5776..b4e155d8c 100644 --- a/src/test/java/core/model/TranslatorTest.java +++ b/src/test/java/core/model/TranslatorTest.java @@ -1,7 +1,6 @@ package core.model; import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -193,4 +192,4 @@ void translateWithVariables(String language, String key, Object[] values, String // when-then assertThat(translator.translate(key, values)).isEqualTo(expectedTranslation); } -} \ No newline at end of file +} diff --git a/src/test/java/tool/arenasizer/ArenaSizerTest.java b/src/test/java/tool/arenasizer/ArenaSizerTest.java index 410508e82..28f56572a 100644 --- a/src/test/java/tool/arenasizer/ArenaSizerTest.java +++ b/src/test/java/tool/arenasizer/ArenaSizerTest.java @@ -1,7 +1,6 @@ package tool.arenasizer; import core.util.AmountOfMoney; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -107,4 +106,4 @@ private static Stadium createStadium(int terraces, int basicSeating, int underRo stadium.setVipBox(vipBox); return stadium; } -} \ No newline at end of file +} diff --git a/src/test/java/tool/arenasizer/StadiumTest.java b/src/test/java/tool/arenasizer/StadiumTest.java index 97f8ee54e..9fe30cb92 100644 --- a/src/test/java/tool/arenasizer/StadiumTest.java +++ b/src/test/java/tool/arenasizer/StadiumTest.java @@ -1,6 +1,5 @@ package tool.arenasizer; -import core.util.AmountOfMoney; import core.util.HODateTime; import org.junit.jupiter.api.Test; From e3455c0934ceafcb5bc7d58ad6e33a34795dbfcd Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Fri, 23 Jan 2026 00:07:48 +0100 Subject: [PATCH 14/31] #2379 release_notes.md --- src/main/resources/release_notes.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index 9cd0beeed..1d689cbce 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -16,6 +16,8 @@ ### Player overview * Fix error storing owner notes with length exceeding the column length (#2358) +* Fix error selecting players with the arrow keys (#2379) +* Synchronise player selection in training and player overview modules (#2379) ### Team Analyzer @@ -48,10 +50,13 @@ Reports by Contributors - October 19, 2025 - December 30, 2025 * Ioannidouefty 459 -* wsbrenk 31 +* wsbrenk 107 +* Frankieorabona 73 +* _KOHb_ 54 +* Sebastian Reddig 32 * Lidegand 24 * Kristaps 4 * Mara 3 * Joeri Roels 1 -Total 522 +Total 757 From 61377d496167cc55ed7ec05b8ca46c433586ddaa Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Fri, 23 Jan 2026 00:08:25 +0100 Subject: [PATCH 15/31] #2379 release_notes.md --- src/main/resources/release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index 1d689cbce..69f8a609c 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -52,7 +52,7 @@ Reports by Contributors - October 19, 2025 - December 30, 2025 * Ioannidouefty 459 * wsbrenk 107 * Frankieorabona 73 -* _KOHb_ 54 +* \_KOHb\_ 54 * Sebastian Reddig 32 * Lidegand 24 * Kristaps 4 From 788087d63a31e6f7297afbd901eb53b6e75802af Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Fri, 23 Jan 2026 18:44:17 +0100 Subject: [PATCH 16/31] Rename .java to .kt --- .../comp/entry/{CheckBoxTableEntry.java => CheckBoxTableEntry.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/core/gui/comp/entry/{CheckBoxTableEntry.java => CheckBoxTableEntry.kt} (100%) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt similarity index 100% rename from src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java rename to src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt From c440e4ab12d508e28774c0b6c3f01e6badedc3b3 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Fri, 23 Jan 2026 18:44:18 +0100 Subject: [PATCH 17/31] #2379 convert new class CheckBoxTableEntry to kotlin --- .../core/gui/comp/entry/CheckBoxTableEntry.kt | 101 ++++++++---------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt index 48f7e7a9a..83ac8e103 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt @@ -1,17 +1,15 @@ -package core.gui.comp.entry; +package core.gui.comp.entry -import core.gui.comp.renderer.HODefaultTableCellRenderer; -import org.jetbrains.annotations.NotNull; +import core.gui.comp.renderer.HODefaultTableCellRenderer +import java.awt.Color +import javax.swing.JCheckBox +import javax.swing.JComponent -import javax.swing.*; -import java.awt.*; - -public class CheckBoxTableEntry implements IHOTableCellEntry { - - private final Color fgStandard; - private final Color bgStandard; - private final JCheckBox checkBox; - private Boolean value; +open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandard: Color?, bgStandard: Color?) : + IHOTableCellEntry { + private val fgStandard: Color? + private val bgStandard: Color? + private val checkBox: JCheckBox /** * Create table cell entry for booleans by check box @@ -20,32 +18,31 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param fgStandard Color * @param bgStandard Color */ - public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { - this.value = value; - this.checkBox = new JCheckBox(); - this.checkBox.setSelected(value != null && value); - this.checkBox.setEnabled(isEnabled); - this.fgStandard = fgStandard; - this.bgStandard = bgStandard; - createComponent(); + init { + this.checkBox = JCheckBox() + this.checkBox.setSelected(value != null && value == true) + this.checkBox.setEnabled(isEnabled) + this.fgStandard = fgStandard + this.bgStandard = bgStandard + createComponent() } /** * Set value is called from HOTableModel * @param b boolean */ - public void setValue(boolean b) { - this.value = b; - this.checkBox.setSelected(b); - this.updateComponent(); + open fun setValue(b: Boolean) { + this.value = b + this.checkBox.setSelected(b) + this.updateComponent() } /** * Get value is called from HOTableModel * @return Boolean */ - public Boolean getValue() { - return this.value; + fun getValue(): Boolean { + return this.value!! } /** @@ -53,24 +50,21 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param selected boolean * @return JComponent */ - @Override - public JComponent getComponent(boolean selected) { + override fun getComponent(selected: Boolean): JComponent { if (selected) { - this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG); - + this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG) } else { - this.checkBox.setBackground(bgStandard); + this.checkBox.setBackground(bgStandard) } - this.checkBox.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); - return this.checkBox; + this.checkBox.setForeground(if (selected) HODefaultTableCellRenderer.SELECTION_FG else fgStandard) + return this.checkBox } /** * Reset the checkbox */ - @Override - public void clear() { - this.checkBox.setSelected(false); + override fun clear() { + this.checkBox.setSelected(false) } /** @@ -78,18 +72,16 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param obj the object to be compared. * @return int [-1,0,1] */ - @Override - public int compareTo(@NotNull IHOTableCellEntry obj) { - if (obj instanceof CheckBoxTableEntry entry) { - if (this.getValue() == entry.getValue()){ - return 0; - } - else if (this.getValue()){ - return 1; + override fun compareTo(obj: IHOTableCellEntry): Int { + if (obj is CheckBoxTableEntry) { + if (this.getValue() === obj.getValue()) { + return 0 + } else if (this.getValue()) { + return 1 } } // Not a checkbox - return -1; + return -1 } /** @@ -97,26 +89,23 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param obj IHOTableCellEntry The other entry * @return int */ - @Override - public int compareToThird(IHOTableCellEntry obj) { - return this.compareTo(obj); + override fun compareToThird(obj: IHOTableCellEntry): Int { + return this.compareTo(obj) } /** * Update the component */ - @Override - public void createComponent() { - updateComponent(); + override fun createComponent() { + updateComponent() } /** * Update the component */ - @Override - public void updateComponent() { - this.checkBox.setSelected(this.value); - this.checkBox.setBackground(bgStandard); - this.checkBox.setForeground(fgStandard); + override fun updateComponent() { + this.checkBox.setSelected(this.value!!) + this.checkBox.setBackground(bgStandard) + this.checkBox.setForeground(fgStandard) } } From 0e5cd249f42806e9d46cff1d16d49071a4c433fb Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 00:56:38 +0100 Subject: [PATCH 18/31] Revert "#2379 convert new class CheckBoxTableEntry to kotlin" This reverts commit c440e4ab12d508e28774c0b6c3f01e6badedc3b3. --- .../core/gui/comp/entry/CheckBoxTableEntry.kt | 101 ++++++++++-------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt index 83ac8e103..48f7e7a9a 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt @@ -1,15 +1,17 @@ -package core.gui.comp.entry +package core.gui.comp.entry; -import core.gui.comp.renderer.HODefaultTableCellRenderer -import java.awt.Color -import javax.swing.JCheckBox -import javax.swing.JComponent +import core.gui.comp.renderer.HODefaultTableCellRenderer; +import org.jetbrains.annotations.NotNull; -open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandard: Color?, bgStandard: Color?) : - IHOTableCellEntry { - private val fgStandard: Color? - private val bgStandard: Color? - private val checkBox: JCheckBox +import javax.swing.*; +import java.awt.*; + +public class CheckBoxTableEntry implements IHOTableCellEntry { + + private final Color fgStandard; + private final Color bgStandard; + private final JCheckBox checkBox; + private Boolean value; /** * Create table cell entry for booleans by check box @@ -18,31 +20,32 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @param fgStandard Color * @param bgStandard Color */ - init { - this.checkBox = JCheckBox() - this.checkBox.setSelected(value != null && value == true) - this.checkBox.setEnabled(isEnabled) - this.fgStandard = fgStandard - this.bgStandard = bgStandard - createComponent() + public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { + this.value = value; + this.checkBox = new JCheckBox(); + this.checkBox.setSelected(value != null && value); + this.checkBox.setEnabled(isEnabled); + this.fgStandard = fgStandard; + this.bgStandard = bgStandard; + createComponent(); } /** * Set value is called from HOTableModel * @param b boolean */ - open fun setValue(b: Boolean) { - this.value = b - this.checkBox.setSelected(b) - this.updateComponent() + public void setValue(boolean b) { + this.value = b; + this.checkBox.setSelected(b); + this.updateComponent(); } /** * Get value is called from HOTableModel * @return Boolean */ - fun getValue(): Boolean { - return this.value!! + public Boolean getValue() { + return this.value; } /** @@ -50,21 +53,24 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @param selected boolean * @return JComponent */ - override fun getComponent(selected: Boolean): JComponent { + @Override + public JComponent getComponent(boolean selected) { if (selected) { - this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG) + this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG); + } else { - this.checkBox.setBackground(bgStandard) + this.checkBox.setBackground(bgStandard); } - this.checkBox.setForeground(if (selected) HODefaultTableCellRenderer.SELECTION_FG else fgStandard) - return this.checkBox + this.checkBox.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); + return this.checkBox; } /** * Reset the checkbox */ - override fun clear() { - this.checkBox.setSelected(false) + @Override + public void clear() { + this.checkBox.setSelected(false); } /** @@ -72,16 +78,18 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @param obj the object to be compared. * @return int [-1,0,1] */ - override fun compareTo(obj: IHOTableCellEntry): Int { - if (obj is CheckBoxTableEntry) { - if (this.getValue() === obj.getValue()) { - return 0 - } else if (this.getValue()) { - return 1 + @Override + public int compareTo(@NotNull IHOTableCellEntry obj) { + if (obj instanceof CheckBoxTableEntry entry) { + if (this.getValue() == entry.getValue()){ + return 0; + } + else if (this.getValue()){ + return 1; } } // Not a checkbox - return -1 + return -1; } /** @@ -89,23 +97,26 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @param obj IHOTableCellEntry The other entry * @return int */ - override fun compareToThird(obj: IHOTableCellEntry): Int { - return this.compareTo(obj) + @Override + public int compareToThird(IHOTableCellEntry obj) { + return this.compareTo(obj); } /** * Update the component */ - override fun createComponent() { - updateComponent() + @Override + public void createComponent() { + updateComponent(); } /** * Update the component */ - override fun updateComponent() { - this.checkBox.setSelected(this.value!!) - this.checkBox.setBackground(bgStandard) - this.checkBox.setForeground(fgStandard) + @Override + public void updateComponent() { + this.checkBox.setSelected(this.value); + this.checkBox.setBackground(bgStandard); + this.checkBox.setForeground(fgStandard); } } From ed72aa7b10cfa5211d574294def31fd6cc870213 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 00:56:47 +0100 Subject: [PATCH 19/31] Revert "Rename .java to .kt" This reverts commit 788087d63a31e6f7297afbd901eb53b6e75802af. --- .../comp/entry/{CheckBoxTableEntry.kt => CheckBoxTableEntry.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/core/gui/comp/entry/{CheckBoxTableEntry.kt => CheckBoxTableEntry.java} (100%) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java similarity index 100% rename from src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt rename to src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java From 84cbcbbfd25bbaf69a2c5ece5cff5452ae7b5f02 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 01:07:12 +0100 Subject: [PATCH 20/31] #2379 LineupModule.storeUserSettings --- src/main/java/module/lineup/LineupModule.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/module/lineup/LineupModule.java b/src/main/java/module/lineup/LineupModule.java index 401370e7a..d396d13f8 100644 --- a/src/main/java/module/lineup/LineupModule.java +++ b/src/main/java/module/lineup/LineupModule.java @@ -37,6 +37,8 @@ public KeyStroke getKeyStroke() { @Override public void storeUserSettings() { - if (this.lineupMasterView != null) this.lineupMasterView.storeUserSettings(); + if (this.lineupMasterView != null) { + this.lineupMasterView.storeUserSettings(); + } } } From 1d68ecf791c6de3c4f106456bb18d1b4100a0abe Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 10:24:22 +0100 Subject: [PATCH 21/31] Rename .java to .kt --- .../comp/entry/{CheckBoxTableEntry.java => CheckBoxTableEntry.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/core/gui/comp/entry/{CheckBoxTableEntry.java => CheckBoxTableEntry.kt} (100%) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt similarity index 100% rename from src/main/java/core/gui/comp/entry/CheckBoxTableEntry.java rename to src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt From c7b9fc83d7313ab259e9155fd5d54baa16b7d40a Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 10:24:22 +0100 Subject: [PATCH 22/31] #2379 convert CheckBoxTableEntry to kotlin again --- .../core/gui/comp/entry/CheckBoxTableEntry.kt | 100 ++++++++---------- .../java/core/gui/comp/table/HOTableModel.kt | 6 +- .../core/gui/model/UserColumnFactory.java | 4 +- 3 files changed, 49 insertions(+), 61 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt index 48f7e7a9a..309a4bbb8 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt @@ -1,17 +1,15 @@ -package core.gui.comp.entry; +package core.gui.comp.entry -import core.gui.comp.renderer.HODefaultTableCellRenderer; -import org.jetbrains.annotations.NotNull; +import core.gui.comp.renderer.HODefaultTableCellRenderer +import java.awt.Color +import javax.swing.JCheckBox +import javax.swing.JComponent -import javax.swing.*; -import java.awt.*; - -public class CheckBoxTableEntry implements IHOTableCellEntry { - - private final Color fgStandard; - private final Color bgStandard; - private final JCheckBox checkBox; - private Boolean value; +open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandard: Color?, bgStandard: Color?) : + IHOTableCellEntry { + private val fgStandard: Color? + private val bgStandard: Color? + private val checkBox: JCheckBox = JCheckBox() /** * Create table cell entry for booleans by check box @@ -20,32 +18,30 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param fgStandard Color * @param bgStandard Color */ - public CheckBoxTableEntry(boolean isEnabled, Boolean value, Color fgStandard, Color bgStandard) { - this.value = value; - this.checkBox = new JCheckBox(); - this.checkBox.setSelected(value != null && value); - this.checkBox.setEnabled(isEnabled); - this.fgStandard = fgStandard; - this.bgStandard = bgStandard; - createComponent(); + init { + this.checkBox.setSelected(value != null && value == true) + this.checkBox.setEnabled(isEnabled) + this.fgStandard = fgStandard + this.bgStandard = bgStandard + createComponent() } /** * Set value is called from HOTableModel * @param b boolean */ - public void setValue(boolean b) { - this.value = b; - this.checkBox.setSelected(b); - this.updateComponent(); + open fun changeValue(b: Boolean?) { + this.value = b + this.checkBox.setSelected(b != null && b) + this.updateComponent() } /** * Get value is called from HOTableModel * @return Boolean */ - public Boolean getValue() { - return this.value; + fun getValue(): Boolean { + return this.value!! } /** @@ -53,24 +49,21 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param selected boolean * @return JComponent */ - @Override - public JComponent getComponent(boolean selected) { + override fun getComponent(selected: Boolean): JComponent { if (selected) { - this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG); - + this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG) } else { - this.checkBox.setBackground(bgStandard); + this.checkBox.setBackground(bgStandard) } - this.checkBox.setForeground(selected ? HODefaultTableCellRenderer.SELECTION_FG : fgStandard); - return this.checkBox; + this.checkBox.setForeground(if (selected) HODefaultTableCellRenderer.SELECTION_FG else fgStandard) + return this.checkBox } /** * Reset the checkbox */ - @Override - public void clear() { - this.checkBox.setSelected(false); + override fun clear() { + this.checkBox.setSelected(false) } /** @@ -78,18 +71,16 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param obj the object to be compared. * @return int [-1,0,1] */ - @Override - public int compareTo(@NotNull IHOTableCellEntry obj) { - if (obj instanceof CheckBoxTableEntry entry) { - if (this.getValue() == entry.getValue()){ - return 0; - } - else if (this.getValue()){ - return 1; + override fun compareTo(obj: IHOTableCellEntry): Int { + if (obj is CheckBoxTableEntry) { + if (this.getValue() == obj.getValue()) { + return 0 + } else if (this.getValue()) { + return 1 } } // Not a checkbox - return -1; + return -1 } /** @@ -97,26 +88,23 @@ public class CheckBoxTableEntry implements IHOTableCellEntry { * @param obj IHOTableCellEntry The other entry * @return int */ - @Override - public int compareToThird(IHOTableCellEntry obj) { - return this.compareTo(obj); + override fun compareToThird(obj: IHOTableCellEntry): Int { + return this.compareTo(obj) } /** * Update the component */ - @Override - public void createComponent() { - updateComponent(); + override fun createComponent() { + updateComponent() } /** * Update the component */ - @Override - public void updateComponent() { - this.checkBox.setSelected(this.value); - this.checkBox.setBackground(bgStandard); - this.checkBox.setForeground(fgStandard); + override fun updateComponent() { + this.checkBox.setSelected(this.value!!) + this.checkBox.setBackground(bgStandard) + this.checkBox.setForeground(fgStandard) } } diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index 614a844c5..d95c70e44 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -197,8 +197,8 @@ abstract class HOTableModel protected constructor( override fun setValueAt(value: Any, row: Int, column: Int) { if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size) { val ret = m_clData!![row][column] - if (ret is CheckBoxTableEntry) { - ret.value = value as Boolean? + if (ret is CheckBoxTableEntry && value is Boolean ) { + ret.changeValue(value) } m_clData!![row][column] = value } @@ -448,4 +448,4 @@ abstract class HOTableModel protected constructor( if (tables.isNotEmpty()) return tables[0] return null } -} \ No newline at end of file +} diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index f087dfb79..f64c87d27 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -966,9 +966,9 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { public IHOTableCellEntry getTableEntry(@NotNull Player player) { return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD) { @Override - public void setValue(boolean value) { + public void changeValue(Boolean value) { player.setCanBeSelectedByAssistant(value); - super.setValue(value); + super.changeValue(value); } }; } From 9950b810d2dd214bf92fb27fa6b2cf8264afa208 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 10:48:11 +0100 Subject: [PATCH 23/31] #2379 Review --- src/main/java/core/gui/model/UserColumnController.java | 8 +++----- src/main/java/core/model/player/Player.java | 10 +++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/core/gui/model/UserColumnController.java b/src/main/java/core/gui/model/UserColumnController.java index a5f0b8853..eed7e7dfa 100644 --- a/src/main/java/core/gui/model/UserColumnController.java +++ b/src/main/java/core/gui/model/UserColumnController.java @@ -102,14 +102,13 @@ public enum ColumnModelId { /** - * constructor - * + * Constructor */ private UserColumnController(){ } /** - * singelton + * Singleton * @return UserColumnController */ public static UserColumnController instance(){ @@ -117,8 +116,7 @@ public static UserColumnController instance(){ } /** - * load all models from db - * + * Load all models from db */ public void load() { final DBManager dbManager = DBManager.instance(); diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index 4853123e6..7054d179a 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -1227,13 +1227,17 @@ public int getPlaymakingSkill() { } /** - * set whether that player can be selected by the assistant + * Set whether that player can be selected by the assistant * The value is stored to the database * @param flag boolean */ public void setCanBeSelectedByAssistant(boolean flag) { - if (flag == canBeSelectedByAssistant) return; // nothing changed - if (this.isExternallyRecruitedCoach()) flag = false; + if (flag == canBeSelectedByAssistant) { + return; // Nothing changed + } + if (this.isExternallyRecruitedCoach()) { + flag = false; + } getNotes().setEligibleToPlay(flag); DBManager.instance().storePlayerNotes(notes); canBeSelectedByAssistant = flag; From b8a9e46d8428e2e1796edf199353494aa61371fa Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 24 Jan 2026 10:59:57 +0100 Subject: [PATCH 24/31] #2379 Format UserColumn.java --- .../java/core/gui/comp/table/UserColumn.java | 390 ++++++++++-------- 1 file changed, 211 insertions(+), 179 deletions(-) diff --git a/src/main/java/core/gui/comp/table/UserColumn.java b/src/main/java/core/gui/comp/table/UserColumn.java index a39091997..83afef647 100644 --- a/src/main/java/core/gui/comp/table/UserColumn.java +++ b/src/main/java/core/gui/comp/table/UserColumn.java @@ -10,189 +10,221 @@ */ public abstract class UserColumn { - /** unique column id **/ - protected int id; - - /** columnName properties representation, not display!! **/ - protected String columnName; - - /** tooltip properties representation **/ - protected String tooltip; - - /** minimum width of the column **/ - protected int minWidth; - - /** preferred width of the column **/ - protected int preferredWidth; - - /** index of the column in the table **/ - protected int index = 0; - - /** if a column is shown in the table. Only displayed columns are saved in db. **/ - protected boolean display = false; + /** + * unique column id + **/ + protected int id; + + /** + * columnName properties representation, not display!! + **/ + protected String columnName; + + /** + * tooltip properties representation + **/ + protected String tooltip; + + /** + * minimum width of the column + **/ + protected int minWidth; + + /** + * preferred width of the column + **/ + protected int preferredWidth; + + /** + * index of the column in the table + **/ + protected int index = 0; + + /** + * if a column is shown in the table. Only displayed columns are saved in db. + **/ + protected boolean display = false; protected boolean translateColumnName = true; protected boolean translateColumnTooltip = true; - /** - * Sort order of the column - */ - SortOrder sortOrder; - - /** - * Sort priority - * Defines the order of the sort keys if more than one column are sorted - */ - Integer sortPriority; - - /** - * Constructor of an user column - * @param id column identifier has to be unique in one table - * @param name Column name is displayed in the column header - * @param tooltip Column header tool tip - */ - protected UserColumn(int id,String name, String tooltip){ - this.id = id; - columnName = name; - this.tooltip = tooltip; - } - - /** - * Constructor of an user column - * @param id column identifier has to be unique in one table - * @param name Column name and tool tip - */ - protected UserColumn(int id,String name){ - this(id,name,name); - } - - /** - * constructor is used by AbstractTable - */ - public UserColumn(){} - - /** - * returns the language dependency name of the column - * @return String - */ - public final String getColumnName() { + /** + * Sort order of the column + */ + SortOrder sortOrder; + + /** + * Sort priority + * Defines the order of the sort keys if more than one column are sorted + */ + Integer sortPriority; + + /** + * Constructor of an user column + * + * @param id column identifier has to be unique in one table + * @param name Column name is displayed in the column header + * @param tooltip Column header tool tip + */ + protected UserColumn(int id, String name, String tooltip) { + this.id = id; + columnName = name; + this.tooltip = tooltip; + } + + /** + * Constructor of an user column + * + * @param id column identifier has to be unique in one table + * @param name Column name and tool tip + */ + protected UserColumn(int id, String name) { + this(id, name, name); + } + + /** + * constructor is used by AbstractTable + */ + public UserColumn() { + } + + /** + * returns the language dependency name of the column + * + * @return String + */ + public final String getColumnName() { return translateColumnName ? TranslationFacility.tr(columnName) : columnName; } - - /** - * Return id - * @return int - */ - public final int getId() { - return id; - } - - /** - * returns the language dependency tooltip of the column - * @return String - */ - public final String getTooltip() { - return (this.translateColumnTooltip)?TranslationFacility.tr(tooltip):tooltip; - } - - /** - * Should a column be shown - * @return boolean - */ - public boolean isDisplay() { - return display; - } - - /** - * set a column to be showed - * @param display boolean - */ - public final void setDisplay(boolean display) { - this.display = display; - if (!display) { - index = 0; - sortPriority = null; - sortOrder = null; - } - } - - /** - * return the current index of column - * only actual if user don´t move the column !! - * @return int - */ - public final int getIndex() { - return index; - } - - /** - * set index - * if columnModel should be saved index will set, or column is loaded - * @param index int - */ - public final void setIndex(int index) { - this.index = index; - } - - /** - * String representation - * use in UserColumnsPanel in OptionsPanel - */ - @Override - public String toString(){ - return getTooltip(); - } - - /** - * Some columns must be displayed, so some columns are not editable in options dialog - * @return boolean - */ - public boolean canBeDisabled(){ - return true; - } - - /** - * Column is not visible (width is reduced to zero). - * @return boolean - */ - public boolean isHidden(){return false;} - - /** - * set minWidth and prefWidth in the TableColumn - * @param column TableColumn - */ - public void setSize(TableColumn column){ - column.setMinWidth(minWidth); - column.setPreferredWidth(preferredWidth); - } - - /** - * set preferredWidth for saving to DB - * @param width int - */ - public void setPreferredWidth(int width){ - preferredWidth = width; - } - - public int getPreferredWidth(){ - return preferredWidth; - } - - public Integer getSortPriority() { - return sortPriority; - } - - public SortOrder getSortOrder() { - return sortOrder; - } - - public void setSortPriority(Integer sortPriority) { - this.sortPriority = sortPriority; - } - - public void setSortOrder(SortOrder sortOrder) { - this.sortOrder = sortOrder; - } - - public boolean isEditable() {return false;} + + /** + * Return id + * + * @return int + */ + public final int getId() { + return id; + } + + /** + * returns the language dependency tooltip of the column + * + * @return String + */ + public final String getTooltip() { + return (this.translateColumnTooltip) ? TranslationFacility.tr(tooltip) : tooltip; + } + + /** + * Should a column be shown + * + * @return boolean + */ + public boolean isDisplay() { + return display; + } + + /** + * set a column to be showed + * + * @param display boolean + */ + public final void setDisplay(boolean display) { + this.display = display; + if (!display) { + index = 0; + sortPriority = null; + sortOrder = null; + } + } + + /** + * return the current index of column + * only actual if user don´t move the column !! + * + * @return int + */ + public final int getIndex() { + return index; + } + + /** + * set index + * if columnModel should be saved index will set, or column is loaded + * + * @param index int + */ + public final void setIndex(int index) { + this.index = index; + } + + /** + * String representation + * use in UserColumnsPanel in OptionsPanel + */ + @Override + public String toString() { + return getTooltip(); + } + + /** + * Some columns must be displayed, so some columns are not editable in options dialog + * + * @return boolean + */ + public boolean canBeDisabled() { + return true; + } + + /** + * Column is not visible (width is reduced to zero). + * + * @return boolean + */ + public boolean isHidden() { + return false; + } + + /** + * set minWidth and prefWidth in the TableColumn + * + * @param column TableColumn + */ + public void setSize(TableColumn column) { + column.setMinWidth(minWidth); + column.setPreferredWidth(preferredWidth); + } + + /** + * set preferredWidth for saving to DB + * + * @param width int + */ + public void setPreferredWidth(int width) { + preferredWidth = width; + } + + public int getPreferredWidth() { + return preferredWidth; + } + + public Integer getSortPriority() { + return sortPriority; + } + + public SortOrder getSortOrder() { + return sortOrder; + } + + public void setSortPriority(Integer sortPriority) { + this.sortPriority = sortPriority; + } + + public void setSortOrder(SortOrder sortOrder) { + this.sortOrder = sortOrder; + } + + public boolean isEditable() { + return false; + } } From 4b4d3340e971ce584e33393550dc5b363527836b Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sun, 25 Jan 2026 11:51:49 +0100 Subject: [PATCH 25/31] #2379 formatting --- src/main/java/core/gui/comp/table/HOTableModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/core/gui/comp/table/HOTableModel.kt b/src/main/java/core/gui/comp/table/HOTableModel.kt index d95c70e44..e90814d1c 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.kt +++ b/src/main/java/core/gui/comp/table/HOTableModel.kt @@ -197,7 +197,7 @@ abstract class HOTableModel protected constructor( override fun setValueAt(value: Any, row: Int, column: Int) { if (m_clData != null && m_clData!!.size > row && row > -1 && column > -1 && column < m_clData!![row].size) { val ret = m_clData!![row][column] - if (ret is CheckBoxTableEntry && value is Boolean ) { + if (ret is CheckBoxTableEntry && value is Boolean) { ret.changeValue(value) } m_clData!![row][column] = value From d64d8a83e1474a1590c450dc7ef3728b0ce378e8 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sun, 25 Jan 2026 19:12:34 +0100 Subject: [PATCH 26/31] #2379 review --- .../gui/comp/table/PlayerCheckBoxColumn.java | 16 ++++++++-------- .../java/module/lineup/LineupPlayersTable.java | 0 2 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 src/main/java/module/lineup/LineupPlayersTable.java diff --git a/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java b/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java index 8b58e95e6..9d3713673 100644 --- a/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java +++ b/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java @@ -7,13 +7,13 @@ public class PlayerCheckBoxColumn extends PlayerColumn { - public PlayerCheckBoxColumn(int id, String name, String tooltip, int minWidth){ - super(id,name,tooltip); - this.minWidth = minWidth; - preferredWidth = minWidth; - } + public PlayerCheckBoxColumn(int id, String name, String tooltip, int minWidth) { + super(id, name, tooltip); + this.minWidth = minWidth; + preferredWidth = minWidth; + } - public IHOTableCellEntry getTableEntry(@NotNull Player player) { - return null; - } + public IHOTableCellEntry getTableEntry(@NotNull Player player) { + return null; + } } diff --git a/src/main/java/module/lineup/LineupPlayersTable.java b/src/main/java/module/lineup/LineupPlayersTable.java deleted file mode 100644 index e69de29bb..000000000 From befacfbd6cab98c05b759d9d5b5adbf58037cb61 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sun, 25 Jan 2026 23:34:17 +0100 Subject: [PATCH 27/31] #2379 Fix CheckBoxTableEntry null handling --- .../core/gui/comp/entry/CheckBoxTableEntry.kt | 6 ++--- .../gui/comp/entry/CheckBoxTableEntryTest.kt | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt index 309a4bbb8..ba02a3c09 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt @@ -41,7 +41,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @return Boolean */ fun getValue(): Boolean { - return this.value!! + return value != null && value == true } /** @@ -75,7 +75,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar if (obj is CheckBoxTableEntry) { if (this.getValue() == obj.getValue()) { return 0 - } else if (this.getValue()) { + } else if (this.getValue() || this.value == false && obj.value == null) { return 1 } } @@ -103,7 +103,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * Update the component */ override fun updateComponent() { - this.checkBox.setSelected(this.value!!) + this.checkBox.setSelected(getValue()) this.checkBox.setBackground(bgStandard) this.checkBox.setForeground(fgStandard) } diff --git a/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt b/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt new file mode 100644 index 000000000..7feee8ef3 --- /dev/null +++ b/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt @@ -0,0 +1,23 @@ +package core.gui.comp.entry + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import java.awt.Color + +internal class CheckBoxTableEntryTest { + @Test + fun testCheckBoxEntryCompareTo() { + + val checkBoxTableEntry = CheckBoxTableEntry(true, true, Color.RED, Color.BLUE) + val checkBoxTableEntryTrue = CheckBoxTableEntry(true, true, Color.RED, Color.BLUE) + val checkBoxTableEntryFalse = CheckBoxTableEntry(true, false, Color.BLUE, Color.RED) + val checkBoxTableEntryNull = CheckBoxTableEntry(true, null, Color.RED, Color.BLUE) + + Assertions.assertEquals(0, checkBoxTableEntryTrue.compareTo(checkBoxTableEntry)) + Assertions.assertEquals(1, checkBoxTableEntryTrue.compareTo(checkBoxTableEntryFalse)) + Assertions.assertEquals(1, checkBoxTableEntryTrue.compareTo(checkBoxTableEntryNull)) + Assertions.assertEquals(0, checkBoxTableEntryFalse.compareTo(checkBoxTableEntryNull)) + Assertions.assertEquals(-1, checkBoxTableEntryNull.compareTo(checkBoxTableEntry)) + Assertions.assertEquals(-1, checkBoxTableEntryFalse.compareTo(checkBoxTableEntry)) + } +} From 868beba353a6c09f38dadf3ab942f04223f38516 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Mon, 26 Jan 2026 19:20:48 +0100 Subject: [PATCH 28/31] #2379 review --- .../core/gui/comp/entry/CheckBoxTableEntry.kt | 17 ++++++++++------- .../gui/comp/table/PlayerCheckBoxColumn.java | 2 +- .../gui/comp/entry/CheckBoxTableEntryTest.kt | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt index ba02a3c09..09f00401b 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt @@ -19,7 +19,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @param bgStandard Color */ init { - this.checkBox.setSelected(value != null && value == true) + this.checkBox.setSelected(value == true) this.checkBox.setEnabled(isEnabled) this.fgStandard = fgStandard this.bgStandard = bgStandard @@ -32,7 +32,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar */ open fun changeValue(b: Boolean?) { this.value = b - this.checkBox.setSelected(b != null && b) + this.checkBox.setSelected(b == true) this.updateComponent() } @@ -41,7 +41,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @return Boolean */ fun getValue(): Boolean { - return value != null && value == true + return value == true } /** @@ -52,10 +52,11 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar override fun getComponent(selected: Boolean): JComponent { if (selected) { this.checkBox.setBackground(HODefaultTableCellRenderer.SELECTION_BG) + this.checkBox.setForeground(HODefaultTableCellRenderer.SELECTION_FG) } else { this.checkBox.setBackground(bgStandard) + this.checkBox.setForeground(fgStandard) } - this.checkBox.setForeground(if (selected) HODefaultTableCellRenderer.SELECTION_FG else fgStandard) return this.checkBox } @@ -63,19 +64,21 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * Reset the checkbox */ override fun clear() { + this.value = false this.checkBox.setSelected(false) } /** - * Compare with other cell entry + * Compare with other cell entry. + * Descending order is true, false, null. * @param obj the object to be compared. * @return int [-1,0,1] */ override fun compareTo(obj: IHOTableCellEntry): Int { if (obj is CheckBoxTableEntry) { - if (this.getValue() == obj.getValue()) { + if (this.value == obj.value) { return 0 - } else if (this.getValue() || this.value == false && obj.value == null) { + } else if (this.value == true || this.value == false && obj.value == null) { return 1 } } diff --git a/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java b/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java index 9d3713673..4002c7b71 100644 --- a/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java +++ b/src/main/java/core/gui/comp/table/PlayerCheckBoxColumn.java @@ -10,7 +10,7 @@ public class PlayerCheckBoxColumn extends PlayerColumn { public PlayerCheckBoxColumn(int id, String name, String tooltip, int minWidth) { super(id, name, tooltip); this.minWidth = minWidth; - preferredWidth = minWidth; + this.preferredWidth = minWidth; } public IHOTableCellEntry getTableEntry(@NotNull Player player) { diff --git a/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt b/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt index 7feee8ef3..bff8872e8 100644 --- a/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt +++ b/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt @@ -16,8 +16,8 @@ internal class CheckBoxTableEntryTest { Assertions.assertEquals(0, checkBoxTableEntryTrue.compareTo(checkBoxTableEntry)) Assertions.assertEquals(1, checkBoxTableEntryTrue.compareTo(checkBoxTableEntryFalse)) Assertions.assertEquals(1, checkBoxTableEntryTrue.compareTo(checkBoxTableEntryNull)) - Assertions.assertEquals(0, checkBoxTableEntryFalse.compareTo(checkBoxTableEntryNull)) + Assertions.assertEquals(1, checkBoxTableEntryFalse.compareTo(checkBoxTableEntryNull)) + Assertions.assertEquals(-1, checkBoxTableEntryNull.compareTo(checkBoxTableEntryFalse)) Assertions.assertEquals(-1, checkBoxTableEntryNull.compareTo(checkBoxTableEntry)) - Assertions.assertEquals(-1, checkBoxTableEntryFalse.compareTo(checkBoxTableEntry)) } } From d47fb216d1d1cc6cc4edcb18edfe96688ac7e21e Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Tue, 27 Jan 2026 18:19:24 +0100 Subject: [PATCH 29/31] #2379 CheckBoxTableEntry.value not null --- .../core/gui/comp/entry/CheckBoxTableEntry.kt | 23 ++++--------------- .../core/gui/model/UserColumnFactory.java | 4 ++-- src/main/java/core/model/player/Player.java | 2 +- .../gui/comp/entry/CheckBoxTableEntryTest.kt | 7 ++---- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt index 09f00401b..9009bf56a 100644 --- a/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt +++ b/src/main/java/core/gui/comp/entry/CheckBoxTableEntry.kt @@ -5,7 +5,7 @@ import java.awt.Color import javax.swing.JCheckBox import javax.swing.JComponent -open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandard: Color?, bgStandard: Color?) : +open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean, fgStandard: Color?, bgStandard: Color?) : IHOTableCellEntry { private val fgStandard: Color? private val bgStandard: Color? @@ -19,7 +19,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * @param bgStandard Color */ init { - this.checkBox.setSelected(value == true) + this.checkBox.setSelected(value) this.checkBox.setEnabled(isEnabled) this.fgStandard = fgStandard this.bgStandard = bgStandard @@ -30,20 +30,11 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * Set value is called from HOTableModel * @param b boolean */ - open fun changeValue(b: Boolean?) { + open fun changeValue(b: Boolean) { this.value = b - this.checkBox.setSelected(b == true) this.updateComponent() } - /** - * Get value is called from HOTableModel - * @return Boolean - */ - fun getValue(): Boolean { - return value == true - } - /** * Return the checkbox component * @param selected boolean @@ -76,11 +67,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar */ override fun compareTo(obj: IHOTableCellEntry): Int { if (obj is CheckBoxTableEntry) { - if (this.value == obj.value) { - return 0 - } else if (this.value == true || this.value == false && obj.value == null) { - return 1 - } + return this.value.compareTo(obj.value) } // Not a checkbox return -1 @@ -106,7 +93,7 @@ open class CheckBoxTableEntry(isEnabled: Boolean, var value: Boolean?, fgStandar * Update the component */ override fun updateComponent() { - this.checkBox.setSelected(getValue()) + this.checkBox.setSelected(value) this.checkBox.setBackground(bgStandard) this.checkBox.setForeground(fgStandard) } diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index f64c87d27..364d69671 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -964,9 +964,9 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { playerAdditionalArray[31] = new PlayerCheckBoxColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) { @Override public IHOTableCellEntry getTableEntry(@NotNull Player player) { - return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD) { + return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant() == true, ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD) { @Override - public void changeValue(Boolean value) { + public void changeValue(boolean value) { player.setCanBeSelectedByAssistant(value); super.changeValue(value); } diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index 7054d179a..6b9d2d41a 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -1249,7 +1249,7 @@ public void setCanBeSelectedByAssistant(boolean flag) { * Get whether that player can be selected by the assistant * @return Boolean */ - public Boolean getCanBeSelectedByAssistant() { + public boolean getCanBeSelectedByAssistant() { if (canBeSelectedByAssistant == null) { canBeSelectedByAssistant = !this.isExternallyRecruitedCoach() && getNotes().isEligibleToPlay(); } diff --git a/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt b/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt index bff8872e8..655faec71 100644 --- a/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt +++ b/src/test/java/core/gui/comp/entry/CheckBoxTableEntryTest.kt @@ -11,13 +11,10 @@ internal class CheckBoxTableEntryTest { val checkBoxTableEntry = CheckBoxTableEntry(true, true, Color.RED, Color.BLUE) val checkBoxTableEntryTrue = CheckBoxTableEntry(true, true, Color.RED, Color.BLUE) val checkBoxTableEntryFalse = CheckBoxTableEntry(true, false, Color.BLUE, Color.RED) - val checkBoxTableEntryNull = CheckBoxTableEntry(true, null, Color.RED, Color.BLUE) Assertions.assertEquals(0, checkBoxTableEntryTrue.compareTo(checkBoxTableEntry)) + Assertions.assertEquals(0, checkBoxTableEntryFalse.compareTo(checkBoxTableEntryFalse)) Assertions.assertEquals(1, checkBoxTableEntryTrue.compareTo(checkBoxTableEntryFalse)) - Assertions.assertEquals(1, checkBoxTableEntryTrue.compareTo(checkBoxTableEntryNull)) - Assertions.assertEquals(1, checkBoxTableEntryFalse.compareTo(checkBoxTableEntryNull)) - Assertions.assertEquals(-1, checkBoxTableEntryNull.compareTo(checkBoxTableEntryFalse)) - Assertions.assertEquals(-1, checkBoxTableEntryNull.compareTo(checkBoxTableEntry)) + Assertions.assertEquals(-1, checkBoxTableEntryFalse.compareTo(checkBoxTableEntryTrue)) } } From 6bf37955ba093fab18721994987505cba59eda0f Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Tue, 27 Jan 2026 18:20:21 +0100 Subject: [PATCH 30/31] #2379 review --- src/main/java/core/gui/model/UserColumnFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/core/gui/model/UserColumnFactory.java b/src/main/java/core/gui/model/UserColumnFactory.java index 364d69671..f4c9a94f4 100644 --- a/src/main/java/core/gui/model/UserColumnFactory.java +++ b/src/main/java/core/gui/model/UserColumnFactory.java @@ -964,7 +964,7 @@ public IHOTableCellEntry getTableEntry(Player player, Player playerCompare) { playerAdditionalArray[31] = new PlayerCheckBoxColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28) { @Override public IHOTableCellEntry getTableEntry(@NotNull Player player) { - return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant() == true, ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD) { + return new CheckBoxTableEntry(!player.isExternallyRecruitedCoach(), player.getCanBeSelectedByAssistant(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD) { @Override public void changeValue(boolean value) { player.setCanBeSelectedByAssistant(value); From 72c34d8fedc650983a4e169aea3bb0fd5e1d14c1 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Tue, 27 Jan 2026 22:06:32 +0100 Subject: [PATCH 31/31] #2379 Fix PlayerOverviewPanel constructor --- src/main/java/module/playeroverview/PlayerOverviewPanel.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/module/playeroverview/PlayerOverviewPanel.java b/src/main/java/module/playeroverview/PlayerOverviewPanel.java index 6423b4960..a84e13dc8 100644 --- a/src/main/java/module/playeroverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playeroverview/PlayerOverviewPanel.java @@ -36,7 +36,9 @@ public PlayerOverviewPanel() { initComponents(); RefreshManager.instance().registerRefreshable(this); this.playerOverviewTable.addListSelectionListener(e -> selectPlayer()); - this.playerOverviewTable.setRowSelectionInterval(0, 0); + if (this.playerOverviewTable.getRowCount() > 0) { + this.playerOverviewTable.setRowSelectionInterval(0, 0); + } } /**