1 package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.google.common.collect.Lists;
26 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
27 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
28 import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
29 import jaxx.runtime.validator.swing.SwingValidator;
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33 import javax.swing.JComponent;
34
35
36
37
38
39 public class CreateAccidentalBatchUIHandler extends AbstractTuttiUIHandler<CreateAccidentalBatchUIModel, CreateAccidentalBatchUI> {
40
41 private static final Log log =
42 LogFactory.getLog(CreateAccidentalBatchUIHandler.class);
43
44
45
46
47
48 @Override
49 public void beforeInit(CreateAccidentalBatchUI ui) {
50 super.beforeInit(ui);
51 CreateAccidentalBatchUIModel model = new CreateAccidentalBatchUIModel();
52 ui.setContextValue(model);
53 listModelIsModify(model);
54 }
55
56 @Override
57 public void afterInit(CreateAccidentalBatchUI ui) {
58
59 initUI(ui);
60
61 initBeanFilterableComboBox(ui.getAccidentalSpeciesComboBox(),
62 Lists.newArrayList(getDataContext().getReferentSpecies()),
63 null);
64
65 initBeanFilterableComboBox(ui.getAccidentalGenderComboBox(),
66 Lists.newArrayList(getDataContext().getGenderValues()),
67 null);
68
69 initBeanFilterableComboBox(ui.getAccidentalLengthStepCaracteristicComboBox(),
70 Lists.newArrayList(getDataContext().getLengthStepCaracteristics()),
71 null);
72
73 initBeanFilterableComboBox(ui.getAccidentalDeadOrAliveComboBox(),
74 Lists.newArrayList(getDataContext().getDeadOrAliveValues()),
75 null);
76
77 listenValidatorValid(ui.getValidator(), getModel());
78 }
79
80 @Override
81 protected JComponent getComponentToFocus() {
82 return getUI().getAccidentalSpeciesComboBox();
83 }
84
85 @Override
86 public void onCloseUI() {
87
88 if (log.isDebugEnabled()) {
89 log.debug("closing: " + ui);
90 }
91
92
93 ui.getValidator().setBean(null);
94
95
96 getModel().setValid(false);
97
98 EditCatchesUI parent = getParentContainer(EditCatchesUI.class);
99 parent.getHandler().setAccidentalSelectedCard(EditCatchesUIHandler.MAIN_CARD);
100 }
101
102 @Override
103 public SwingValidator<CreateAccidentalBatchUIModel> getValidator() {
104 return ui.getValidator();
105 }
106
107
108
109
110
111 public void openUI() {
112
113 CreateAccidentalBatchUIModel model = getModel();
114
115
116 ui.getValidator().setBean(model);
117
118 model.reset();
119
120 }
121
122 }