From a10971827ceb21e4c6b4110b0873e631e5cfd889 Mon Sep 17 00:00:00 2001
From: Tim Vaughan <tgvaughan@gmail.com>
Date: Sun, 20 Sep 2015 13:04:29 +1200
Subject: [PATCH] Added error reporting to logcombiner: closes #422.

---
 src/beast/app/tools/LogCombiner.java       |  4 ++++
 src/beast/app/tools/LogCombinerDialog.java | 12 ++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/beast/app/tools/LogCombiner.java b/src/beast/app/tools/LogCombiner.java
index f7bcb5d38..43ec931a6 100644
--- a/src/beast/app/tools/LogCombiner.java
+++ b/src/beast/app/tools/LogCombiner.java
@@ -59,6 +59,10 @@ private void parseArgs(String[] args) throws Exception {
                         i += 2;
                     } else if (args[i].equals("-b") || args[i].equals("-burnin") || args[i].equals("--burnin")) {
                         m_nBurninPercentage = Integer.parseInt(args[i + 1]);
+                        if (m_nBurninPercentage < 0 || m_nBurninPercentage > 100) {
+                            System.err.println("Error: Burn-in percentage must be between 0 and 100.");
+                            System.exit(1);
+                        }
                         i += 2;
                     } else if (args[i].equals("-n")) {
                         m_nParticles = Integer.parseInt(args[i + 1]);
diff --git a/src/beast/app/tools/LogCombinerDialog.java b/src/beast/app/tools/LogCombinerDialog.java
index 2d5961aca..99d54b20b 100644
--- a/src/beast/app/tools/LogCombinerDialog.java
+++ b/src/beast/app/tools/LogCombinerDialog.java
@@ -95,7 +95,9 @@ public LogCombinerDialog(final JFrame frame, String titleString, Icon icon) {
         filesTable.getColumnModel().getColumn(0).setPreferredWidth(120);
         filesTable.getColumnModel().getColumn(0).setPreferredWidth(80);
 
-        TableEditorStopper.ensureEditingStopWhenTableLosesFocus(filesTable);
+        // This causes superfluous TabelModel.setValue events to fire.
+        // Is this still needed?  I guess we'll see...
+        //TableEditorStopper.ensureEditingStopWhenTableLosesFocus(filesTable);
 
         filesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
             public void valueChanged(ListSelectionEvent evt) {
@@ -362,7 +364,13 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
         public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
             FileInfo fileInfo = files.get(rowIndex);
             if (columnIndex == 1) {
-                fileInfo.burnin = (Integer) aValue;
+                int newBurnin = (int)aValue;
+                if (newBurnin<0 || newBurnin>100)
+                    JOptionPane.showMessageDialog(frame,
+                            "Burn-in percentage must be between 0 and 100.",
+                            "Error", JOptionPane.ERROR_MESSAGE);
+                else
+                    fileInfo.burnin = newBurnin;
             }
         }