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

!7

sclass VideosInDirectory extends DynSCP {
  new DynModuleRef mate;
  S dir;
  L<S> allFiles, videoFiles;
  
  transient DynamicHStack buttons;

  File dirObject() { ret newFile(dir); }
  
  JComponent visualize2() {
    if (buttons == null) { buttons = makeNiceButtons(); updateButtons(); }
    if (mate! == null) ret jcenteredlabel("Need directory");
    ret jHigherScrollPane(jfullcenter(buttons));
  }
  
  void update {
    lock lock;
    int oldChangeCount = mate! == null ? -1 : changeCount;
    try {
      if (mate! != null && !dm_moduleStillThere(mate!)) mate.set(null);
      if (mate! == null)
        if (setField(mate := DynModuleRef(print("Mate: ", dm_findMateOfType(this, 'DirectoryInfo)))))
          revisualize2();
      if (mate == null) ret;
      setField(dir := (S) call(mate!, 'getDir));
      L<S> allFiles = castCall(mate!, 'getFiles);
      if (this.allFiles != allFiles) {
        setField(+allFiles);
        setField(videoFiles := filterOrNull(allFiles, f isVideoFileName));
      }
    } finally {
      if (changeCount != oldChangeCount) updateButtons();
    }
  }
  
  void updateButtons {
    if (dir == null || buttons == null) ret with setModuleName("Videos in directory");
    L<TextImageAction> l = filesForNiceButtons(sortFilesByDate(
      fileNamesInDirToFile(new File(dir), videoFiles)), f dm_showVideo);
    for (final TextImageAction tia : l)
      tia.popupMenuMaker = VideosInDirectory_popupMenu(this, tia);
    replaceNiceButtons(buttons, l);
    setModuleName(videoFiles == null
      ? "Not allowed to look in directory " + fileName(dirObject())
      : n2(l, "video") + " in directory " + fileName(dirObject()));
  }
}

static VF1<JPopupMenu> VideosInDirectory_popupMenu(VideosInDirectory m, final TextImageAction tia) {
  // Haha, not even used
  //final WeakReference<VideosInDirectory> me = new(m);
  ret voidfunc(JPopupMenu menu) {
    final File f = filesForNiceButtons_map.get(tia);
  };
}

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