Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

52
LINES

< > BotCompany Repo | #1035920 // G22ShowCasePanel

JavaX fragment (include) [tags: use-pretranspiled]

Uses 2164K of libraries. Click here for Pure Java version (70026L/371K).

srecord noeq G22ShowCasePanel(G22Utils g22utils) is Swingable {
  transient SingleComponentPanel scpShowCase;
  transient ReliableSingleThread rstUpdateShowCase = rst(l0 updateShowCase);
  
  void updateShowCase() {
    if (!isShowing(scpShowCase)) ret;
    var autoStarter = g22utils.autoStarter();
    if (autoStarter.cancelled())
      ret with scpShowCase.set(jcenteredlabel("Auto-start cancelled"));
    if (!autoStarter.waitedAndDone()) ret;
    var script = varShowCasedScript()!;
    
    if (script == null)
      ret with scpShowCase.set(g22utils.jGazelleLogo());
      
    scpShowCase.set(g22utils.visualizeAutoRunnableScript(script));
  }
  
  IVarWithNotify<G22LeftArrowScript> varShowCasedScript() {
    ret g22utils.projectActions().varShowCasedScript();
  }
  
  cachedVisualize {
    g22utils.autoStarter().onDone(rstUpdateShowCase);
    scpShowCase = singleComponentPanel(
      varShowCasedScript()! == null ? null : jcenteredlabel("Waiting for auto-start to finish..."));
    onChange(varShowCasedScript(), rstUpdateShowCase);
    bindToComponent(scpShowCase, rstUpdateShowCase);
      
    // LAYOUT
    
    ret
      northAndCenterWithMargin(
        centerAndEastWithMargin(
          // combo box (script selector)
          
          withSideMargins(withLabel("Script:", bindComboBoxToVar(varShowCasedScript(),
            swing(-> centerComboBoxAndItems(new ConceptsComboBox<>(g22utils.concepts(), G22LeftArrowScript)
              .allowNull(true)
              .itemFilter(script -> classIs(G22LeftArrowScript, script) && script.isClearForAutoRun())
              .sorter(l -> sortedByFieldAlphanumIC description(l))
          ))))),
          jline(
            jimageButton(#1101440, "Re-run script", rstUpdateShowCase),
            g22utils.editButton("Edit script",
              -> g22utils.projectActions().editScript(varShowCasedScript()!))
          )
        ),
        scpShowCase
      );
  }
}

Author comment

Began life as a copy of #1034718

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035920
Snippet name: G22ShowCasePanel
Eternal ID of this version: #1035920/13
Text MD5: 8071b42faa061d3bac3bc70e705b2f20
Transpilation MD5: 780f243f892ad001fc106e68d0fc7be9
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-08-08 13:15:48
Source code size: 1987 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 240
Version history: 12 change(s)
Referenced in: [show references]