Search in sources :

Example 41 with TreeItem

use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.

the class TableItemTree method read.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.SchemaItemTree
	 * #read()
	 */
@Override
public void read() throws Exception {
    if (parent == null)
        return;
    String childrenSQL = getChildrenSQL(parent.getName(), getName());
    // Connection connection = getConnection();
    // try {
    // if (childrenSQL != null && !childrenSQL.isEmpty()) {
    // List<Map<String, Object>> select = DbUtil.select(connection,
    // childrenSQL);
    // childrens = applyChildren(select);
    //
    // if (childrens == null)
    // childrens = FXCollections.observableArrayList();
    // }
    // } finally {
    // if (connection != null)
    // connection.close();
    // }
    Connection connection = getConnection();
    if (connection == null)
        throw new GargoyleConnectionFailException("connect fail...");
    try {
        if (childrenSQL != null && !childrenSQL.isEmpty()) {
            List<Map<String, Object>> select = DbUtil.select(connection, childrenSQL);
            childrens.addAll(applyChildren(select));
        }
        //			if (childrens == null)
        //				childrens = FXCollections.observableArrayList();
        // SQL로 불가능한 처리는 Connection을 받아 처리하도록한다.
        ObservableList<TreeItem<DatabaseItemTree<T>>> second = applyChildren(connection, parent.getName(), getName());
        if (second != null)
            childrens.addAll(second);
    } finally {
        if (connection != null)
            connection.close();
    }
}
Also used : TreeItem(javafx.scene.control.TreeItem) Connection(java.sql.Connection) Map(java.util.Map) GargoyleConnectionFailException(com.kyj.fx.voeditor.visual.exceptions.GargoyleConnectionFailException)

Example 42 with TreeItem

use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.

the class SystemLayoutViewController method search.

public TreeItem<FileWrapper> search(File f) {
    TreeItem<FileWrapper> root = treeProjectFile.getRoot();
    Path p = FileUtil.toRelativizeForGagoyle(f);
    String[] split = StringUtils.split(p.toString(), File.separator);
    boolean isFound = false;
    ObservableList<TreeItem<FileWrapper>> children = root.getChildren();
    int sliding = 0;
    TreeItem<FileWrapper> treeItem = null;
    for (int i = 0; i < split.length; i++) {
        isFound = false;
        for (TreeItem<FileWrapper> w : children) {
            treeItem = w;
            String name = treeItem.getValue().getFile().getName();
            if (split[sliding].equals(name)) {
                isFound = true;
                break;
            }
        }
        if (isFound) {
            children = treeItem.getChildren();
            sliding++;
        } else {
            // 아예못찾은경우는 종료.
            break;
        }
    }
    return treeItem;
}
Also used : Path(java.nio.file.Path) JavaProjectFileTreeItem(com.kyj.fx.voeditor.visual.component.JavaProjectFileTreeItem) TreeItem(javafx.scene.control.TreeItem) JavaProjectMemberFileTreeItem(com.kyj.fx.voeditor.visual.component.JavaProjectMemberFileTreeItem) FileWrapper(com.kyj.fx.voeditor.visual.component.FileWrapper)

Example 43 with TreeItem

use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.

the class CustomSkinConfigView method load.

/**
	 * Load TreeItem
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 12. 2.
	 * @param item
	 */
private void load(ConfigurationTreeItem item) {
    if (item != null) {
        if (item instanceof ConfigurationGraphicsNodeItem) {
            ConfigurationGraphicsNodeItem node = (ConfigurationGraphicsNodeItem) item;
            if (node.getCustomOpenStyle() != null) {
                Consumer<Class<?>> customOpenStyle = node.getCustomOpenStyle();
                customOpenStyle.accept(node.getContentNode());
            } else if (node.getContentNode() != null) {
                Class<?> cont = node.getContentNode();
                try {
                    Object newInstance = cont.newInstance();
                    if (newInstance instanceof Parent) {
                        FxUtil.createStageAndShow((Parent) newInstance, stage -> {
                            stage.initOwner(CustomSkinConfigView.this.getScene().getWindow());
                            stage.setTitle(node.getItemName());
                        });
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) TreeItem(javafx.scene.control.TreeItem) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) TreeTableRow(javafx.scene.control.TreeTableRow) Parent(javafx.scene.Parent) TreeTableView(javafx.scene.control.TreeTableView) Callback(javafx.util.Callback) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) FontViewComposite(com.kyj.fx.voeditor.visual.component.font.FontViewComposite) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) ConfigItemTreeItem(com.kyj.fx.voeditor.visual.component.ConfigItemTreeItem) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Consumer(java.util.function.Consumer) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) TreeTableColumn(javafx.scene.control.TreeTableColumn) ConfigurationLeafNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem) ConfigurationGraphicsNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) BorderPane(javafx.scene.layout.BorderPane) ConfigurationGraphicsNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem) Parent(javafx.scene.Parent) URISyntaxException(java.net.URISyntaxException)

Example 44 with TreeItem

use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.

the class ConfigItemTreeItem method createNode.

/**
	 * 파일 트리를 생성하기 위한 노드를 반환한다.
	 *
	 * @Date 2015. 10. 14.
	 * @param f
	 * @return
	 * @User KYJ
	 */
public TreeItem<ConfigurationTreeItem> createNode(final ConfigurationTreeItem f) {
    TreeItem<ConfigurationTreeItem> treeItem = new TreeItem<ConfigurationTreeItem>(f) {

        private boolean isLeaf;

        private boolean isFirstTimeChildren = true;

        private boolean isFirstTimeLeaf = true;

        @Override
        public ObservableList<TreeItem<ConfigurationTreeItem>> getChildren() {
            if (isFirstTimeChildren) {
                isFirstTimeChildren = false;
                super.getChildren().setAll(buildChildren(this));
            }
            return super.getChildren();
        }

        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                ConfigurationTreeItem f = getValue();
                if (f instanceof ConfigurationLeafNodeItem)
                    isLeaf = true;
                else
                    isLeaf = false;
            }
            return isLeaf;
        }

        private ObservableList<TreeItem<ConfigurationTreeItem>> buildChildren(TreeItem<ConfigurationTreeItem> treeItem) {
            ConfigurationTreeItem f = treeItem.getValue();
            if (f == null) {
                return FXCollections.emptyObservableList();
            }
            List<ConfigurationTreeItem> childrens = f.getChildrens();
            if (childrens == null || childrens.isEmpty() || f instanceof ConfigurationLeafNodeItem) {
                return FXCollections.emptyObservableList();
            } else {
                ObservableList<TreeItem<ConfigurationTreeItem>> children = FXCollections.observableArrayList();
                for (ConfigurationTreeItem child : childrens) {
                    TreeItem<ConfigurationTreeItem> createNode = createNode(child);
                    createNode.setExpanded(true);
                    children.add(createNode);
                }
                return children;
            }
        }
    };
    return treeItem;
}
Also used : ConfigurationLeafNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) TreeItem(javafx.scene.control.TreeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem)

Example 45 with TreeItem

use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.

the class ProjectFileTreeItemCreator method createJavaProjectNode.

public TreeItem<FileWrapper> createJavaProjectNode(final FileWrapper f) {
    return new JavaProjectFileTreeItem(f) {

        private boolean isLeaf;

        private boolean isFirstTimeChildren = true;

        private boolean isFirstTimeLeaf = true;

        @Override
        public ObservableList<TreeItem<FileWrapper>> getChildren() {
            if (isFirstTimeChildren) {
                isFirstTimeChildren = false;
                super.getChildren().setAll(buildChildren(this, FILE_TREE_TYPE.JAVA_PROJECT));
            }
            return super.getChildren();
        }

        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                FileWrapper f = (FileWrapper) getValue();
                File file = f.getFile();
                if (file.isDirectory()) {
                    isLeaf = file.list().length == 0 ? true : false;
                } else {
                    isLeaf = f.isFile();
                }
            }
            return isLeaf;
        }
    };
}
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