Select Git revision
Drawer.java
Forked from
COUETOUX Basile / graphic-2020
Source project has a limited visibility.
-
MANSOUR Chadi authored
This reverts commit d81c9d6d
MANSOUR Chadi authoredThis reverts commit d81c9d6d
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();
}
}
}