org.controlsfx.control.CheckTreeView Java Examples

The following examples show how to use org.controlsfx.control.CheckTreeView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SyncSettingsController.java    From ariADDna with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: GuiController.java    From BlockMap with MIT License 5 votes vote down vote up
/**
 * Recursive pre-order traversal of the pin type hierarchy tree. Generated items are added automatically.
 *
 * @param type
 *            the current type to add
 * @param parent
 *            the parent tree item to add this one to. <code>null</code> if {@code type} is the root type, in this case the generated tree
 *            item will be used as root for the tree directly.
 * @param tree
 *            the tree containing the items
 */
private void initPinCheckboxes(PinType type, CheckBoxTreeItem<PinType> parent, CheckTreeView<PinType> tree) {
	ImageView image = new ImageView(type.image);
	/*
	 * The only way so set the size of an image relative to the text of the label is to bind its height to a font size. Since tree items don't
	 * possess a fontProperty (it's hidden behind a cell factory implementation), we have to use the next best labeled node (pinBox in this
	 * case). This will only work if we don't change any font sizes.
	 */
	image.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> pinBox.getFont().getSize() * 1.5, pinBox.fontProperty()));
	image.setSmooth(true);
	image.setPreserveRatio(true);
	CheckBoxTreeItem<PinType> ret = new CheckBoxTreeItem<>(type, image);

	if (parent == null)
		tree.setRoot(ret);
	else
		parent.getChildren().add(ret);

	for (PinType sub : type.getChildren())
		initPinCheckboxes(sub, ret, tree);

	ret.setExpanded(type.expandedByDefault);
	if (type.selectedByDefault) {
		pins.visiblePins.add(type);
		tree.getCheckModel().check(ret);
	}
	checkedPins.put(type, ret);
}