Skip to content

Commit

Permalink
Fix HOTableModel.setValueAt
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrenk committed Nov 1, 2024
1 parent b26ed59 commit f590c1d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
8 changes: 6 additions & 2 deletions src/main/java/core/gui/comp/table/HOTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public final String getColumnName(int columnIndex) {
@Override
public void setValueAt(Object value, int row, int column) {
m_clData[row][column] = value;
fireTableCellUpdated(row,column);
fireTableCellUpdated(table.convertRowIndexToView(row),table.convertColumnIndexToView(column));
}

/**
Expand Down Expand Up @@ -313,8 +313,12 @@ private boolean setUserColumnSettings(JTable table) {
return changed;
}

/**
* User can disable columns
* @return
*/
public boolean userCanDisableColumns() {
return false;
return true;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/core/gui/model/PlayerAnalysisModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ public PlayerAnalysisModel(UserColumnController.ColumnModelId id, int instance){
this.instance = instance;
initialize();
}
@Override
public boolean userCanDisableColumns(){
return !DBManager.instance().isFirstStart();
}

private void initialize() {
columns = new UserColumn[65];
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/core/gui/model/PlayerOverviewTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ protected PlayerOverviewTableModel(UserColumnController.ColumnModelId id, String
initialize();
}

@Override
public boolean userCanDisableColumns() {
return !DBManager.instance().isFirstStart();
}

/**
* initialize all columns.
*/
Expand Down Expand Up @@ -93,6 +88,11 @@ private void initialize() {
columns[63] = new BooleanColumn(UserColumnFactory.AUTO_LINEUP, " ", "AutoAufstellung", 28);
}

@Override
public final boolean isCellEditable(int row, int col) {
return getValueAt(row, col) instanceof Boolean;
}

public int getRowIndexOfPlayer(int playerId){
var modelIndex = getPlayerIndex(playerId);
if (modelIndex > -1){
Expand Down Expand Up @@ -208,7 +208,7 @@ protected void initData() {
}

/**
* Passt nur die Aufstellung an
* Initializes the lineup only
*/
public void reInitData() {
UserColumn [] tmpDisplayedColumns = getDisplayedColumns();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/option/UserColumnsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void initComponents() {
}

/**
* @return
* @return JPanel
*/
private JPanel getTopPanel() {
JPanel panel = new ImagePanel();
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/module/lineup/LineupPlayersTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import core.net.HattrickLink;
import module.playerOverview.PlayerTable;
import org.jetbrains.annotations.Nullable;

import javax.swing.event.TableModelListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

Expand Down Expand Up @@ -77,7 +75,7 @@ private void resetPlayers() {
}

private void initListeners() {
this.tableModel.addTableModelListener(e -> {
this.getTableModel().addTableModelListener(e -> {
var r = e.getFirstRow();
var c = e.getColumn();
var player = tableModel.getPlayerAtRow(r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import core.gui.model.UserColumnController;
import core.gui.theme.HOIconName;
import core.gui.theme.ThemeManager;
import core.model.HOVerwaltung;
import core.model.TranslationFacility;
import core.model.enums.MatchType;
import core.model.match.Matchdetails;
Expand Down Expand Up @@ -328,9 +327,4 @@ private String formatTacticColumn(TeamLineup lineup) {
}
return str.toString();
}

@Override
public boolean userCanDisableColumns() {
return true;
}
}
8 changes: 4 additions & 4 deletions src/main/java/module/teamAnalyzer/ui/RecapUserColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public IHOTableEntry getTableEntry(TeamLineup lineup) {
return new ColorLabelEntry(lineup.getName(), ColorLabelEntry.FG_STANDARD, ColorLabelEntry.BG_STANDARD, SwingConstants.LEFT);
}

@Override
public boolean canBeDisabled() {
return true;
}
// @Override
// public boolean canBeDisabled() {
// return true;
// }

}

0 comments on commit f590c1d

Please sign in to comment.