X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Fdistance%2FDistanceTableModel.java;h=2c1d83d1337b56af1a8ab1fbad0a3cc938b3d5a2;hp=faa059ea4b1bb2ada4ce6340b30bc6014a9ce65a;hb=a6197ddcaac11c0b943183da7d46169742d024af;hpb=88f2c3647ed9e055090484f01a959d4581f85e7d diff --git a/tim/prune/function/distance/DistanceTableModel.java b/tim/prune/function/distance/DistanceTableModel.java index faa059e..2c1d83d 100644 --- a/tim/prune/function/distance/DistanceTableModel.java +++ b/tim/prune/function/distance/DistanceTableModel.java @@ -17,6 +17,8 @@ public class DistanceTableModel extends GenericTableModel private static final String _toColLabel = I18nManager.getText("dialog.distances.column.to"); /** Column heading (depends on metric/imperial settings) */ private String _distanceLabel = null; + /** Previous distance units */ + private Unit _previousDistUnit = null; /** * @return column count @@ -69,6 +71,9 @@ public class DistanceTableModel extends GenericTableModel Unit distUnit = Config.getUnitSet().getDistanceUnit(); _distanceLabel = I18nManager.getText("fieldname.distance") + " (" + I18nManager.getText(distUnit.getShortnameKey()) + ")"; + final boolean distUnitsChanged = (distUnit != _previousDistUnit); + _previousDistUnit = distUnit; + // Initialize array of distances int numRows = getRowCount(); if (_distances == null || _distances.length != numRows) { @@ -84,7 +89,12 @@ public class DistanceTableModel extends GenericTableModel _distances[i] = Distance.convertRadiansToDistance(rads); } } - // Let table know that it has to refresh data (and might as well refresh column headings too) - fireTableStructureChanged(); + // Let table know that it has to refresh data, and maybe the whole table too + if (distUnitsChanged) { + fireTableStructureChanged(); + } + else { + fireTableDataChanged(); + } } }