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

25
LINES

< > BotCompany Repo | #1022677 // selectSubdirOrCreateNew

JavaX fragment (include)

static Component selectSubdirOrCreateNew(File motherDir, final VF1<File> action) {
  JList list = jlist(map f2s(listDirs(motherDir)));
  
  onDoubleClickOrEnter(list, voidfunc(S path) {
    callFInNewThread(action, newFile(path));
    disposePIFrame(list);
  });
  
  JButton okButton = listDependentButton(list, "OK", r {
    callFInNewThread(action, newFile(selectedItem(list)));
    disposePIFrame(list);
  });
  
  ret showFrame_returnContents("Choose a directory", centerAndSouthWithMargins(
    withTitle("Please select a directory or create one", list),
    
    westAndEast(okButton, jbutton("Create directory...", r {
      inputText("Name of new directory", voidfunc(S name) {
        File f = mkdirs(newFile(motherDir, name));
        fillListWithStrings(list, map f2s(listDirs(motherDir)));
        selectItem(list, f2s(f));
        focusComponent(okButton);
      });
    }))));
}

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: 287 / 347
Version history: 11 change(s)
Referenced in: [show references]