Skip to content

Commit

Permalink
Fix HOTableModel.moveColumn illegal argument exception (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrenk authored Nov 8, 2024
1 parent 5ea0938 commit 40220fc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/core/gui/comp/table/HOTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import core.gui.comp.renderer.HODefaultTableCellRenderer;
import core.gui.model.UserColumnController;
import core.model.TranslationFacility;
import core.util.HOLogger;

import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
Expand Down Expand Up @@ -271,9 +273,14 @@ private void moveColumn(JTable table, UserColumn userColumn) {
if (table instanceof FixedColumnsTable fixedColumnsTable) {
var targetIndex = userColumn.getIndex() - fixedColumnsTable.getFixedColumnsCount();
if (targetIndex > 0) {
var index = fixedColumnsTable.getColumnModel().getColumnIndex(userColumn.getId());
if (index != targetIndex) {
table.moveColumn(index, targetIndex);
try {
var index = fixedColumnsTable.getColumnModel().getColumnIndex(userColumn.getId());
if (index != targetIndex) {
table.moveColumn(index, targetIndex);
}
}
catch (IllegalArgumentException e) {
HOLogger.instance().info(this.getClass(), "Cannot move column to stored index " + userColumn.id + " " + userColumn.getColumnName() + " index=" + userColumn.getIndex() + ": " + e.getMessage());
}
}
} else {
Expand Down

0 comments on commit 40220fc

Please sign in to comment.