Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions src/edu/csus/ecs/pc2/ui/ContestInformationPane.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2026 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.ui;

import java.awt.BorderLayout;
Expand Down Expand Up @@ -51,9 +51,11 @@
import edu.csus.ecs.pc2.core.Constants;
import edu.csus.ecs.pc2.core.IInternalController;
import edu.csus.ecs.pc2.core.StringUtilities;
import edu.csus.ecs.pc2.core.Utilities;
import edu.csus.ecs.pc2.core.model.ContestInformation;
import edu.csus.ecs.pc2.core.model.ContestInformation.TeamDisplayMask;
import edu.csus.ecs.pc2.core.model.ContestInformationEvent;
import edu.csus.ecs.pc2.core.model.ContestTime;
import edu.csus.ecs.pc2.core.model.IContestInformationListener;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.scoring.DefaultScoringAlgorithm;
Expand Down Expand Up @@ -1109,9 +1111,12 @@ public void setContestAndController(IInternalContest inContest, IInternalControl

/**
* Returns a new ContestInformation object containing data fetched from this pane's fields.
* @param validating If true, some display fields will be validated and throw an IllegalArgumentException if bad.
* In addition, if true, some display fields may be changed (normalized).
* @return a ContestInformation object
* @throws IllegalArgumentException if a field value is bad
*/
protected ContestInformation getFromFields() {
protected ContestInformation getFromFields(boolean validating) throws IllegalArgumentException {
ContestInformation newContestInformation = new ContestInformation();
ContestInformation currentContestInformation = getContest().getContestInformation();

Expand Down Expand Up @@ -1180,20 +1185,34 @@ protected ContestInformation getFromFields() {
newContestInformation.setContestShortName(savedContestInformation.getContestShortName());
newContestInformation.setExternalYamlPath(savedContestInformation.getExternalYamlPath());

//TODO: why is the following being done here when it is overridden below?
newContestInformation.setFreezeTime(savedContestInformation.getFreezeTime());
// setFreezeTime is always called below so this is indeed unnecessary
// newContestInformation.setFreezeTime(savedContestInformation.getFreezeTime());

newContestInformation.setLastRunNumberSubmitted(savedContestInformation.getLastRunNumberSubmitted());
newContestInformation.setAutoStartContest(savedContestInformation.isAutoStartContest());
}

newContestInformation.setScoringProperties(scoringPropertiesPane.getProperties());

newContestInformation.setFreezeTime(contestFreezeLengthTextField.getText());
// make sure time is formatted properly
String freezeField = contestFreezeLengthTextField.getText();
long freezeSeconds = Utilities.convertStringToSeconds(freezeField);
if(freezeSeconds == -1) {
if(validating) {
throw new IllegalArgumentException("Invalid freeze time \"" + freezeField + "\" specified.");
}
} else {
freezeField = ContestTime.formatTime(freezeSeconds);
if(validating) {
// Update display to show possibly normalized freeze duration
contestFreezeLengthTextField.setText(freezeField);
}
}
newContestInformation.setFreezeTime(freezeField);

newContestInformation.setThawed(scoreboardHasBeenUnfrozen);

// fill in sandbox/interative grace time adjustments
// fill in sandbox/interactive grace time adjustments
newContestInformation.setSandboxGraceTimeSecs(StringUtilities.getIntegerValue("0" + getSandboxGraceTimeTextField().getText(), savedContestInformation.getSandboxGraceTimeSecs()));
newContestInformation.setSandboxInteractiveGraceMultiplier(StringUtilities.getIntegerValue("0" + this.getSandboxInteractiveMultiplierTextField().getText(), savedContestInformation.getSandboxInteractiveGraceMultiplier()));

Expand All @@ -1219,7 +1238,7 @@ protected void dumpProperties(String comment, Properties properties) {
}

protected void enableUpdateButton() {
ContestInformation newChoice = getFromFields();
ContestInformation newChoice = getFromFields(false);

if (getContest().getContestInformation().isSameAs(newChoice)) {
setEnableButtons(false);
Expand Down Expand Up @@ -1308,7 +1327,14 @@ private String getScheduledStartTimeStr(GregorianCalendar cal) {


private void updateContestInformation() {
ContestInformation contestInformation = getFromFields();
ContestInformation contestInformation = null;

try {
contestInformation = getFromFields(true);
} catch(IllegalArgumentException e) {
JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), "Bad Value Specified", JOptionPane.INFORMATION_MESSAGE);
return;
}

getController().updateContestInformation(contestInformation);
}
Expand Down Expand Up @@ -1994,7 +2020,7 @@ private Component getRigidArea3( ) {
}
return rigidArea3;
}

private Component getRigidArea4() {
if (rigidArea4==null) {
rigidArea4 = Box.createRigidArea(new Dimension(20,20));
Expand Down
Loading