use of javafx.scene.control.TreeItem in project uPMT by coco35700.
the class TypeTreeView method addClass.
// method used to add a class to the current cell
public void addClass(int classNumber) {
TreeItem<TypeController> newTypeController = new TreeItem<TypeController>();
Type nt = new Category("Classe " + classNumber);
TypeController tc;
if (getItem().getType().getClass().equals(Schema.class)) {
tc = new TypeController(nt, getTreeItem().getValue().getType());
} else {
tc = new TypeController(nt, getTreeItem().getParent().getValue().getType());
}
newTypeController.setValue(tc);
getTreeItem().getChildren().add(newTypeController);
getItem().getType().getTypes().add(nt);
this.getTreeItem().setExpanded(true);
}
use of javafx.scene.control.TreeItem in project uPMT by coco35700.
the class TypeTreeView method addFolder.
// method used to add a folder to the current cell
public void addFolder(int folderNumber) {
TreeItem<TypeController> newTypeController = new TreeItem<TypeController>();
Type nt = new Folder("Dossier " + folderNumber);
TypeController tc;
if (getItem().getType().getClass().equals(Schema.class)) {
tc = new TypeController(nt, getTreeItem().getValue().getType());
} else {
tc = new TypeController(nt, getTreeItem().getParent().getValue().getType());
}
tc = new TypeController(nt, getTreeItem().getValue().getType());
newTypeController.setValue(tc);
getTreeItem().getChildren().add(newTypeController);
getItem().getType().getTypes().add(nt);
this.getTreeItem().setExpanded(true);
}
use of javafx.scene.control.TreeItem in project uPMT by coco35700.
the class RemovePropertyFromClassCommand method undo.
@Override
public void undo() {
controller.GetAddPropertySchemeWithValueController().update(oldp);
;
// adding the new property to the scheme
TreeItem<TypeController> newType = new TreeItem<TypeController>();
TypeController tc = new TypeController(oldp, controller.getType());
newType.setValue(tc);
tree.getChildren().add(newType);
// getItem().getType().getTypes().add(nt);
tree.setExpanded(true);
main.needToSave();
}
use of javafx.scene.control.TreeItem in project uPMT by coco35700.
the class SchemaTransformations method addTypeTreeView.
private static void addTypeTreeView(TreeItem<TypeController> tree, Type t) {
if (!t.getTypes().isEmpty()) {
TypeController tc = new TypeController(t, tree.getValue().getType());
TreeItem<TypeController> node = new TreeItem<TypeController>(tc);
node.setExpanded(true);
tree.getChildren().add(node);
for (Type s : t.getTypes()) {
addTypeTreeView(node, s);
}
} else {
TypeController tc = new TypeController(t, tree.getValue().getType());
TreeItem<TypeController> node = new TreeItem<TypeController>(tc);
tree.getChildren().add(node);
}
}
use of javafx.scene.control.TreeItem in project kanonizo by kanonizo.
the class GuiUtils method createDynamicFileTree.
public static TreeItem<File> createDynamicFileTree(File parent) {
return new TreeItem<File>(parent) {
private boolean isLeaf;
private boolean isFirstTimeChildren = true;
private boolean isFirstTimeLeaf = true;
@Override
public ObservableList<TreeItem<File>> getChildren() {
if (isFirstTimeChildren) {
isFirstTimeChildren = false;
super.getChildren().setAll(buildChildren(this));
}
return super.getChildren();
}
@Override
public boolean isLeaf() {
if (isFirstTimeLeaf) {
isFirstTimeLeaf = false;
File f = getValue();
isLeaf = f.isFile();
}
return isLeaf;
}
private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) {
File f = TreeItem.getValue();
if (f != null && f.isDirectory()) {
File[] files = f.listFiles((fn) -> !fn.getName().startsWith("."));
if (files != null) {
ObservableList<TreeItem<File>> children = FXCollections.observableArrayList();
for (File childFile : files) {
children.add(createDynamicFileTree(childFile));
}
return children;
}
}
return FXCollections.emptyObservableList();
}
};
}
Aggregations