1 package fr.ifremer.dali.ui.swing.content.home.survey;
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.dali.ui.swing.action.AbstractCheckBeforeChangeScreenAction;
27 import fr.ifremer.dali.ui.swing.action.AbstractDaliSaveAction;
28 import fr.ifremer.dali.ui.swing.content.home.HomeUI;
29 import fr.ifremer.dali.ui.swing.content.home.SaveAction;
30 import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler;
31
32 import static org.nuiton.i18n.I18n.t;
33
34
35
36
37 public abstract class AbstractEditSurveyAction extends
38 AbstractCheckBeforeChangeScreenAction<SurveysTableUIModel, SurveysTableUI, SurveysTableUIHandler> {
39
40
41
42
43
44
45
46 protected AbstractEditSurveyAction(SurveysTableUIHandler handler, boolean hideBody) {
47 super(handler, hideBody);
48 }
49
50
51 @Override
52 public boolean prepareAction() throws Exception {
53 boolean canContinue = super.prepareAction();
54 getContext().setSelectedSamplingOperationId(null);
55 if (canContinue && (getModel().isModify() || getModel().getMainUIModel().isModify())) {
56 getContext().getDialogHelper().showWarningDialog(
57 t("dali.home.survey.error.message"),
58 t("dali.home.survey.error.title"));
59 canContinue = false;
60 }
61 return canContinue;
62
63 }
64
65
66 @Override
67 protected Class<? extends AbstractDaliSaveAction> getSaveActionClass() {
68 return SaveAction.class;
69 }
70
71
72 @Override
73 protected boolean isModelModify() {
74 return getModel().getMainUIModel().isModify();
75 }
76
77
78 @Override
79 protected void setModelModify(boolean modelModify) {
80 getModel().getMainUIModel().setModify(modelModify);
81 }
82
83
84 @Override
85 protected boolean isModelValid() {
86 return getModel().getMainUIModel().isValid();
87 }
88
89
90 @Override
91 protected AbstractApplicationUIHandler<?, ?> getSaveHandler() {
92 return getUI().getParentContainer(HomeUI.class).getHandler();
93 }
94 }