1 package fr.ifremer.tutti.ui.swing.util.species;
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.persistence.entities.referential.Species;
27 import fr.ifremer.tutti.service.DecoratorService;
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 SelectSpeciesUIHandler extends AbstractTuttiUIHandler<SelectSpeciesUIModel, SelectSpeciesUI> {
40
41 private static final Log log =
42 LogFactory.getLog(SelectSpeciesUIHandler.class);
43
44 @Override
45 public void beforeInit(SelectSpeciesUI ui) {
46 super.beforeInit(ui);
47 SelectSpeciesUIModel model = new SelectSpeciesUIModel();
48 ui.setContextValue(model);
49 }
50
51 @Override
52 public void afterInit(SelectSpeciesUI ui) {
53 initUI(ui);
54
55 String context = ui.useSurveyCode ? DecoratorService.WITH_SURVEY_CODE : null;
56
57 initBeanFilterableComboBox(ui.getSpeciesCombo(),
58 Lists.<Species>newArrayList(),
59 null,
60 context);
61
62
63
64
65
66
67 getModel().addPropertyChangeListener(
68 SelectSpeciesUIModel.PROPERTY_SPECIES,
69 evt -> SelectSpeciesUIHandler.this.ui.getSpeciesCombo().getHandler().sortData());
70
71 }
72
73 @Override
74 protected JComponent getComponentToFocus() {
75 return getUI().getSpeciesCombo();
76 }
77
78 @Override
79 public void onCloseUI() {
80 if (log.isDebugEnabled()) {
81 log.debug("closing: " + ui);
82 }
83 }
84
85 @Override
86 public SwingValidator<SelectSpeciesUIModel> getValidator() {
87 return null;
88 }
89
90 }