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

56
LINES

< > BotCompany Repo | #1036609 // G22TextsPanel (dev.)

JavaX fragment (include)

concept G22TextsPanel extends G22CRUDAndDetailPanel<G22Text> {
  transient volatile settable G22LAScriptIDE scriptIDE;
  
  SimpleCRUD_v2<G22Text> makeCRUD() {
    var crud = new SimpleCRUD_v2<>(g22utils.concepts(), G22Text);
    crud.noSubclasses(true);
    crud.entityName = -> "Script";
    g22utils.setupScriptCRUD(crud, true);
    
    // Full-text search baby!!
    var ts = crud.tableSearcher();
    var basicRowTester = ts.rowTester;
    ts.rowTester = if2ToF2((pat, map) -> {
      if (basicRowTester.get(pat, map)) true;
      
      long id = toLong(map.get(crud.hID));
      G22Text script = g22utils.getScript(id);
      if (anyContainsIgnoreCase(script.allTexts(), pat)) true;
      
      false;
    });
    
    crud.addButton(new JPopDownButton().content(
      "Show all scripts as one long text", rThread showHugeText));
    ret crud;
  }
  
  JComponent makeDetailView(G22Text script) {
    scriptIDE(new G22LAScriptIDE(g22utils));
    scriptIDE.setScript(script);
    ret scriptIDE.visualize();
  }
  
  SimpleCRUD_v2<G22Text> scriptCRUD() { ret crud(); }
  
  selfType g22utils(G22Utils g22utils) { super.g22utils(g22utils); this; }
  
  void showHugeText {
    S text = new G22ScriptUtil(g22utils).makeHugeText(g22utils.list(G22Text));
    showFrame("Scripts in project", g22utils.newSyntaxTextArea(text));
  }
  
  void edit(G22Text script, LineAndColumn lineAndCol) {
    edit(script);
    print(+scriptIDE);
    print("Waiting for script IDE to appear for " + script);
    var ide = pollWaitUntilNotNull(100, 5.0, -> {
      if (scriptIDE == null) null;
      if (scriptIDE.script() != script) null;
      ret scriptIDE;
    });
 
    print("Going to position " + lineAndCol + " in " + ide);
    ide?.goToPositionInAllModes(lineAndCol);
  }
}

Author comment

Began life as a copy of #1034599

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

-
Snippet ID: #1036609
Snippet name: G22TextsPanel (dev.)
Eternal ID of this version: #1036609/1
Text MD5: aeb1202270fcb5e1ce9769beb4fa2f83
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-04-27 18:40:19
Source code size: 1823 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 137 / 148
Referenced in: