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

68
LINES

< > BotCompany Repo | #1005741 // File Exchange [a persistent clipboard]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (7792L/54K/180K).

!752

concepts.

concept FileRef {
  S path;
  long touched;
}

static JTable table;

p-substance {
  concepts();
  update();
  awtOnConceptChanges(table, "update", false);
  hideConsoleIfMainProgram();
  dbBot();
}

svoid update {
  bool first = table == null;
  L data = map(sortedByFieldDesc(list(FileRef), "touched"), func(FileRef f) {
    Map map = litorderedmap("Path" := f.path);
    pcall {
      File file = new File(f.path);
      S type;
      if (file.isFile()) {
        type = "File";
        map.put("Size", file.length());
      } else if (file.isDirectory())
        type = "Directory";
      else
        type = "Not found";
      map.put("Type", type);
    }
    ret map;
  });
  table = showTable(data, table);
  
  if (first) {
    addToWindow(table, jbutton("Add file or directory...", r {
      addFile();
    }));
    
    tablePopupMenu(table, voidfunc(JPopupMenu menu, int row) {
      Map map = getTableLineAsMap(table, row);
      S path = (S) map.get("Path");
      final File file = new File(path);
      if (file.isDirectory())
        addMenuItem(menu, "Browse", r { browseDir(file) });
    });
  }
}

svoid addFile() {
  final new JTextField tf;
  showFormTitled("Add file or directory",
    "File/directory path", tf,
    r {
      S path = tf.getText().trim();
      if (!isAbsolutePath(path)) {
        messageBox("Please enter an absolute path.");
        addFile();
        ret;
      }
      cset(uniq(FileRef, +path), touched := now());
    });
}

Author comment

Began life as a copy of #1005728

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1005741
Snippet name: File Exchange [a persistent clipboard]
Eternal ID of this version: #1005741/1
Text MD5: 96547342ff81908ccb27449c894f7bd1
Transpilation MD5: f19ee4729aec5d0ed3441da777a18b18
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-05 22:39:01
Source code size: 1553 bytes / 68 lines
Pitched / IR pitched: No / No
Views / Downloads: 666 / 748
Referenced in: