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.

CommandEintragLoeschen.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 command.commands;
  7. import command.CommandInterface;
  8. import java.util.ArrayList;
  9. import model.AdressVerwaltungModel;
  10. import view.MainWindow;
  11. /**
  12. *
  13. * @author PC
  14. */
  15. public class CommandEintragLoeschen implements CommandInterface{
  16. private MainWindow view;
  17. private AdressVerwaltungModel model;
  18. private ArrayList<String> cache;
  19. public CommandEintragLoeschen(MainWindow view, AdressVerwaltungModel model) {
  20. this.view = view;
  21. this.model = model;
  22. this.cache = new ArrayList<>();
  23. }
  24. @Override
  25. public void execute() {
  26. this.cache = this.model.getLastRowData();
  27. this.model.eintragLoeschen(this.model.getRowCount()-1);
  28. }
  29. @Override
  30. public void undo() {
  31. this.model.eintragHinzufuegen(this.cache);
  32. }
  33. @Override
  34. public boolean isUndoable() {
  35. return true;
  36. }
  37. }