1 package fr.ifremer.dali.ui.swing.action;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import fr.ifremer.dali.ui.swing.util.DaliUI;
25 import fr.ifremer.quadrige3.ui.swing.AbstractUIHandler;
26 import fr.ifremer.quadrige3.ui.swing.model.AbstractBeanUIModel;
27
28 import java.util.ArrayList;
29 import java.util.List;
30
31
32
33
34 public abstract class AbstractDaliSaveAction<M extends AbstractBeanUIModel, UI extends DaliUI<M, ?>, H extends AbstractUIHandler<M, UI>>
35 extends AbstractDaliAction<M, UI, H> {
36
37 private boolean fromChangeScreenAction = false;
38 private boolean fromCheckModelAction = false;
39 private boolean allowChangeScreen = true;
40
41
42
43
44
45
46
47 public AbstractDaliSaveAction(H handler, boolean hideBody) {
48 super(handler, hideBody);
49 }
50
51 public boolean isFromChangeScreenAction() {
52 return fromChangeScreenAction;
53 }
54
55 public void setFromChangeScreenAction(boolean fromChangeScreenAction) {
56 this.fromChangeScreenAction = fromChangeScreenAction;
57 }
58
59 public boolean isFromCheckModelAction() {
60 return fromCheckModelAction;
61 }
62
63 public void setFromCheckModelAction(boolean fromCheckModelAction) {
64 this.fromCheckModelAction = fromCheckModelAction;
65 }
66
67 public boolean isAllowChangeScreen() {
68 return allowChangeScreen;
69 }
70
71 public void setAllowChangeScreen(boolean allowChangeScreen) {
72 this.allowChangeScreen = allowChangeScreen;
73 }
74
75 @Override
76 public boolean prepareAction() throws Exception {
77 fromChangeScreenAction = false;
78 fromCheckModelAction = false;
79 allowChangeScreen = true;
80 return super.prepareAction();
81 }
82
83
84 protected List<AbstractBeanUIModel> getModelsToModify() {
85 return new ArrayList<>();
86 }
87
88 @Override
89 public void postSuccessAction() {
90 super.postSuccessAction();
91
92
93 getModelsToModify().forEach(model -> model.setModify(false));
94
95
96 getModel().setModify(false);
97 }
98 }