1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.unit;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import fr.ifremer.reefdb.ui.swing.action.AbstractCheckBeforeChangeScreenAction;
27 import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbSaveAction;
28 import fr.ifremer.reefdb.ui.swing.action.GoToObservationAction;
29 import fr.ifremer.reefdb.ui.swing.content.manage.referential.unit.local.ReferentialUnitsLocalUIModel;
30 import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler;
31
32
33
34
35 public class CloseAction extends AbstractCheckBeforeChangeScreenAction<ReferentialUnitsUIModel, ReferentialUnitsUI, ReferentialUnitsUIHandler> {
36
37
38
39
40
41
42 public CloseAction(final ReferentialUnitsUIHandler handler) {
43 super(handler, true);
44 }
45
46
47 @Override
48 protected Class<? extends AbstractReefDbSaveAction> getSaveActionClass() {
49 return SaveAction.class;
50 }
51
52
53 @Override
54 protected AbstractApplicationUIHandler<?, ?> getSaveHandler() {
55 return getHandler();
56 }
57
58
59 @Override
60 protected Class<GoToObservationAction> getGotoActionClass() {
61 return GoToObservationAction.class;
62 }
63
64
65 @Override
66 protected boolean isModelModify() {
67 final ReferentialUnitsLocalUIModel model = getLocalModel();
68 return model != null && model.isModify();
69 }
70
71
72 @Override
73 protected boolean isModelValid() {
74 final ReferentialUnitsLocalUIModel model = getLocalModel();
75 return model == null || model.isValid();
76 }
77
78 private ReferentialUnitsLocalUIModel getLocalModel() {
79 return getUI().getReferentialUnitsLocalUI().getModel();
80 }
81
82
83 @Override
84 protected void setModelModify(boolean modelModify) {
85 final ReferentialUnitsLocalUIModel model = getLocalModel();
86 if (model != null) {
87 model.setModify(modelModify);
88 }
89 }
90 }