package bluej.collect;
import javafx.animation.Animation;
import javafx.animation.AnimationTimer;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.stage.Modality;
import bluej.Config;
import bluej.utility.Debug;
import threadchecker.OnThread;
| A dialog to be shown in the case that you are running a trial, and
| data collection fails for one of the participants,
|
public class DataSubmissionFailedDialog extends Dialog<Void>{
private final AnimationTimer timer;
private final long countdown = 20;
public DataSubmissionFailedDialog()
{
initModality(Modality.APPLICATION_MODAL);
setTitle("Data collection failure");
Label message = new Label("Connection to the data recording server has failed. Please tell an instructor, and then restart " + (Config.isGreenfoot() ? "Greenfoot" : "BlueJ") + " to reconnect and continue working.");
message.setWrapText(true);
message.setPrefWidth(300.0);
getDialogPane().getButtonTypes().setAll(ButtonType.OK);
Button ok = (Button)getDialogPane().lookupButton(ButtonType.OK);
ok.setText("Ok (" + countdown + ")");
ok.setOnAction(e -> close());
ok.setDisable(true);
timer = new AnimationTimer()
{
long time = -1;
long prevRemaining = countdown;
@Override
public void handle(long now)
{
if (time == -1)
time = now;
else
{
long remaining = countdown - ((now - time) / 1000000000);
if (prevRemaining == remaining)
return;
prevRemaining = remaining;
if (remaining > 0)
ok.setText("Ok (" + remaining + ")");
else
{
ok.setText("Ok");
ok.setDisable(false);
stop();
}
}
}
};
setOnShown(ev -> {
timer.start();
ok.getScene().getWindow().setOnCloseRequest(e -> {
if (ok.isDisable())
e.consume();
});
});
getDialogPane().setContent(message);
}
}
. DataSubmissionFailedDialog
. handle
84 neLoCode
+ 2 LoComm