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

66
LINES

< > BotCompany Repo | #1034712 // G22VariablesPanel

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

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

srecord noeq G22VariablesPanel is Swingable {
  settable G22Utils g22utils;
  settable bool compactView;
  settable double updateInterval = 1.0;
  
  transient SimpleCRUD_v2<G22Variable> crud;
  transient SingleComponentPanel scpDetail;
  transient ReliableSingleThread rstUpdateDetail = rst(l0 _updateDetail);
  
  SimpleCRUD_v2<G22Variable> crud() {
    if (crud == null) {
      crud = new SimpleCRUD_v2<>(g22utils.concepts(), G22Variable);
      crud.updateInterval(updateInterval);
    }
    ret crud;
  }
  
  cachedVisualize {
    crud().iconButtons(true);
    crud.entityName = -> "Variable";
    crud.renderValue = l1 strOrNull; // no huge images (e.g. live feed) in variables table - too slow!
    //if (compactView) crud.hideField("persistent");
    
    crud.itemToMap_inner2 = var -> {
      var map = crud.itemToMap_inner2_base(var);
      if (var.big())
        map.put("Size on disk" := str_toKB(var.bigFile()));
      ret map;
    };

    var vis = jCenteredSection("Project Variables", crud.visualize());
    
    var cbPauseUpdates = jCheckBox("Pause updates");
    onChange(cbPauseUpdates, -> crud.pauseUpdates(isChecked(cbPauseUpdates)));
    crud.addButton(cbPauseUpdates);
    
    IVF1<G22Variable> rUpdate = v -> crud.update();
    bindToComponent(vis,
      -> g22utils.onBigVariableLoaded(rUpdate),
      -> g22utils.removeBigVariableLoadedListener(rUpdate));
    
    if (compactView) ret vis;
    
    crud.onSingleSelectionChanged(rstUpdateDetail);
    
    scpDetail = scp();
    ret jvsplit(vis, scpDetail);
  }
  
  void updateCount { crud().update(); }
  void setSelected(G22Variable var) { crud().setSelected(var); }

  void _updateDetail {  
    var var = crud.selected();
    if (var == null) ret with scpDetail.clear();
      
    O value = var.value();
    var vis = new G22JavaObjectVisualizer(g22utils, value).visualize();
    bindChangeListenerToComponent(vis, var.varValue(), -> {
      if (!eq(var.value(), value))
        rstUpdateDetail!;
    });
    
    scpDetail.set(jCenteredSection("Variable " + var.name, vis));
  }
}

Author comment

Began life as a copy of #1034599

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1034712
Snippet name: G22VariablesPanel
Eternal ID of this version: #1034712/26
Text MD5: 6b39b07a6ed53fdcfc19dfe40b396928
Transpilation MD5: 5bd06789949246f350f6c309eb2af307
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-17 18:43:31
Source code size: 2134 bytes / 66 lines
Pitched / IR pitched: No / No
Views / Downloads: 215 / 410
Version history: 25 change(s)
Referenced in: [show references]