Select Git revision
SimulatorApplication.class.uniqueId20
Forked from
COUETOUX Basile / FirefighterStarter
Source project has a limited visibility.
-
BACHTARZI Imed eddine authored
used the Factory Method through ElementFactory
BACHTARZI Imed eddine authoredused the Factory Method through ElementFactory
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
DrawerWithSave.java 1.38 KiB
package serializer;
import javafx.scene.control.Alert;
import javafx.stage.FileChooser;
import java.io.File;
import java.io.IOException;
public class DrawerWithSave extends state.Drawer {
public DrawerWithSave(int width, int height) {
super(width, height);
}
void write(){
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save");
File file = fileChooser.showSaveDialog(getScene().getWindow());
if (file == null) return;
try {
ShapeWriter.write(file, super.shapes);
}
catch (IOException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Error Dialog");
alert.setHeaderText(null);
alert.setContentText("Ooops, there was an error!");
alert.showAndWait();
}
}
public void load() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Load");
File file = fileChooser.showOpenDialog(getScene().getWindow());
if (file == null) return;
try {
super.shapes = ShapeReader.read(file);
repaint();
} catch (IOException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Error Dialog");
alert.setHeaderText(null);
alert.setContentText("Ooops, there was an error!");
alert.showAndWait();
}
}
}