Fix reprocess choices

Make sure the choice to continue anyway is always present.
This commit is contained in:
Douglas Gillespie 2024-06-10 09:22:30 +01:00
parent a6b0ccd780
commit f0aca0c83f
3 changed files with 21 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import java.awt.BorderLayout;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List; import java.util.List;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
@ -64,15 +66,28 @@ public class ReprocessChoiceDialog extends PamDialog {
List<ReprocessStoreChoice> userChoices = choiceSummary.getChoices(); List<ReprocessStoreChoice> userChoices = choiceSummary.getChoices();
choiceButtons = new JRadioButton[userChoices.size()]; choiceButtons = new JRadioButton[userChoices.size()];
ButtonGroup bg = new ButtonGroup(); ButtonGroup bg = new ButtonGroup();
SelAction selAction = new SelAction();
for (int i = 0; i < userChoices.size(); i++) { for (int i = 0; i < userChoices.size(); i++) {
ReprocessStoreChoice aChoice = userChoices.get(i); ReprocessStoreChoice aChoice = userChoices.get(i);
choiceButtons[i] = new JRadioButton(aChoice.toString()); choiceButtons[i] = new JRadioButton(aChoice.toString());
choiceButtons[i].setToolTipText(aChoice.getToolTip()); choiceButtons[i].setToolTipText(aChoice.getToolTip());
bg.add(choiceButtons[i]);
choiceButtons[i].addActionListener(selAction);
choicePanel.add(choiceButtons[i], c); choicePanel.add(choiceButtons[i], c);
c.gridy++; c.gridy++;
} }
setDialogComponent(mainPanel); setDialogComponent(mainPanel);
getCancelButton().setVisible(false); 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) { public static ReprocessStoreChoice showDialog(Window parentFrame, StoreChoiceSummary choices) {

View File

@ -62,7 +62,7 @@ public class ReprocessManager {
*/ */
boolean setupOK = setupInputStream(choiceSummary, choice); boolean setupOK = setupInputStream(choiceSummary, choice);
if (choice == ReprocessStoreChoice.DONTSSTART) { if (choice == null || choice == ReprocessStoreChoice.DONTSSTART) {
return false; return false;
} }
@ -173,6 +173,8 @@ public class ReprocessManager {
return choiceSummary; return choiceSummary;
} }
choiceSummary.addChoice(ReprocessStoreChoice.STARTNORMAL);
ArrayList<PamControlledUnit> outputStores = PamController.getInstance().findControlledUnits(DataOutputStore.class, true); ArrayList<PamControlledUnit> outputStores = PamController.getInstance().findControlledUnits(DataOutputStore.class, true);
boolean partStores = false; boolean partStores = false;
int nOutputStores = 0; int nOutputStores = 0;

View File

@ -65,6 +65,9 @@ public class StoreChoiceSummary {
* @param choice * @param choice
*/ */
public void addChoice(ReprocessStoreChoice choice) { public void addChoice(ReprocessStoreChoice choice) {
if (choices.contains(choice)) {
return;
}
choices.add(choice); choices.add(choice);
} }