com.legyver.fenxlib.widgets.filetree.event.FileTreeRemoveEventHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fenxlib.widgets.filetree Show documentation
Show all versions of fenxlib.widgets.filetree Show documentation
FileTree widget for Fenxlib projects
package com.legyver.fenxlib.widgets.filetree.event;
import com.legyver.fenxlib.widgets.filetree.registry.FileTreeRegistry;
import com.legyver.fenxlib.widgets.filetree.tree.FileTreeItem;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
/**
* EventHandler to remove the selected item from the file tree
*/
public class FileTreeRemoveEventHandler implements EventHandler {
private final FileTreeRegistry fileTreeRegistry;
private final FileTreeItem fileTreeItem;
/**
* Construct an event handler to remove the selected item from the file tree
* @param fileTreeRegistry the registry for the file tree
* @param fileTreeItem the item to remove
*/
public FileTreeRemoveEventHandler(FileTreeRegistry fileTreeRegistry, FileTreeItem fileTreeItem) {
this.fileTreeRegistry = fileTreeRegistry;
this.fileTreeItem = fileTreeItem;
}
@Override
public void handle(ActionEvent event) {
fileTreeRegistry.remove(fileTreeItem.getUniqueIdentifier());
fileTreeItem.flagForRemoval();
FileTreeItem parent = (FileTreeItem) fileTreeItem.getParent();
parent.refresh();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy