1 package fr.ifremer.reefdb.ui.swing.content.manage.referential.location.local.replace;
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 jaxx.runtime.validator.swing.SwingValidator;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.nuiton.jaxx.application.swing.util.Cancelable;
31
32 import javax.swing.*;
33
34
35
36
37
38
39 public class ReplaceLocationUIHandler extends AbstractReefDbUIHandler<ReplaceLocationUIModel, ReplaceLocationUI> implements Cancelable {
40
41
42 private static final Log log =
43 LogFactory.getLog(ReplaceLocationUIHandler.class);
44
45
46 @Override
47 public void afterInit(ReplaceLocationUI ui) {
48
49 initUI(ui);
50
51 ReplaceLocationUIModel model = getModel();
52 initBeanFilterableComboBox(ui.getSourceListComboBox(), model.getSourceList(), model.getSelectedSource());
53 initBeanFilterableComboBox(ui.getTargetListComboBox(), model.getTargetList(), model.getSelectedTarget());
54
55 SwingValidator validator = ui.getValidator();
56 listenValidatorValid(validator, model);
57
58 registerValidators(validator);
59 }
60
61
62 @Override
63 protected JComponent getComponentToFocus() {
64 return getUI().getSourceListComboBox();
65 }
66
67
68 @Override
69 @SuppressWarnings("unchecked")
70 public SwingValidator getValidator() {
71 return ui.getValidator();
72 }
73
74
75 @Override
76 public void cancel() {
77 getModel().setValid(false);
78 onCloseUI();
79 }
80
81 }