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.dto.referential.UnitDTO;
27 import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbSaveAction;
28
29 import java.util.List;
30
31
32
33
34 public class SaveAction extends AbstractReefDbSaveAction<ReferentialUnitsUIModel, ReferentialUnitsUI, ReferentialUnitsUIHandler> {
35
36
37
38
39
40
41 public SaveAction(final ReferentialUnitsUIHandler handler) {
42 super(handler, false);
43 }
44
45
46 @Override
47 public boolean prepareAction() throws Exception {
48 if (!super.prepareAction()) {
49 return false;
50 }
51
52
53 return getModel().isModify() && getModel().isValid();
54 }
55
56
57 @Override
58 public void doAction() {
59
60 List<? extends UnitDTO> toSave = getModel().getLocalUIModel().getRows();
61
62 getContext().getReferentialService().saveUnits(toSave);
63 }
64
65
66 @Override
67 public void postSuccessAction() {
68
69 getUI().getReferentialUnitsLocalUI().getMenuUI().getHandler().reloadComboBox();
70
71 getModel().setModify(false);
72
73 super.postSuccessAction();
74 }
75
76 }