1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.tethys.core.dialog;
18
19 import io.github.tonywasher.joceanus.tethys.api.base.TethysUINode;
20 import io.github.tonywasher.joceanus.tethys.api.base.TethysUIProgram;
21 import io.github.tonywasher.joceanus.tethys.api.button.TethysUIButton;
22 import io.github.tonywasher.joceanus.tethys.api.control.TethysUIControlFactory;
23 import io.github.tonywasher.joceanus.tethys.api.control.TethysUILabel;
24 import io.github.tonywasher.joceanus.tethys.api.dialog.TethysUIAboutBox;
25 import io.github.tonywasher.joceanus.tethys.api.pane.TethysUIBoxPaneManager;
26 import io.github.tonywasher.joceanus.tethys.core.base.TethysUICoreComponent;
27 import io.github.tonywasher.joceanus.tethys.core.base.TethysUIResource;
28 import io.github.tonywasher.joceanus.tethys.core.factory.TethysUICoreFactory;
29
30
31
32
33 public abstract class TethysUICoreAboutBox
34 extends TethysUICoreComponent
35 implements TethysUIAboutBox {
36
37
38
39 private static final String PROMPT_VERSION = TethysUIResource.ABOUT_VERSION.getValue();
40
41
42
43
44 private static final String PROMPT_REVISION = TethysUIResource.ABOUT_REVISION.getValue();
45
46
47
48
49 private static final String PROMPT_BUILDDATE = TethysUIResource.ABOUT_BUILTON.getValue();
50
51
52
53
54 private static final String TEXT_OK = TethysUIResource.BUTTON_OK.getValue();
55
56
57
58
59 private static final int INSET_SIZE = 5;
60
61
62
63
64 private final TethysUIBoxPaneManager thePanel;
65
66
67
68
69
70
71 protected TethysUICoreAboutBox(final TethysUICoreFactory<?> pFactory) {
72
73 final TethysUIProgram myApp = pFactory.getProgramDefinitions();
74
75
76 final TethysUIControlFactory myFactory = pFactory.controlFactory();
77 final TethysUILabel myProduct = myFactory.newLabel(myApp.getName());
78 final TethysUILabel myVersion = myFactory.newLabel(PROMPT_VERSION + " "
79 + myApp.getVersion());
80 final TethysUILabel myRevision = myFactory.newLabel(PROMPT_REVISION + " "
81 + myApp.getRevision());
82 final TethysUILabel myBuild = myFactory.newLabel(PROMPT_BUILDDATE + " "
83 + myApp.getBuiltOn());
84 final TethysUILabel myCopyright = myFactory.newLabel(myApp.getCopyright());
85
86
87 final TethysUIButton myOKButton = pFactory.buttonFactory().newButton();
88 myOKButton.setText(TEXT_OK);
89 myOKButton.getEventRegistrar().addEventListener(e -> closeDialog());
90
91
92 thePanel = pFactory.paneFactory().newVBoxPane();
93 thePanel.setBorderPadding(INSET_SIZE);
94 thePanel.addNode(myProduct);
95 thePanel.addNode(myCopyright);
96 thePanel.addStrut();
97 thePanel.addNode(myVersion);
98 thePanel.addNode(myRevision);
99 thePanel.addNode(myBuild);
100 thePanel.addStrut();
101 thePanel.addNode(myOKButton);
102 }
103
104
105
106
107 protected abstract void closeDialog();
108
109 @Override
110 public TethysUINode getNode() {
111 return thePanel.getNode();
112 }
113
114 @Override
115 public void setEnabled(final boolean pEnabled) {
116 thePanel.setEnabled(pEnabled);
117 }
118
119 @Override
120 public void setVisible(final boolean pVisible) {
121 thePanel.setVisible(pVisible);
122 }
123
124 @Override
125 public Integer getId() {
126 return thePanel.getId();
127 }
128 }