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();
}
}
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;
}
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();
}
}
}
}
}
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;
}
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;
}
};
}
Aggregations