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

57
LINES

< > BotCompany Repo | #1016311 // Videos In Directory [Dyn Module, dev.]

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

Libraryless. Click here for Pure Java version (15963L/113K).

1  
!7
2  
3  
sclass VideosInDirectory extends DynSCP {
4  
  new DynModuleRef mate;
5  
  S dir;
6  
  L<S> allFiles, videoFiles;
7  
  
8  
  transient DynamicHStack buttons;
9  
10  
  File dirObject() { ret newFile(dir); }
11  
  
12  
  JComponent visualize2() {
13  
    if (buttons == null) { buttons = makeNiceButtons(); updateButtons(); }
14  
    if (mate! == null) ret jcenteredlabel("Need directory");
15  
    ret jHigherScrollPane(jfullcenter(buttons));
16  
  }
17  
  
18  
  void update {
19  
    lock lock;
20  
    int oldChangeCount = mate! == null ? -1 : changeCount;
21  
    try {
22  
      if (mate! != null && !dm_moduleStillThere(mate!)) mate.set(null);
23  
      if (mate! == null)
24  
        if (setField(mate := DynModuleRef(print("Mate: ", dm_findMateOfType(this, 'DirectoryInfo)))))
25  
          revisualize2();
26  
      if (mate == null) ret;
27  
      setField(dir := (S) call(mate!, 'getDir));
28  
      L<S> allFiles = castCall(mate!, 'getFiles);
29  
      if (this.allFiles != allFiles) {
30  
        setField(+allFiles);
31  
        setField(videoFiles := filterOrNull(allFiles, f isVideoFileName));
32  
      }
33  
    } finally {
34  
      if (changeCount != oldChangeCount) updateButtons();
35  
    }
36  
  }
37  
  
38  
  void updateButtons {
39  
    if (dir == null || buttons == null) ret with setModuleName("Videos in directory");
40  
    L<TextImageAction> l = filesForNiceButtons(sortFilesByDate(
41  
      fileNamesInDirToFile(new File(dir), videoFiles)), f dm_showVideo);
42  
    for (final TextImageAction tia : l)
43  
      tia.popupMenuMaker = VideosInDirectory_popupMenu(this, tia);
44  
    replaceNiceButtons(buttons, l);
45  
    setModuleName(videoFiles == null
46  
      ? "Not allowed to look in directory " + fileName(dirObject())
47  
      : n2(l, "video") + " in directory " + fileName(dirObject()));
48  
  }
49  
}
50  
51  
static VF1<JPopupMenu> VideosInDirectory_popupMenu(VideosInDirectory m, final TextImageAction tia) {
52  
  // Haha, not even used
53  
  //final WeakReference<VideosInDirectory> me = new(m);
54  
  ret voidfunc(JPopupMenu menu) {
55  
    final File f = filesForNiceButtons_map.get(tia);
56  
  };
57  
}

Author comment

Began life as a copy of #1015922

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016311
Snippet name: Videos In Directory [Dyn Module, dev.]
Eternal ID of this version: #1016311/4
Text MD5: 28d78edffdd6b83acbb10216426dd069
Transpilation MD5: b103144584ebde56256ff1b0aae987f7
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-14 13:00:34
Source code size: 2004 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 329 / 531
Version history: 3 change(s)
Referenced in: [show references]