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.

AdressenOeffnen.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 am
  18. */
  19. public class AdressenOeffnen implements CommandInterface
  20. {
  21. private AdressverwaltungModel model;
  22. private Hauptfenster view;
  23. /**
  24. *
  25. * @param model
  26. * @param view
  27. */
  28. public AdressenOeffnen(AdressverwaltungModel model, Hauptfenster view)
  29. {
  30. this.model = model;
  31. this.view = view;
  32. }
  33. /**
  34. * Führt den Befehl aus
  35. */
  36. @Override
  37. public void execute()
  38. {
  39. JFileChooser chooser = new JFileChooser();
  40. chooser.showOpenDialog(view);
  41. File file = chooser.getSelectedFile();
  42. try
  43. {
  44. model.datenLesen(file);
  45. view.getLblStatus().setText("Neue Datei geöffnet");
  46. }
  47. catch(IOException | ClassNotFoundException ex)
  48. {
  49. Logger.getLogger(AdressenOeffnen.class.getName()).log(Level.SEVERE, null, ex);
  50. }
  51. }
  52. /**
  53. * Macht den Befehl rückgängig
  54. */
  55. @Override
  56. public void undo()
  57. {
  58. }
  59. /**
  60. * Gibt zurück ob die Aktion rücknehmbar ist
  61. */
  62. @Override
  63. public boolean isUndoable()
  64. {
  65. return false;
  66. }
  67. }