Libraryless. Click here for Pure Java version (18238L/112K).
sclass JForwardingLibDownloader is Swingable { transient SingleComponentPanel scp; settable S libraryName; // snippet ID of library required for this platform settable LS libIDs; settable S sizeInformation; // how big is the library? event addingLibraries(Cl<S> libIDs); bool supported() { ret nempty(libIDs()); } selfType forward(IF0<JComponent> forward) { this.forward = forward; this; } swappable JComponent forward() { ret vstackWithSpacing(flattenToList( jcenteredlabel(libraryName() + " enabled"), map(file -> jcenteredline(jFilePathLabel(file).visualize()), libFiles()), jbutton("Delete " + libraryName(), rThread { if (!swingConfirm("Really?")) ret; deleteFilesVerbose(libFiles()); scp.setComponent(makeComponent()); }))); } L<File> libFiles() { ret map DiskSnippetCache_getLibrary(libIDs()); } bool libDownloaded() { ret filesExist(libFiles()); } bool hasLib() { bool has = currentProgramHasLibraries(libFiles()); ret has; } void addLib() { if (supported()) { addingLibraries(libIDs()); if (addLibraries(libIDs())) print(libraryName() + " loaded: " + libIDs()); } } cachedVisualize { if (scp == null) scp = singleComponentPanel(makeComponent()); ret scp; } JComponent makeComponent() { if (!supported()) ret jcenteredlabel(libraryName() + " is not yet supported on your platform"); if (libDownloaded()) { addLib(); ret forward(); } else ret jfullcenter(centerAndEastWithMargin( jcenteredlabel("Download " + libraryName() + " for " + platformName() + appendBracketed(sizeInformation()) + "?"), jbuttonWithDisable("OK", r addLibWithProgressBar))); } void addLibWithProgressBar { scp.setComponent(jcenteredlabel("Downloading " + libraryName() + "...")); try { addLib(); scp.setComponent(forward()); } catch print e { scp.setComponent(jErrorView(e)); } } selfType libID(S libID) { ret libIDs(llNonNulls(libID)); } selfType libIDs(S... libIDs) { ret libIDs(asList(libIDs)); } void loadLibsIfDownloaded() { if (supported() && libDownloaded()) addLib(); } }
Began life as a copy of #1034410
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035134 |
Snippet name: | JForwardingLibDownloader |
Eternal ID of this version: | #1035134/24 |
Text MD5: | 0d7e9c8d202787ee45cc055446f4e54b |
Transpilation MD5: | aad96088ae4c89706f5e2d5e0fb511d3 |
Author: | stefan |
Category: | javax / video |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-11 23:53:05 |
Source code size: | 2380 bytes / 89 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 196 / 361 |
Version history: | 23 change(s) |
Referenced in: | [show references] |