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

52
LINES

< > BotCompany Repo | #1019415 // Some Lists

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (10631L/56K).

!7

sclass NamedList {
  S name;
  L<S> lines;
}

cmodule SomeObjects > DynObjectTable<NamedList> {
  S globalID = aGlobalID();
  L<NamedList> lists = synchroList();
  
  transient SingleComponentPanel scp;
  
  start {
    itemToMap = func(NamedList l) -> Map { litorderedmap("Name" := l.name, lines := l(l.lines)) };
    defaultAction = voidfunc(final NamedList l) {
      final SimpleLiveValue<S> lvText = stringLiveValue(lines(l.lines));
      lvText.onChange(dm_rstWithPostDelay(module(), 1000, r { l.lines = lines(lvText!); blubberblub; }));
      setSCPComponent(scp, jSection("List: " + l.name, focusOnShow(jLiveValueWordWrapTypeWriterTextArea_bothWays(lvText))));
    };
    blubberblub;
  }
  
  void onPersisted {
    saveTextFile(javaxDataDir("Some Lists/" + globalID + ".struct"), dm_persistenceStruct());
  }
  
  void blubberblub { setData_force(lists); }
  
  visualize {
    JComponent c = super.visualize();
    ret jhsplit(withCenteredButtonsOnTop(c,
      "Add list..." := rThread {
        inputText("Name of new list", voidfunc(S name) {
          NamedList l = nu(NamedList, +name);
          lists.add(l); blubberblub;
          doubleClickItem(l);
        });
      },
      tableDependentButton(table, "Delete" := rThread {
        logQuoted(javaxDataDir("Some Lists/" + globalID + ".deleted"), struct(selected()));
        lists.remove(selected()); setSCPComponent(scp, emptyContent()); blubberblub;
      })
    ), scp = singleComponentPanel(emptyContent()));
  }
  
  JComponent emptyContent() { ret jSection("Content"); }
  
  enhanceFrame {
    titlePopupMenuItems(f, "Backup in: " + f2s(javaxDataDir("Some Lists/" + globalID + ".*")));
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019415
Snippet name: Some Lists
Eternal ID of this version: #1019415/30
Text MD5: 3fde2c452e8778acc85b2fe0a305f12b
Transpilation MD5: c346fafac3175b2a1ffbe12416195c93
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-26 22:35:32
Source code size: 1724 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 367 / 1901
Version history: 29 change(s)
Referenced in: [show references]