1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.tethys.javafx.button;
18
19 import io.github.tonywasher.joceanus.oceanus.event.OceanusEventRegistrar;
20 import io.github.tonywasher.joceanus.tethys.api.base.TethysUIEvent;
21 import io.github.tonywasher.joceanus.tethys.core.button.TethysUICoreDateButtonManager;
22 import io.github.tonywasher.joceanus.tethys.core.factory.TethysUICoreFactory;
23 import io.github.tonywasher.joceanus.tethys.javafx.base.TethysUIFXNode;
24
25
26
27
28 public final class TethysUIFXDateButtonManager
29 extends TethysUICoreDateButtonManager {
30
31
32
33 private TethysUIFXDateDialog theDialog;
34
35
36
37
38
39
40 TethysUIFXDateButtonManager(final TethysUICoreFactory<?> pFactory) {
41
42 super(pFactory);
43 }
44
45 @Override
46 public TethysUIFXNode getNode() {
47 return (TethysUIFXNode) super.getNode();
48 }
49
50 @Override
51 public void setVisible(final boolean pVisible) {
52 getNode().setManaged(pVisible);
53 getNode().setVisible(pVisible);
54 }
55
56
57
58
59
60
61 public TethysUIFXDateDialog getDialog() {
62 ensureDialog();
63 return theDialog;
64 }
65
66
67
68
69 private void ensureDialog() {
70
71 if (theDialog == null) {
72
73 theDialog = new TethysUIFXDateDialog(getConfig());
74
75
76 final OceanusEventRegistrar<TethysUIEvent> myRegistrar = theDialog.getEventRegistrar();
77 myRegistrar.addEventListener(TethysUIEvent.PREPAREDIALOG, e -> handleDialogRequest());
78 myRegistrar.addEventListener(TethysUIEvent.NEWVALUE, e -> handleNewValue());
79 myRegistrar.addEventListener(TethysUIEvent.WINDOWCLOSED, e -> handleNewValue());
80 }
81 }
82
83 @Override
84 protected void showDialog() {
85
86 ensureDialog();
87
88
89 theDialog.showDialogUnderNode(getNode().getNode());
90 }
91
92 @Override
93 public void setPreferredWidth(final Integer pWidth) {
94 getNode().setPreferredWidth(pWidth);
95 }
96
97 @Override
98 public void setPreferredHeight(final Integer pHeight) {
99 getNode().setPreferredHeight(pHeight);
100 }
101
102 @Override
103 public void setBorderPadding(final Integer pPadding) {
104 super.setBorderPadding(pPadding);
105 getNode().createWrapperPane(getBorderTitle(), getBorderPadding());
106 }
107
108 @Override
109 public void setBorderTitle(final String pTitle) {
110 super.setBorderTitle(pTitle);
111 getNode().createWrapperPane(getBorderTitle(), getBorderPadding());
112 }
113 }