1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.fraction.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.FractionDTO;
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.fraction.ManageFractionsUI;
30 import fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.fraction.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<ManageFractionsMenuUIModel, ManageFractionsMenuUI, ManageFractionsMenuUIHandler> {
39
40 private List<FractionDTO> result;
41
42
43
44
45
46
47 public SearchAction(final ManageFractionsMenuUIHandler 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().searchFractions(
89 getModel().getStatusFilter(),
90 getModel().getFractionId(),
91 getModel().getStatusCode());
92 }
93
94
95 @Override
96 public void postSuccessAction() {
97
98 getModel().setResults(result);
99
100 super.postSuccessAction();
101 }
102
103 private ManageFractionsUI getParentUI() {
104 return getUI().getParentContainer(ManageFractionsUI.class);
105 }
106 }