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).

1  
!7
2  
3  
sclass SCP extends DynModule {
4  
  S link, dir;
5  
  L<SCPFile> files; 
6  
  bool inForm = true;
7  
  
8  
  transient JTextField tfLink, tfDir;
9  
  transient JList list;
10  
  
11  
  void start { fetch(); }
12  
  
13  
  JComponent visualize() {
14  
    if (tfLink == null) tfLink = jtextfield("root@butter.botcompany.de");
15  
    if (tfDir == null) tfDir = jtextfield("/root");
16  
    if (inForm) ret renameSubmitButton("Connect", makeForm(
17  
      "User@Host", tfLink, 
18  
      "Remote directory", tfDir,
19  
      disableButtonWhileCalcing(func -> bool {
20  
        setFields(link := getTextTrim(tfLink), dir := getTextTrim(tfDir));
21  
        if (!fetch()) false;
22  
        revisualize();
23  
        true;
24  
      })));
25  
      
26  
    // We're logged in, show list
27  
    
28  
    list = jlist(collect(files, 'path));
29  
    ret jSection(link + ":" + dir, list);
30  
  }
31  
  
32  
  bool fetch() {
33  
    int i = indexOf(link, '@');
34  
    if (i < 0) false;
35  
    setField(files := map scpFileFromLibrary(scpLS(takeFirst(link, i), substring(link, i+1), dir)));
36  
    setField(inForm := false);
37  
    true;
38  
  }
39  
  
40  
  void enhanceFrame(Container f) {
41  
    frameTitlePopupMenuItems(f,
42  
      "Back To Form", r backToForm,
43  
      "Clear Error", r clearError);
44  
  }
45  
  
46  
  void backToForm {
47  
    setField(inForm := true);
48  
    revisualize();
49  
  }
50  
}

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: 260 / 387
Version history: 2 change(s)
Referenced in: [show references]