From f0aca0c83faa802accdeecf9c4774c643610fa09 Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Mon, 10 Jun 2024 09:22:30 +0100 Subject: [PATCH] Fix reprocess choices Make sure the choice to continue anyway is always present. --- .../fileprocessing/ReprocessChoiceDialog.java | 15 +++++++++++++++ .../fileprocessing/ReprocessManager.java | 4 +++- .../fileprocessing/StoreChoiceSummary.java | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/PamController/fileprocessing/ReprocessChoiceDialog.java b/src/PamController/fileprocessing/ReprocessChoiceDialog.java index f2b9eee5..985fbb99 100644 --- a/src/PamController/fileprocessing/ReprocessChoiceDialog.java +++ b/src/PamController/fileprocessing/ReprocessChoiceDialog.java @@ -4,6 +4,8 @@ import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.List; import javax.swing.ButtonGroup; @@ -64,15 +66,28 @@ public class ReprocessChoiceDialog extends PamDialog { List userChoices = choiceSummary.getChoices(); choiceButtons = new JRadioButton[userChoices.size()]; ButtonGroup bg = new ButtonGroup(); + SelAction selAction = new SelAction(); for (int i = 0; i < userChoices.size(); i++) { ReprocessStoreChoice aChoice = userChoices.get(i); choiceButtons[i] = new JRadioButton(aChoice.toString()); choiceButtons[i].setToolTipText(aChoice.getToolTip()); + bg.add(choiceButtons[i]); + choiceButtons[i].addActionListener(selAction); choicePanel.add(choiceButtons[i], c); c.gridy++; } setDialogComponent(mainPanel); getCancelButton().setVisible(false); + getOkButton().setEnabled(false); + } + + private class SelAction implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + getOkButton().setEnabled(true); + } + } public static ReprocessStoreChoice showDialog(Window parentFrame, StoreChoiceSummary choices) { diff --git a/src/PamController/fileprocessing/ReprocessManager.java b/src/PamController/fileprocessing/ReprocessManager.java index 4f05913a..b4e8c395 100644 --- a/src/PamController/fileprocessing/ReprocessManager.java +++ b/src/PamController/fileprocessing/ReprocessManager.java @@ -62,7 +62,7 @@ public class ReprocessManager { */ boolean setupOK = setupInputStream(choiceSummary, choice); - if (choice == ReprocessStoreChoice.DONTSSTART) { + if (choice == null || choice == ReprocessStoreChoice.DONTSSTART) { return false; } @@ -172,6 +172,8 @@ public class ReprocessManager { choiceSummary.addChoice(ReprocessStoreChoice.STARTNORMAL); return choiceSummary; } + + choiceSummary.addChoice(ReprocessStoreChoice.STARTNORMAL); ArrayList outputStores = PamController.getInstance().findControlledUnits(DataOutputStore.class, true); boolean partStores = false; diff --git a/src/PamController/fileprocessing/StoreChoiceSummary.java b/src/PamController/fileprocessing/StoreChoiceSummary.java index f0f13c3a..571f7aa7 100644 --- a/src/PamController/fileprocessing/StoreChoiceSummary.java +++ b/src/PamController/fileprocessing/StoreChoiceSummary.java @@ -65,6 +65,9 @@ public class StoreChoiceSummary { * @param choice */ public void addChoice(ReprocessStoreChoice choice) { + if (choices.contains(choice)) { + return; + } choices.add(choice); }