1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.matrix.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.ui.swing.util.AbstractReefDbUIHandler;
27 import fr.ifremer.reefdb.ui.swing.util.ReefDbUIs;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31
32
33
34 public class ManageMatricesMenuUIHandler extends AbstractReefDbUIHandler<ManageMatricesMenuUIModel, ManageMatricesMenuUI> {
35
36
37
38
39 private static final Log LOG = LogFactory.getLog(ManageMatricesMenuUIHandler.class);
40
41
42 @Override
43 public void beforeInit(final ManageMatricesMenuUI ui) {
44 super.beforeInit(ui);
45
46
47 final ManageMatricesMenuUIModel model = new ManageMatricesMenuUIModel();
48 ui.setContextValue(model);
49 }
50
51
52 @Override
53 public void afterInit(final ManageMatricesMenuUI ui) {
54 initUI(ui);
55
56
57 getModel().addPropertyChangeListener(ManageMatricesMenuUIModel.PROPERTY_LOCAL, evt -> {
58 getUI().getStatusCombo().setData(getContext().getReferentialService().getStatus(getModel().getStatusFilter()));
59 reloadComboBox();
60 });
61
62
63 initComboBox();
64 }
65
66
67
68
69 private void initComboBox() {
70 initBeanFilterableComboBox(
71 getUI().getLabelCombo(),
72 getContext().getReferentialService().getMatrices(getModel().getStatusFilter()),
73 null);
74
75 initBeanFilterableComboBox(
76 getUI().getStatusCombo(),
77 getContext().getReferentialService().getStatus(getModel().getStatusFilter()),
78 null);
79 ReefDbUIs.forceComponentSize(getUI().getLabelCombo());
80 ReefDbUIs.forceComponentSize(getUI().getStatusCombo());
81 }
82
83
84
85
86 public void reloadComboBox() {
87
88 getUI().getLabelCombo().setData(getContext().getReferentialService().getMatrices(getModel().getStatusFilter()));
89 }
90 }