1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.samplingequipment;
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.QuitScreenAction;
27 import fr.ifremer.reefdb.ui.swing.util.AbstractReefDbBeanUIModel;
28 import fr.ifremer.reefdb.ui.swing.util.AbstractReefDbUIHandler;
29 import jaxx.runtime.SwingUtil;
30 import jaxx.runtime.validator.swing.SwingValidator;
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33 import org.nuiton.jaxx.application.swing.util.CloseableUI;
34
35 import java.beans.PropertyChangeEvent;
36 import java.beans.PropertyChangeListener;
37
38
39
40
41 public class ManageSamplingEquipmentsUIHandler extends AbstractReefDbUIHandler<ManageSamplingEquipmentsUIModel, ManageSamplingEquipmentsUI> implements CloseableUI {
42
43
44
45
46 private static final Log LOG = LogFactory.getLog(ManageSamplingEquipmentsUIHandler.class);
47
48
49 @Override
50 public void beforeInit(ManageSamplingEquipmentsUI ui) {
51 super.beforeInit(ui);
52
53
54 ui.setContextValue(new ManageSamplingEquipmentsUIModel());
55 ui.setContextValue(SwingUtil.createActionIcon("config"));
56
57 }
58
59
60 @Override
61 public void afterInit(ManageSamplingEquipmentsUI ui) {
62 initUI(ui);
63
64 getModel().setLocalUIModel(getUI().getSamplingEquipmentsLocalUI().getModel());
65
66 listenModelModify(getModel().getLocalUIModel());
67 getModel().getLocalUIModel().addPropertyChangeListener(AbstractReefDbBeanUIModel.PROPERTY_VALID, evt -> getValidator().doValidate());
68 registerValidators(getValidator());
69 listenValidatorValid(getValidator(), getModel());
70
71
72 getContext().clearObservationPrelevementsIds();
73 }
74
75
76 @Override
77 public SwingValidator<ManageSamplingEquipmentsUIModel> getValidator() {
78 return getUI().getValidator();
79 }
80
81
82 @Override
83 @SuppressWarnings("unchecked")
84 public boolean quitUI() {
85 try {
86 QuitScreenAction action = new QuitScreenAction(this, false, SaveAction.class);
87 if (action.prepareAction()) {
88 return true;
89 }
90 } catch (Exception e) {
91 LOG.error(e.getLocalizedMessage(), e);
92 }
93 return false;
94
95 }
96 }