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

50
LINES

< > BotCompany Repo | #1019296 // SCP Module v2 (dev.)

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

Uses 9724K of libraries. Click here for Pure Java version (14639L/102K).

!7

sclass SCP extends DynModule {
  S link, dir;
  L<SCPFile> files; 
  bool inForm = true;
  
  transient JTextField tfLink, tfDir;
  transient JList list;
  
  void start { fetch(); }
  
  JComponent visualize() {
    if (tfLink == null) tfLink = jtextfield("root@butter.botcompany.de");
    if (tfDir == null) tfDir = jtextfield("/root");
    if (inForm) ret renameSubmitButton("Connect", makeForm(
      "User@Host", tfLink, 
      "Remote directory", tfDir,
      disableButtonWhileCalcing(func -> bool {
        setFields(link := getTextTrim(tfLink), dir := getTextTrim(tfDir));
        if (!fetch()) false;
        revisualize();
        true;
      })));
      
    // We're logged in, show list
    
    list = jlist(collect(files, 'path));
    ret jSection(link + ":" + dir, list);
  }
  
  bool fetch() {
    int i = indexOf(link, '@');
    if (i < 0) false;
    setField(files := map scpFileFromLibrary(scpLS(takeFirst(link, i), substring(link, i+1), dir)));
    setField(inForm := false);
    true;
  }
  
  void enhanceFrame(Container f) {
    frameTitlePopupMenuItems(f,
      "Back To Form", r backToForm,
      "Clear Error", r clearError);
  }
  
  void backToForm {
    setField(inForm := true);
    revisualize();
  }
}

Author comment

Began life as a copy of #1015951

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1019296
Snippet name: SCP Module v2 (dev.)
Eternal ID of this version: #1019296/3
Text MD5: 1ecf6dd8c840650da469431ccceb1490
Transpilation MD5: 45b60f83897ce750c0990aff7a96c6ce
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-12 13:21:35
Source code size: 1289 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 330 / 472
Version history: 2 change(s)
Referenced in: