FileSystemTree
classin packageklyn.gui.windows.filesystem
public class FileSystemTree extends TreeView
└ FileSystemTree

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
Properties
Modifier and Type Member Description
public property rootFolder
rootFolder as FolderPath
Optional sole root; null displays Path.roots().
public readonly property selectedPath
selectedPath as Path
Selected file or folder, or null.
public property useSystemIcons
useSystemIcons as Boolean
Uses OS icons for visible entries.
public property viewMode
viewMode as FileSystemViewMode
Controls context actions and all public mutation methods.
Inherited Properties
propertyInherited Properties from TreeView: activateExpandableNodes, emptyText, model, rootVisible, selectedNode, title
propertyInherited Properties from Widget: accentColor, acceptFileDrops, backgroundColor, borderColor, bottom, canFocus, cornerRadius, cursor, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isPressed, isTabStop, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, resolvedStyleCache, resolvedStyleCacheAppearanceMode, resolvedStyleCacheFont, resolvedStyleCacheRevision, resolvedStyleCacheStateKey, resolvedStyleCacheStyleClass, resolvedStyleCacheZoomRevision, right, size, sizePolicy, styleClass, toolTip, width, window, x, y
Events
Modifier and Type Member Description
public event changed
changed as ActionEvent
Emitted after a successful disk mutation, including when a subsequent view refresh fails.
Inherited Events
eventInherited Events from TreeView: nodeActivated, nodeContextRequested, selectionChanged
eventInherited Events from Widget: filesDropped, focusGained, focusLost, keyPressed, keyReleased, mouseMoved, mousePressed, mouseReleased, mouseWheel, paintRequested, resized
Constructors
Modifier and Type Member Description
public FileSystemTree
FileSystemTree(rootFolder as FolderPath = null)
Creates a collapsed, deferred tree with no recursive scan.
Methods
Modifier and Type Member Description
public createFile
createFile(parent as FolderPath, name as String) as FilePath
Creates an empty file without truncating an existing file.
public createFolder
createFolder(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 paint
paint(painter as Painter) as Void
Paints rows from cached icons and starts a finite worker for new visible types.
public refresh
refresh() as Void
Refreshes roots and visible expanded folders, retaining the selected path when available.
public refreshIcons
refreshIcons() as Void
Clears the 512-entry image/type cache without rescanning directories.
public removePath
removePath(path as Path, recursive as Boolean = true) as Void
Permanently removes an entry and selects its parent.
public renamePath
renamePath(path as Path, newName as String) as Path
Renames an entry within its current parent and selects its new path.
public selectPath
selectPath(path as Path) as Boolean
Opens every parent folder and selects and reveals a physical Path.
public override setBounds
setBounds(x as Int, y as Int, width as Int, height as Int) as Void
Resizes active modal overlays with the owning window's content area.
Inherited Methods
methodInherited Methods from TreeView: expandNode, refreshRows, selectNode
methodInherited Methods from Widget: applyThemeMetrics, blur, containsPoint, emitFilesDropped, emitFocusGained, emitFocusLost, emitKeyPressed, emitKeyReleased, emitMouseMoved, emitMousePressed, emitMouseReleased, emitMouseWheel, handleTabKey, notifyPaintRequested, paint, paintClipped, paintForeground, paintOverlay, preferredSizeIncludesContentZoom, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds