use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.
the class ProjectFileTreeItemCreator method createJavaProjectMemberNode.
public TreeItem<FileWrapper> createJavaProjectMemberNode(final FileWrapper f) {
TreeItem<FileWrapper> treeItem = new JavaProjectMemberFileTreeItem(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_MEMBER));
}
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;
}
};
treeItem.expandedProperty().addListener((oba, oldval, newval) -> {
FileWrapper value = f;
File file = value.getFile();
if (newval) {
cacheExpaned.add(file);
} else {
cacheExpaned.remove(file);
}
});
if (cacheExpaned.contains(f.getFile())) {
treeItem.setExpanded(true);
}
return treeItem;
}
use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.
the class ProjectFileTreeItemCreator method buildChildren.
private ObservableList<TreeItem<FileWrapper>> buildChildren(TreeItem<FileWrapper> treeItem, FILE_TREE_TYPE type) {
FileWrapper f = treeItem.getValue();
boolean isParentSvnConnected = f.isSVNConnected();
File parentWcDbFile = f.getWcDbFile();
if (f == null) {
return FXCollections.emptyObservableList();
}
if (f.isFile()) {
return FXCollections.emptyObservableList();
}
File[] files = f.listFiles();
if (files != null) {
ObservableList<TreeItem<FileWrapper>> children = FXCollections.observableArrayList();
switch(type) {
case NOMAL:
for (File childFile : files) {
TreeItem<FileWrapper> createNode = createDefaultNode(createFileWrapper(childFile));
children.add(createNode);
}
break;
case JAVA_PROJECT:
for (File childFile : files) {
TreeItem<FileWrapper> createNode = createJavaProjectMemberNode(createFileWrapper(childFile, fw -> {
fw.setWcDbFile(parentWcDbFile);
fw.setSVNConnected(isParentSvnConnected);
}));
children.add(createNode);
}
break;
case JAVA_PROJECT_MEMBER:
for (File childFile : files) {
TreeItem<FileWrapper> createNode = createJavaProjectMemberNode(createFileWrapper(childFile, fw -> {
fw.setWcDbFile(parentWcDbFile);
fw.setSVNConnected(isParentSvnConnected);
}));
children.add(createNode);
}
break;
}
return children;
}
return FXCollections.emptyObservableList();
}
use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.
the class ProjectFileTreeItemCreator method createFileNode.
public TreeItem<FileWrapper> createFileNode(final FileWrapper f) {
return new FileTreeItem(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.NOMAL));
}
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;
}
};
}
use of javafx.scene.control.TreeItem in project Gargoyle by callakrsos.
the class CheckBoxFxControlsTreeItem method createNode.
/**
* 파일 트리를 생성하기 위한 노드를 반환한다.
*
* @Date 2015. 10. 14.
* @param f
* @return
* @User KYJ
*/
public TreeItem<Node> createNode(final Node f) {
TreeItem<Node> treeItem = new CheckBoxTreeItem<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(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(getImage(getName(f)));
return treeItem;
}
use of javafx.scene.control.TreeItem in project org.csstudio.display.builder by kasemir.
the class WidgetTree method setSelectedWidgets.
/**
* Called by selection handler when selected widgets have changed, or on new model
* @param widgets Widgets to select in tree
*/
public void setSelectedWidgets(final List<Widget> widgets) {
if (!active.compareAndSet(false, true))
return;
try {
final MultipleSelectionModel<TreeItem<WidgetOrTab>> selection = tree_view.getSelectionModel();
selection.clearSelection();
for (Widget widget : widgets) selection.select(widget2tree.get(widget));
// If something's selected, show it.
// Otherwise leave tree at current position.
final int index = selection.getSelectedIndex();
if (index >= 0)
tree_view.scrollTo(index);
} finally {
active.set(false);
}
}
Aggregations