Search in sources :

Example 21 with TreeItem

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);
}
Also used : TypeController(controller.controller.TypeController) AlertType(javafx.scene.control.Alert.AlertType) ButtonType(javafx.scene.control.ButtonType) Type(model.Type) Category(model.Category) TreeItem(javafx.scene.control.TreeItem)

Example 22 with TreeItem

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);
}
Also used : TypeController(controller.controller.TypeController) AlertType(javafx.scene.control.Alert.AlertType) ButtonType(javafx.scene.control.ButtonType) Type(model.Type) TreeItem(javafx.scene.control.TreeItem) Folder(model.Folder)

Example 23 with TreeItem

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();
}
Also used : TypeController(controller.controller.TypeController) TreeItem(javafx.scene.control.TreeItem)

Example 24 with TreeItem

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);
    }
}
Also used : TypeController(controller.controller.TypeController) Type(model.Type) TreeItem(javafx.scene.control.TreeItem)

Example 25 with TreeItem

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();
        }
    };
}
Also used : TreeItem(javafx.scene.control.TreeItem) File(java.io.File)

Aggregations

TreeItem (javafx.scene.control.TreeItem)76 File (java.io.File)15 TreeView (javafx.scene.control.TreeView)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 ObjectProperty (javafx.beans.property.ObjectProperty)9 MenuItem (javafx.scene.control.MenuItem)9 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)7 IOException (java.io.IOException)7 FXCollections (javafx.collections.FXCollections)7 ListChangeListener (javafx.collections.ListChangeListener)7 ObservableList (javafx.collections.ObservableList)7 ActionEvent (javafx.event.ActionEvent)7 ContextMenu (javafx.scene.control.ContextMenu)7 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)6 FXML (javafx.fxml.FXML)6 Button (javafx.scene.control.Button)6