1 | |
package org.jtheque.films.controllers.impl.undo.create; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.beans.IBeansManager; |
21 | |
import org.jtheque.core.managers.language.ILanguageManager; |
22 | |
import org.jtheque.films.persistence.od.FilmImpl; |
23 | |
import org.jtheque.films.services.able.IFilmsService; |
24 | |
|
25 | |
import javax.annotation.Resource; |
26 | |
import javax.swing.undo.AbstractUndoableEdit; |
27 | |
import javax.swing.undo.CannotRedoException; |
28 | |
import javax.swing.undo.CannotUndoException; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
public final class CreatedFilmEdit extends AbstractUndoableEdit { |
36 | |
private static final long serialVersionUID = -3037357344759861059L; |
37 | |
|
38 | |
private final FilmImpl film; |
39 | |
|
40 | |
@Resource |
41 | |
private IFilmsService filmsService; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public CreatedFilmEdit(FilmImpl film) { |
49 | 0 | super(); |
50 | |
|
51 | 0 | Managers.getManager(IBeansManager.class).inject(this); |
52 | |
|
53 | 0 | this.film = film; |
54 | 0 | } |
55 | |
|
56 | |
@Override |
57 | |
public void undo() throws CannotUndoException { |
58 | 0 | super.undo(); |
59 | |
|
60 | 0 | filmsService.delete(film); |
61 | 0 | } |
62 | |
|
63 | |
@Override |
64 | |
public void redo() throws CannotRedoException { |
65 | 0 | super.redo(); |
66 | |
|
67 | 0 | filmsService.create(film); |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
public String getPresentationName() { |
72 | 0 | return Managers.getManager(ILanguageManager.class).getMessage("undo.edits.create"); |
73 | |
} |
74 | |
} |