You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AdressenSpeichern.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package gui_adressverwaltung.Controller;
  7. import gui_adressverwaltung.Controller.Interface.CommandInterface;
  8. import gui_adressverwaltung.model.AdressverwaltungModel;
  9. import gui_adressverwaltung.view.Hauptfenster;
  10. import java.io.File;
  11. import java.io.IOException;
  12. import java.util.logging.Level;
  13. import java.util.logging.Logger;
  14. import javax.swing.JFileChooser;
  15. /**
  16. *
  17. * @author nobody
  18. */
  19. public class AdressenSpeichern implements CommandInterface
  20. {
  21. private AdressverwaltungModel model;
  22. private Hauptfenster view;
  23. public AdressenSpeichern(AdressverwaltungModel model, Hauptfenster view)
  24. {
  25. this.model = model;
  26. this.view = view;
  27. }
  28. /**
  29. * Führt den Befehl aus
  30. */
  31. @Override
  32. public void execute()
  33. {
  34. JFileChooser chooser = new JFileChooser();
  35. chooser.showSaveDialog(view);
  36. File file = chooser.getSelectedFile();
  37. try
  38. {
  39. model.datenSpeichern(file);
  40. view.getLblStatus().setText("Adressen wurden gespeichert");
  41. }
  42. catch(IOException ex)
  43. {
  44. Logger.getLogger(AdressenSpeichern.class.getName()).log(Level.SEVERE, null, ex);
  45. }
  46. }
  47. /**
  48. * Nimmt den Befehl zurück
  49. */
  50. @Override
  51. public void undo()
  52. {
  53. }
  54. /**
  55. * Giubt zurück ob der Befehl rücknehmbar ist
  56. */
  57. @Override
  58. public boolean isUndoable()
  59. {
  60. return false;
  61. }
  62. }