Search in sources :

Example 1 with ColumnItemTree

use of com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.ColumnItemTree in project Gargoyle by callakrsos.

the class DatabaseTreeCell method updateItem.

/*
	 * (non-Javadoc)
	 *
	 * @see
	 * javafx.scene.control.cell.TextFieldTreeCell#updateItem(java.lang.Object,
	 * boolean)
	 */
@SuppressWarnings("rawtypes")
@Override
public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
    if (empty) {
        setGraphic(null);
        setStyle(null);
    } else {
        if (item instanceof ColumnItemTree) {
            ColumnItemTree columnItemTree = (ColumnItemTree) item;
            if (columnItemTree.isPrimaryKey()) {
                //					setTextFill(Color.RED);
                setStyle("-fx-text-fill:RED");
            } else {
                //					setTextFill(Color.BLACK);
                setStyle("-fx-text-fill:BLACK");
            }
        } else {
            //				setTextFill(Color.BLACK);
            setStyle("-fx-text-fill:BLACK");
        }
        setText(item.toString());
    }
}
Also used : ColumnItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.ColumnItemTree)

Example 2 with ColumnItemTree

use of com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.ColumnItemTree in project Gargoyle by callakrsos.

the class DatabaseTreeNode method createNode.

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

        private boolean isLeaf;

        private boolean isFirstTimeChildren = true;

        private boolean isFirstTimeLeaf = true;

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

        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                DatabaseItemTree<String> f = getValue();
                isLeaf = (f instanceof ColumnItemTree);
            }
            return isLeaf;
        }

        private ObservableList<TreeItem<DatabaseItemTree<String>>> buildChildren(TreeItem<DatabaseItemTree<String>> treeItem) {
            DatabaseItemTree<String> f = treeItem.getValue();
            // if (treeItem.getChildren().isEmpty()) {
            if (f == null) {
                return FXCollections.emptyObservableList();
            } else {
                try {
                    f.read();
                } catch (GargoyleConnectionFailException e) {
                    LOGGER.error(ValueUtil.toString(e));
                    DialogUtil.showExceptionDailog(e);
                } catch (Exception e) {
                    LOGGER.error(ValueUtil.toString(e));
                    return FXCollections.emptyObservableList();
                }
            }
            if (f == null) {
                return FXCollections.emptyObservableList();
            }
            if (f instanceof ColumnItemTree) {
                return FXCollections.emptyObservableList();
            }
            ObservableList<TreeItem<DatabaseItemTree<String>>> files = f.getChildrens();
            if (files != null) {
                ObservableList<TreeItem<DatabaseItemTree<String>>> children = FXCollections.observableArrayList();
                for (TreeItem<DatabaseItemTree<String>> childFile : files) {
                    DatabaseItemTree<String> value = childFile.getValue();
                    TreeItem<DatabaseItemTree<String>> createNode = createNode(value);
                    children.add(createNode);
                }
                return children;
            }
            return FXCollections.emptyObservableList();
        }
    };
    Node imageNode = getGraphics(f);
    treeItem.setGraphic(imageNode);
    return treeItem;
}
Also used : TreeItem(javafx.scene.control.TreeItem) Node(javafx.scene.Node) DatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree) ColumnItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.ColumnItemTree) GargoyleConnectionFailException(com.kyj.fx.voeditor.visual.exceptions.GargoyleConnectionFailException) GargoyleConnectionFailException(com.kyj.fx.voeditor.visual.exceptions.GargoyleConnectionFailException)

Aggregations

ColumnItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.ColumnItemTree)2 DatabaseItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree)1 GargoyleConnectionFailException (com.kyj.fx.voeditor.visual.exceptions.GargoyleConnectionFailException)1 Node (javafx.scene.Node)1 TreeItem (javafx.scene.control.TreeItem)1