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

25
LINES

< > BotCompany Repo | #1022677 // selectSubdirOrCreateNew

JavaX fragment (include)

1  
static Component selectSubdirOrCreateNew(File motherDir, final VF1<File> action) {
2  
  JList list = jlist(map f2s(listDirs(motherDir)));
3  
  
4  
  onDoubleClickOrEnter(list, voidfunc(S path) {
5  
    callFInNewThread(action, newFile(path));
6  
    disposePIFrame(list);
7  
  });
8  
  
9  
  JButton okButton = listDependentButton(list, "OK", r {
10  
    callFInNewThread(action, newFile(selectedItem(list)));
11  
    disposePIFrame(list);
12  
  });
13  
  
14  
  ret showFrame_returnContents("Choose a directory", centerAndSouthWithMargins(
15  
    withTitle("Please select a directory or create one", list),
16  
    
17  
    westAndEast(okButton, jbutton("Create directory...", r {
18  
      inputText("Name of new directory", voidfunc(S name) {
19  
        File f = mkdirs(newFile(motherDir, name));
20  
        fillListWithStrings(list, map f2s(listDirs(motherDir)));
21  
        selectItem(list, f2s(f));
22  
        focusComponent(okButton);
23  
      });
24  
    }))));
25  
}

Author comment

Began life as a copy of #1018756

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022677
Snippet name: selectSubdirOrCreateNew
Eternal ID of this version: #1022677/12
Text MD5: 2b8a9e75c63399a9ed0964e1ec294741
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-31 19:21:17
Source code size: 917 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 289 / 350
Version history: 11 change(s)
Referenced in: [show references]