Transpiled version (18082L) is out of date.
1 | sclass JContentAndControls is Swingable, Updateable { |
2 | settable IF0/*<JComponent or Swingable>*/ makeContent; |
3 | SingleComponentPanel scpContent = singleComponentPanel(); |
4 | ReliableSingleThread rstReloadContent = rst(l0 reloadImpl); |
5 | settable JButton btnReload; |
6 | gettable DynamicHStack controls = dynamicHStack(); |
7 | gettable JPanel rightCornerControls = jline(); |
8 | SingleComponentPanel scpControls = singleComponentPanel(jfullcenter(controls)); |
9 | |
10 | settable bool loadingScreenWhenReloading; |
11 | settable bool showControls = true; |
12 | settable bool showReloadButton = true; |
13 | |
14 | public void reload aka update() { rstReloadContent.trigger(); } |
15 | |
16 | cachedVisualize { |
17 | onComponentShown(scpContent, -> { if (scpContent.isEmpty()) reload(); }); |
18 | |
19 | if (!showControls) ret scpContent; |
20 | |
21 | if (showReloadButton) { |
22 | btnReload = jReloadButton(l0 reload); |
23 | add(rightCornerControls, btnReload); |
24 | } |
25 | |
26 | ret northAndCenter(withMargin( |
27 | centerAndEastWithMargin(scpControls, rightCornerControls)), scpContent); |
28 | } |
29 | |
30 | swappable JComponent makeLoadingScreen() { |
31 | ret jCenteredLabel("Loading..."); |
32 | } |
33 | |
34 | void reloadImpl { |
35 | temp tempDisableButton(btnReload); |
36 | |
37 | if (loadingScreenWhenReloading() || !scpContent.hasComponent()) |
38 | scpContent.set(makeLoadingScreen()); |
39 | |
40 | try { |
41 | scpContent.set(wrap(makeContent?!)); |
42 | } catch print e { |
43 | scpContent.set(jErrorView(e)); |
44 | } |
45 | } |
46 | |
47 | selfType addControl(S label, JComponent etc control) { |
48 | ret addControl(withLabel(label, control)); |
49 | } |
50 | |
51 | selfType addControl(JComponent etc control) { |
52 | controls.addComponent(control); |
53 | this; |
54 | } |
55 | |
56 | selfType content(IF0 makeContent) { |
57 | ret makeContent(makeContent); |
58 | } |
59 | |
60 | selfType addControlLine(JComponent newControls) { |
61 | scpControls.set(centerAndSouthWithMargin(scpControls!, newControls); |
62 | this; |
63 | } |
64 | } |
Began life as a copy of #1036191
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036474 |
Snippet name: | JContentAndControls |
Eternal ID of this version: | #1036474/29 |
Text MD5: | 5e3f74676772621b75a4a30b827024da |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-08-08 23:46:39 |
Source code size: | 1931 bytes / 64 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 210 / 390 |
Version history: | 28 change(s) |
Referenced in: | [show references] |