1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.matrix.menu;
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.pmfm.MatrixDTO;
27 import fr.ifremer.reefdb.ui.swing.action.AbstractCheckModelAction;
28 import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbSaveAction;
29 import fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.matrix.ManageMatricesUI;
30 import fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.matrix.SaveAction;
31 import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler;
32
33 import java.util.List;
34
35
36
37
38 public class SearchAction extends AbstractCheckModelAction<ManageMatricesMenuUIModel, ManageMatricesMenuUI, ManageMatricesMenuUIHandler> {
39
40 List<MatrixDTO> result;
41
42
43
44
45
46
47 public SearchAction(final ManageMatricesMenuUIHandler handler) {
48 super(handler, false);
49 }
50
51
52 @Override
53 protected Class<? extends AbstractReefDbSaveAction> getSaveActionClass() {
54 return SaveAction.class;
55 }
56
57
58 @Override
59 protected AbstractApplicationUIHandler<?, ?> getSaveHandler() {
60 return getParentUI() != null ? getParentUI().getHandler() : null;
61 }
62
63
64 @Override
65 protected boolean isModelModify() {
66 return getParentUI() != null && getParentUI().getModel().isModify();
67 }
68
69
70 @Override
71 protected void setModelModify(boolean modelModify) {
72 if (getParentUI() == null) {
73 return;
74 }
75 getParentUI().getModel().setModify(modelModify);
76 }
77
78
79 @Override
80 protected boolean isModelValid() {
81 return getParentUI() == null || getParentUI().getModel().isValid();
82 }
83
84
85 @Override
86 public void doAction() {
87
88 result = getContext().getReferentialService().searchMatrices(
89 getModel().getStatusFilter(),
90 getModel().getMatrixId(),
91 getModel().getStatusCode());
92
93 }
94
95
96 @Override
97 public void postSuccessAction() {
98
99 getModel().setResults(result);
100
101 super.postSuccessAction();
102 }
103
104 private ManageMatricesUI getParentUI() {
105 return getUI().getParentContainer(ManageMatricesUI.class);
106 }
107
108 }