From 96630dc379ecbfd00692e98b50bb5d9e881146f6 Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Fri, 8 Nov 2024 19:01:10 +0100 Subject: [PATCH] Fix HOTableModel.moveColumn illegal argument exception --- src/main/java/core/gui/comp/table/HOTableModel.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/core/gui/comp/table/HOTableModel.java b/src/main/java/core/gui/comp/table/HOTableModel.java index 9c1e9d4a0..092c70eb8 100644 --- a/src/main/java/core/gui/comp/table/HOTableModel.java +++ b/src/main/java/core/gui/comp/table/HOTableModel.java @@ -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; @@ -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 {