本文整理汇总了Java中javafx.collections.ObservableList.forEach方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableList.forEach方法的具体用法?Java ObservableList.forEach怎么用?Java ObservableList.forEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.collections.ObservableList
的用法示例。
在下文中一共展示了ObservableList.forEach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Sync all properties with controls.
*/
@FXThread
public void refresh() {
final Object object = getCurrentObject();
if (object == null) return;
final VBox container = getContainer();
container.setDisable(!canEdit(object, getCurrentParent()));
final ObservableList<Node> children = container.getChildren();
children.forEach(node -> {
if (node instanceof UpdatableControl) {
((UpdatableControl) node).sync();
}
});
}
示例2: updateSelectedElements
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Update the list of selected elements.
*/
@FXThread
private void updateSelectedElements() {
final ConcurrentArray<ResourceElement> selectedElements = getSelectedElements();
final long stamp = selectedElements.writeLock();
try {
selectedElements.clear();
final MultipleSelectionModel<TreeItem<ResourceElement>> selectionModel = getSelectionModel();
final ObservableList<TreeItem<ResourceElement>> selectedItems = selectionModel.getSelectedItems();
selectedItems.forEach(item -> selectedElements.add(item.getValue()));
} finally {
selectedElements.writeUnlock(stamp);
}
}
示例3: fill
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Fill the item.
*/
@FXThread
private void fill(@NotNull final TreeItem<TreeNode<?>> treeItem, final boolean expanded, final int level) {
treeItem.setExpanded(expanded || level == 1);
final TreeNode<?> element = treeItem.getValue();
if (!element.hasChildren(this)) return;
final ObservableList<TreeItem<TreeNode<?>>> items = treeItem.getChildren();
final Array<TreeNode<?>> children = element.getChildren(this);
children.forEach(child -> {
element.notifyChildPreAdd(child);
items.add(new TreeItem<>(child));
element.notifyChildAdded(child);
});
items.forEach(item -> fill(item, expanded, level == -1 ? -1 : level + 1));
}
示例4: fillComponents
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Fill a list of components.
*
* @param container the container
* @param node the node
*/
@FXThread
public static void fillComponents(@NotNull final Array<ScreenComponent> container, @NotNull final Node node) {
if (node instanceof ScreenComponent) {
container.add((ScreenComponent) node);
}
if (node instanceof SplitPane) {
final ObservableList<Node> items = ((SplitPane) node).getItems();
items.forEach(child -> fillComponents(container, child));
} else if (node instanceof TabPane) {
final ObservableList<Tab> tabs = ((TabPane) node).getTabs();
tabs.forEach(tab -> fillComponents(container, tab.getContent()));
}
if (!(node instanceof Parent)) {
return;
}
final ObservableList<Node> nodes = ((Parent) node).getChildrenUnmodifiable();
nodes.forEach(child -> fillComponents(container, child));
}
示例5: fill
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Fill the node.
*/
@FXThread
private void fill(@NotNull final TreeItem<ResourceElement> treeItem) {
final ResourceElement element = treeItem.getValue();
final Array<String> extensionFilter = getExtensionFilter();
if (!element.hasChildren(extensionFilter, isOnlyFolders())) return;
final ObservableList<TreeItem<ResourceElement>> items = treeItem.getChildren();
if (isLazyMode()) {
items.add(new TreeItem<>(LoadingResourceElement.getInstance()));
} else {
final Array<ResourceElement> children = element.getChildren(extensionFilter, isOnlyFolders());
children.sort(NAME_COMPARATOR);
children.forEach(child -> items.add(new TreeItem<>(child)));
items.forEach(this::fill);
}
}
示例6: fill
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Fill the tree item.
*
* @param item the tree item.
*/
@FXThread
private void fill(@NotNull final TreeItem<VirtualResourceElement<?>> item) {
final VirtualResourceElement<?> element = item.getValue();
if(!element.hasChildren()) {
return;
}
final ObservableList<TreeItem<VirtualResourceElement<?>>> items = item.getChildren();
final Array<VirtualResourceElement<?>> children = element.getChildren();
children.sort(NAME_COMPARATOR);
children.forEach(child -> items.add(new TreeItem<>(child)));
items.forEach(this::fill);
}
示例7: lazyLoadChildren
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Show loaded children in the tree.
*
* @param treeItem the tree item.
* @param children the loaded children.
* @param callback the loading callback.
*/
@FXThread
private void lazyLoadChildren(@NotNull final TreeItem<ResourceElement> treeItem,
@NotNull final Array<ResourceElement> children,
@Nullable final Consumer<@NotNull TreeItem<ResourceElement>> callback) {
final ObservableList<TreeItem<ResourceElement>> items = treeItem.getChildren();
if (items.size() != 1 || items.get(0).getValue() != LoadingResourceElement.getInstance()) {
return;
}
children.forEach(child -> items.add(new TreeItem<>(child)));
items.remove(0);
items.forEach(this::fill);
if (isNeedCleanup()) {
cleanup(treeItem);
}
if (callback != null) {
callback.accept(treeItem);
}
}
示例8: selectAllAction
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@FXML
void selectAllAction(ActionEvent event) {
LOG.trace("selectAllAction()");
ObservableList<DesignVariable> list;
list = tableView.getItems();
// update the label after all the changes are made
ignoreUpdate = true;
list.forEach((DesignVariable dv) -> dv.checkedProperty().set(true));
ignoreUpdate = false;
updateLabel();
}
示例9: unselectAllAction
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@FXML
void unselectAllAction(ActionEvent event) {
LOG.trace("unselectAllAction()");
ObservableList<DesignVariable> list;
list = tableView.getItems();
// update the label after all the changes are made
ignoreUpdate = true;
list.forEach((DesignVariable dv) -> dv.checkedProperty().set(false));
ignoreUpdate = false;
updateLabel();
}
示例10: initInventoryContent
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Inicializuje obsah inventáře
*
* @param inventoryContent {@link InventoryContent}
*/
private void initInventoryContent(InventoryContent inventoryContent) {
clear();
inventoryContent.setUpdateListener(inventoryUpdateListener);
inventoryContent.getWeight().addListener(weightListener);
final ObservableList<InventoryRecord> inventoryRecords = inventoryContent.selectAll();
inventoryRecords.forEach(record -> insert(ItemRegistry.getINSTANCE()
.getItem(databaseItem -> databaseItem.getId().equals(record.getItemId())),
record.getAmmount(),
record.getSlotId()));
inventoryRecords.addListener(inventoryRecordListener);
this.inventoryContent = inventoryContent;
this.oldRecords = inventoryRecords;
}
示例11: calcNoOfNodes
import javafx.collections.ObservableList; //导入方法依赖的package包/类
private static void calcNoOfNodes(Node node) {
if (node instanceof Parent) {
if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
noOfNodes += tempChildren.size();
tempChildren.forEach(n -> calcNoOfNodes(n));
}
}
}
示例12: syncFor
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Sync all properties with controls.
*
* @param object the object
*/
@FXThread
public void syncFor(@Nullable final Object object) {
if (!isNeedUpdate(object)) return;
final VBox container = getContainer();
container.setDisable(object == null || !canEdit(object, getCurrentParent()));
final ObservableList<Node> children = container.getChildren();
children.forEach(node -> {
if (node instanceof UpdatableControl) {
((UpdatableControl) node).sync();
}
});
}
示例13: refresh
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Refresh the object in this tree.
*
* @param object the object.
*/
@FXThread
public void refresh(@NotNull final Object object) {
final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), object);
if (treeItem == null) return;
final TreeNode<?> treeNode = treeItem.getValue();
final ObservableList<TreeItem<TreeNode<?>>> items = treeItem.getChildren();
items.clear();
final boolean expanded = treeItem.isExpanded();
final TreeNode<?> selected = getSelected();
final TreeNode<?> element = treeItem.getValue();
if (!element.hasChildren(this)) return;
final Array<TreeNode<?>> children = element.getChildren(this);
children.forEach(child -> items.add(new TreeItem<>(child)));
items.forEach(modelNodeTreeItem -> fill(modelNodeTreeItem, false, -1));
treeItem.setExpanded(expanded);
if (selected == treeNode) {
select(treeNode);
}
}
示例14: clear
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Clear children of a pane.
*
* @param pane the pane.
*/
@FXThread
public static void clear(@NotNull final Pane pane) {
final ObservableList<Node> children = pane.getChildren();
children.forEach(UIUtils::unbind);
children.clear();
}
示例15: getAllItems
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Get all elements of a menu.
*
* @param menuBar the menu bar
* @return the all items
*/
@FXThread
public static @NotNull Array<MenuItem> getAllItems(@NotNull final MenuBar menuBar) {
final Array<MenuItem> container = ArrayFactory.newArray(MenuItem.class);
final ObservableList<Menu> menus = menuBar.getMenus();
menus.forEach(menu -> getAllItems(container, menu));
return container;
}