Ajout de la fonctionnalité d'import/export de grille #2

Merged
Lyanis SOUIDI merged 6 commits from feature_filemanager into master 2023-04-28 03:23:44 +02:00
Showing only changes of commit 19349d89ae - Show all commits

View File

@ -95,7 +95,7 @@ public class HomeView extends JPanel {
return choisirGrille;
}
private static JButton importerGrille(JFrame window) {
private static JButton importerGrille(Window window) {
JPanel panel = new JPanel();
JButton importerGrille = new JButton("Importer une grille");
importerGrille.setPreferredSize(new Dimension(250, 50));
@ -108,7 +108,14 @@ public class HomeView extends JPanel {
int choix = fileChooser.showOpenDialog(panel);
if (choix == JFileChooser.APPROVE_OPTION) {
File fichier = fileChooser.getSelectedFile();
// TODO: charger la grille depuis le fichier
try {
GridView gridView = new GridView(window);
new GridController(FileManager.importGrid(fichier), gridView);
window.setContentPane(gridView);
window.validate();
} catch (Exception ex) {
JOptionPane.showMessageDialog(panel, ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
});