use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.
the class H2TableItemTree method applyChildren.
// private static final int GETPRIMARY_KEY_SEQ = 5;
// private static final int GETPRIMARY_PRIMARYKEY_NAME = 6;
@Override
public ObservableList<TreeItem<DatabaseItemTree<String>>> applyChildren(Connection con, String... args) throws Exception {
DatabaseMetaData metaData = con.getMetaData();
ResultSet tables = metaData.getColumns(null, args[0], args[1], "%");
Set<String> primaryKeySet = toSet(metaData.getPrimaryKeys(null, args[0], args[1]), COLUMN_NAME);
ObservableList<TreeItem<DatabaseItemTree<String>>> observableArrayList = FXCollections.observableArrayList();
while (tables.next()) {
/*
* references
* http://docs.oracle.com/javase/6/docs/api/java/sql/ DatabaseMetaData.html#getTables%28java.lang.String,%20java.lang. String,%20java.lang.String,%20java.lang.String%5b%5d%29
*/
String columnName = tables.getString(COLUMN_NAME);
SqliteColumnItemTree coumnItem = new SqliteColumnItemTree(this, columnName);
coumnItem.setPrimaryKey(primaryKeySet.contains(columnName));
TreeItem<DatabaseItemTree<String>> treeItem = new TreeItem<>(coumnItem);
observableArrayList.add(treeItem);
}
return observableArrayList;
}
use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.
the class SchemaItemTree method read.
/*
* (non-Javadoc)
*
* @see
* com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree
* #read()
*/
@Override
public void read() throws Exception {
String childrenSQL = getChildrenSQL(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 {
// 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, 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 FxControlsTreeItem method createNode.
/**
* 파일 트리를 생성하기 위한 노드를 반환한다.
*
* @Date 2015. 10. 14.
* @param f
* @return
* @User KYJ
*/
public TreeItem<Node> createNode(final Node f) {
TreeItem<Node> treeItem = new TreeItem<Node>(f) {
private boolean isLeaf;
private boolean isFirstTimeChildren = true;
private boolean isFirstTimeLeaf = true;
@Override
public ObservableList<TreeItem<Node>> getChildren() {
if (isFirstTimeChildren) {
isFirstTimeChildren = false;
super.getChildren().setAll(buildChildren(this));
}
return super.getChildren();
}
@Override
public boolean isLeaf() {
if (isFirstTimeLeaf) {
isFirstTimeLeaf = false;
Node f = getValue();
if (f == null) {
isLeaf = true;
} else if (f instanceof Control) {
isLeaf = ((Control) f).getChildrenUnmodifiable().isEmpty();
} else if (f instanceof Parent) {
isLeaf = ((Parent) f).getChildrenUnmodifiable().isEmpty();
} else if (f instanceof Shape)
isLeaf = true;
else
isLeaf = false;
}
return isLeaf;
}
private ObservableList<TreeItem<Node>> buildChildren(TreeItem<Node> treeItem) {
Node f = treeItem.getValue();
if (f == null) {
return FXCollections.emptyObservableList();
}
treeItem.setGraphic(new HBox(/* new CheckBox(), */
getImage(getName(f))));
List<Node> childrens = getChildrens(f);
if (childrens == null || childrens.isEmpty()) {
return FXCollections.emptyObservableList();
} else {
ObservableList<TreeItem<Node>> children = FXCollections.observableArrayList();
for (Node child : childrens) {
children.add(createNode(child));
}
return children;
}
}
};
treeItem.setGraphic(new HBox(/* new CheckBox(), */
getImage(getName(f))));
return treeItem;
}
use of javafx.scene.control.TreeItem in project Challenger4SysAdmins by fvarrui.
the class TreeItemFactory method createChallengeTreeItem.
/**
* @param challenge un chellenge
* @return un item
*/
public static TreeItem<Object> createChallengeTreeItem(Challenge challenge) {
TreeItem<Object> challengeItem = new TreeItem<Object>();
challengeItem.setExpanded(true);
challengeItem.setValue(challenge);
for (Goal goal : challenge.getGoals()) {
challengeItem.getChildren().add(createGoalTreeItem(goal));
}
challenge.goalsProperty().addListener(new ListChangeListener<Goal>() {
public void onChanged(Change<? extends Goal> c) {
while (c.next()) {
c.getAddedSubList().stream().forEach(g -> challengeItem.getChildren().add(createGoalTreeItem(g)));
c.getRemoved().stream().forEach(g -> {
TreeItem<Object> item = challengeItem.getChildren().stream().filter(i -> i.getValue().equals(g)).findFirst().get();
challengeItem.getChildren().remove(item);
});
}
}
});
return challengeItem;
}
use of javafx.scene.control.TreeItem in project Challenger4SysAdmins by fvarrui.
the class TreeItemFactory method createTestTreeItem.
/**
* @param test un test
* @return un item de tipo test
*/
public static TreeItem<Object> createTestTreeItem(Test test) {
TreeItem<Object> testItem = new TreeItem<Object>();
testItem.setExpanded(true);
testItem.setValue(test);
if (test instanceof TestGroup) {
TestGroup ct = (TestGroup) test;
for (Test t : ct.getTests()) {
testItem.getChildren().add(createTestTreeItem(t));
}
ct.testsProperty().addListener(new ListChangeListener<Test>() {
public void onChanged(Change<? extends Test> c) {
while (c.next()) {
c.getAddedSubList().stream().forEach(g -> testItem.getChildren().add(createTestTreeItem(g)));
c.getRemoved().stream().forEach(g -> {
TreeItem<Object> item = testItem.getChildren().stream().filter(i -> i.getValue().equals(g)).findFirst().get();
testItem.getChildren().remove(item);
});
}
}
});
} else if (test instanceof CommandTest) {
CommandTest ct = (CommandTest) test;
if (ct.getCommand() != null) {
testItem.getChildren().add(createCommandTreeItem(ct.getCommand()));
}
ct.commandProperty().addListener((o, ov, nv) -> {
if (nv != null) {
testItem.getChildren().add(createCommandTreeItem(ct.getCommand()));
} else {
testItem.getChildren().clear();
}
});
}
return testItem;
}
Aggregations