public class FileSystemTree extends TreeView
Browses physical directories and regular files from filesystem roots. With no rootFolder, Windows shows logical drives and Unix shows /. Supplying a folder limits browsing and mutations to that subtree. There are no shell shortcuts, libraries or other virtual filesystem entries. Symbolic links and special files are excluded, including linked ancestors. Hidden files are included. Directories precede files, each sorted by name.
Direct children are loaded synchronously only when opening their folder, and retained until an explicit refresh. Painting, scrolling and selection within an already loaded branch perform no directory enumeration. Loading a directory costs O(entries * log(entries)) time and O(entries) metadata; selecting a path loads its ancestors, never unrelated subtrees.
Visible rows request native OS icons asynchronously, shared by file type, size and folder state. Windows executables/.ico files and logical volumes have path-specific keys. The bounded cache includes missing icons, so an unavailable desktop service is not retried on every paint. No thumbnails or icon lookup are performed while painting. Colored vector icons remain usable until the OS snapshot arrives, and when that service is unavailable.
READ_ONLY is the default. READ_WRITE adds New Folder, New File, Rename and Remove context actions, plus F2, Delete and Ctrl+Shift+N. Removal asks for confirmation and permanently deletes the selected entry and its contents. Filesystem roots and the configured root cannot be renamed or removed. F5 refreshes visible expanded branches, preserving selection when possible. The inherited selectionChanged and nodeActivated events expose selectedPath.
import klyn.gui.windows.filesystem import klyn.io tree = FileSystemTree() tree.selectPath(Path.cwd) tree.viewMode = FileSystemViewMode.READ_WRITE
| Modifier and Type | Member | Description |
|---|---|---|
| public property | rootFolderrootFolder as FolderPath |
Optional sole root; null displays Path.roots(). |
| public readonly property | selectedPathselectedPath as Path |
Selected file or folder, or null. |
| public property | useSystemIconsuseSystemIcons as Boolean |
Uses OS icons for visible entries. |
| public property | viewModeviewMode as FileSystemViewMode |
Controls context actions and all public mutation methods. |
| Modifier and Type | Member | Description |
|---|---|---|
| public event | changedchanged as ActionEvent |
Emitted after a successful disk mutation, including when a subsequent view refresh fails. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | FileSystemTreeFileSystemTree(rootFolder as FolderPath = null) |
Creates a collapsed, deferred tree with no recursive scan. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | createFilecreateFile(parent as FolderPath, name as String) as FilePath |
Creates an empty file without truncating an existing file. |
| public | createFoldercreateFolder(parent as FolderPath, name as String) as FolderPath |
Creates a direct subfolder, refreshes only its parent's branch and selects the new entry. |
| public override | paintpaint(painter as Painter) as Void |
Paints rows from cached icons and starts a finite worker for new visible types. |
| public | refreshrefresh() as Void |
Refreshes roots and visible expanded folders, retaining the selected path when available. |
| public | refreshIconsrefreshIcons() as Void |
Clears the 512-entry image/type cache without rescanning directories. |
| public | removePath | Permanently removes an entry and selects its parent. |
| public | renamePath | Renames an entry within its current parent and selects its new path. |
| public | selectPath | Opens every parent folder and selects and reveals a physical Path. |
| public override | setBounds | Resizes active modal overlays with the owning window's content area. |