本文整理汇总了Java中javafx.scene.control.CheckBoxTreeItem类的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxTreeItem类的具体用法?Java CheckBoxTreeItem怎么用?Java CheckBoxTreeItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckBoxTreeItem类属于javafx.scene.control包,在下文中一共展示了CheckBoxTreeItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectTreeItemCheckBoxSelectedSelected
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
@Test public void selectTreeItemCheckBoxSelectedSelected() {
TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
treeItem.setSelected(true);
JSONObject o = new JSONObject();
o.put("select", "/Root node/Child Node 2");
IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
IJavaFXElement cb = item.findElementByCssSelector(".::editor");
cb.marathon_select("Child Node 2:checked");
new Wait("Wait for tree item check box to be selected") {
@Override public boolean until() {
String selected = cb.getAttribute("selected");
return selected.equals("true");
}
};
}
示例2: selectTreeItemCheckBoxSelectedNotSelected
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
@Test public void selectTreeItemCheckBoxSelectedNotSelected() {
TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
treeItem.setSelected(true);
JSONObject o = new JSONObject();
o.put("select", "/Root node/Child Node 2");
IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
IJavaFXElement cb = item.findElementByCssSelector(".::editor");
cb.marathon_select("Child Node 2:unchecked");
new Wait("Wait for tree item check box to be deselected") {
@Override public boolean until() {
String selected = cb.getAttribute("selected");
return selected.equals("false");
}
};
}
示例3: CheckBoxTreeViewSample
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
public CheckBoxTreeViewSample() {
final CheckBoxTreeItem<String> treeRoot = new CheckBoxTreeItem<String>("Root node");
treeRoot.getChildren().addAll(Arrays.asList(new CheckBoxTreeItem<String>("Child Node 1"),
new CheckBoxTreeItem<String>("Child Node 2"), new CheckBoxTreeItem<String>("Child Node 3")));
treeRoot.getChildren().get(2).getChildren()
.addAll(Arrays.asList(new CheckBoxTreeItem<String>("Child Node 4"), new CheckBoxTreeItem<String>("Child Node 5"),
new CheckBoxTreeItem<String>("Child Node 6"), new CheckBoxTreeItem<String>("Child Node 7"),
new TreeItem<String>("Child Node 8"), new CheckBoxTreeItem<String>("Child Node 9"),
new CheckBoxTreeItem<String>("Child Node 10"), new CheckBoxTreeItem<String>("Child Node 11"),
new CheckBoxTreeItem<String>("Child Node 12")));
final TreeView treeView = new TreeView();
treeView.setCellFactory(CheckBoxTreeCell.forTreeView());
treeView.setShowRoot(true);
treeView.setRoot(treeRoot);
treeRoot.setExpanded(true);
getChildren().add(treeView);
}
示例4: select
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
@Test public void select() {
TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
Point2D point = getPoint(treeView, 1);
RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
rfxListView.focusGained(rfxListView);
CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
treeItem.setSelected(true);
rfxListView.focusLost(rfxListView);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Child Node 1:checked", recording.getParameters()[0]);
}
示例5: selectSelectedTreeItemCheckBox
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
@Test public void selectSelectedTreeItemCheckBox() {
TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
Point2D point = getPoint(treeView, 1);
RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
treeItem.setSelected(true);
rfxListView.focusGained(rfxListView);
treeItem.setSelected(false);
rfxListView.focusLost(rfxListView);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Child Node 1:unchecked", recording.getParameters()[0]);
}
示例6: buildItem
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
private CheckBoxTreeItem<String> buildItem(Relation node) {
final CheckBoxTreeItem<String> item = new CheckBoxTreeItem<String>(node.getLabel());
item.setExpanded(true);
item.setIndependent(true);
item.setSelected(!node.isFold());
item.selectedProperty()
.addListener((o, p, c) -> {
node.setFold(!c);
});
node.getChildren()
.stream()
.filter(c -> c instanceof Relation)
.map(c -> (Relation) c)
.forEach(c -> {
item.getChildren()
.add(buildItem(c));
});
return item;
}
示例7: GitFileStatusTreeCell
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
public GitFileStatusTreeCell() {
super(
treeItem -> ((CheckBoxTreeItem<ModifiedPath>) treeItem).selectedProperty(),
CONVERTER
);
getStyleClass().add("git-file-status-tree-cell");
// set up pseudo style classes
unchanged = new SimpleBooleanProperty(false);
added = new SimpleBooleanProperty(false);
modified = new SimpleBooleanProperty(false);
removed = new SimpleBooleanProperty(false);
unchanged .addListener(c -> pseudoClassStateChanged(UNCHANGED, unchanged.get()));
added .addListener(c -> pseudoClassStateChanged(ADDED, added.get()));
modified .addListener(c -> pseudoClassStateChanged(MODIFIED, modified.get()));
removed .addListener(c -> pseudoClassStateChanged(REMOVED, removed.get()));
}
示例8: setTreeChildren
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
private void setTreeChildren(CheckBoxTreeItem<FileItem> parent){
FileItem parentItem = parent.getValue();
CopyOnWriteArrayList<FileItem> items = new CopyOnWriteArrayList<>(dataManager.getContent(parentItem));
for (FileItem i :items) {
if (i.isDir()){
CheckBoxTreeItem<FileItem> item = new CheckBoxTreeItem<>(i);
parent.getChildren().add(item);
setTreeChildren(item);
if (i.isSync()){
/*
нельзя сразу сделать setSelected(true) для элемента
ибо к ним не привяжется слушатель. Поэтому вначале добавляю их в список
и после инициализации TreeView делаю их selected
*/
selected.add(item);
}
}
}
}
示例9: selectionChecker
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
protected void selectionChecker(final Boolean selected) {
tree.waitState(new State<Boolean>() {
public Boolean reached() {
final Lookup<CheckBoxTreeItem> lookup = treeAsParent.lookup(CheckBoxTreeItem.class, new LookupCriteria<CheckBoxTreeItem>() {
public boolean check(CheckBoxTreeItem item) {
return getLevel(item) > 0;
}
});
for (int i = 0; i < lookup.size(); i++) {
final int _i = i;
if (selected != new GetAction<Boolean>() {
@Override
public void run(Object... os) throws Exception {
setResult(lookup.get(_i).isSelected());
}
}.dispatch(tree.getEnvironment())) {
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
}, Boolean.TRUE);
}
示例10: initialize
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
/**
* Native init method.
* Create VUFS folders tree view
* @param location
* @param resources
*/
@Override
public void initialize(URL location, ResourceBundle resources) {
//TODO: replace to getting elements from Repository
CheckBoxTreeItem<String> root = new CheckBoxTreeItem<>("Root");
root.setExpanded(true);
CheckBoxTreeItem<String> folder1 = new CheckBoxTreeItem<>("Folder1");
folder1.getChildren().addAll(
new CheckBoxTreeItem<>("MyFoto"),
new CheckBoxTreeItem<>("OtherFiles")
);
root.getChildren().addAll(
folder1,
new CheckBoxTreeItem<>("Documents"),
new CheckBoxTreeItem<>("WorkFiles"),
new CheckBoxTreeItem<>("Projects"));
// Create the CheckTreeView with the data
final CheckTreeView<String> checkTreeView = new CheckTreeView<>(root);
checkTreeView.getCheckModel().getCheckedItems().addListener((ListChangeListener<TreeItem<String>>) c -> {
System.out.println(checkTreeView.getCheckModel().getCheckedItems());
});
checkTreeView.setId("sync-tree-view");
container.getChildren().add(checkTreeView);
}
示例11: onPriorityAction
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
private void onPriorityAction(final RadioMenuItem priorityMenuItem) {
final CheckBoxTreeItem<TorrentFileEntry> treeItem = (CheckBoxTreeItem<TorrentFileEntry>)getTreeItem();
final FilePriority newPriorityValue = FilePriority.values()[Integer.parseInt(priorityMenuItem.getId())];
if(treeItem.getValue().getPriority() != newPriorityValue) {
if(treeItem.isIndeterminate()) {
treeItem.setSelected(true);
treeItem.getValue().selectedProperty().set(newPriorityValue != FilePriority.SKIP);
}
else {
treeItem.setSelected(newPriorityValue != FilePriority.SKIP);
}
if(!treeItem.isLeaf()) {
fileTreeViewer.onUpdateChildrenPriority(treeItem, newPriorityValue);
}
treeItem.getValue().priorityProperty().set(newPriorityValue);
fileTreeViewer.onUpdateParentPriority(treeItem.getParent());
fileTreeViewer.selectItem(treeItem);
}
}
示例12: addNewRepoFile
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
private void addNewRepoFile(RepoFile repoFile, CheckBoxTreeItem<RepoFile> newItem, TreeItem<RepoFile> root) {
Path pathToParent = repoFile.getFilePath().getParent();
if (pathToParent != null) {
// Check if the file should be added to an existing directory
CheckBoxTreeItem<RepoFile> parentDirectory = null;
for (TreeItem<RepoFile> directory : root.getChildren()) {
if (!directory.equals(checkBox) && directory.getValue().toString().equals(pathToParent.toString())) {
parentDirectory = (CheckBoxTreeItem<RepoFile>) directory;
break;
}
}
if (parentDirectory == null) {
// Create a new directory and add it to the root
DirectoryRepoFile parent = new DirectoryRepoFile(pathToParent, this.sessionModel.getCurrentRepoHelper());
parent.setShowFullPath(true);
parentDirectory = new CheckBoxTreeItem<>(parent);
parentDirectory.setExpanded(true);
root.getChildren().add(parentDirectory);
}
parentDirectory.getChildren().add(newItem);
} else {
root.getChildren().add(newItem);
}
}
示例13: TreeViewSample
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
public TreeViewSample() {
String dir = "./src";
final CheckBoxTreeItem<File> treeRoot = buildRoot(dir);
treeView = new TreeView<File>();
treeView.setCellFactory(CheckBoxTreeCell.<File> forTreeView());
treeView.setShowRoot(true);
treeView.setRoot(treeRoot);
treeRoot.setExpanded(true);
getChildren().add(treeView);
}
示例14: buildNode
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
private CheckBoxTreeItem<File> buildNode(File file) {
CheckBoxTreeItem<File> node = new CheckBoxTreeItem<File>(file);
if (file.isDirectory()) {
ObservableList<TreeItem<File>> children = node.getChildren();
File[] listFiles = file.listFiles();
for (File f : listFiles) {
children.add(buildNode(f));
}
}
return node;
}
示例15: buildRoot
import javafx.scene.control.CheckBoxTreeItem; //导入依赖的package包/类
private void buildRoot() {
root.getChildren().clear();
for (ModifiedPath firstLevelPath : getNamesAtIndex(0)) {
CheckBoxTreeItem<ModifiedPath> firstLevelItem = new CheckBoxTreeItem<>(firstLevelPath);
if (changedFiles.contains(firstLevelPath)) {
fileSelectionStates.add(Tuples.t(firstLevelPath, firstLevelItem.selectedProperty()));
} else {
buildTreeRecursively(firstLevelPath, firstLevelItem, 1);
}
selectAndExpandTreeItem(firstLevelItem);
root.getChildren().add(firstLevelItem);
}
}