本文整理汇总了Java中javafx.collections.ObservableList.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableList.isEmpty方法的具体用法?Java ObservableList.isEmpty怎么用?Java ObservableList.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.collections.ObservableList
的用法示例。
在下文中一共展示了ObservableList.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanup
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Cleanup the tree.
*/
@FXThread
private void cleanup(@NotNull final TreeItem<ResourceElement> treeItem) {
final ResourceElement element = treeItem.getValue();
if (element instanceof FileResourceElement || element instanceof LoadingResourceElement) return;
final ObservableList<TreeItem<ResourceElement>> children = treeItem.getChildren();
for (int i = children.size() - 1; i >= 0; i--) {
cleanup(children.get(i));
}
if (children.isEmpty() && treeItem.getParent() != null) {
final TreeItem<ResourceElement> parent = treeItem.getParent();
final ObservableList<TreeItem<ResourceElement>> parentChildren = parent.getChildren();
parentChildren.remove(treeItem);
}
}
示例2: reload
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@Override
@FXThread
protected void reload() {
if (!hasEditObject()) return;
final Geometry geometry = getEditObject();
final Mesh mesh = geometry.getMesh();
if (mesh == null) return;
final Integer element = getPropertyValue();
final ComboBox<Integer> levelComboBox = getLevelComboBox();
final ObservableList<Integer> items = levelComboBox.getItems();
items.clear();
final int numLodLevels = mesh.getNumLodLevels();
for (int i = 0; i < numLodLevels; i++) {
items.add(i);
}
if (items.isEmpty()) {
items.add(0);
}
levelComboBox.getSelectionModel().select(element);
}
示例3: notifyRemoved
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Notify about removing the element.
*
* @param parent the parent
* @param child the child
*/
@FXThread
public void notifyRemoved(@Nullable final Object parent, @NotNull final Object child) {
final TreeItem<TreeNode<?>> treeItem = tryToFindItem(parent, child);
if (treeItem == null) return;
final TreeItem<TreeNode<?>> parentItem = treeItem.getParent();
final TreeNode<?> parentNode = parentItem.getValue();
final TreeNode<?> node = treeItem.getValue();
final ObservableList<TreeItem<TreeNode<?>>> children = parentItem.getChildren();
parentNode.notifyChildPreRemove(node);
children.remove(treeItem);
parentNode.notifyChildRemoved(node);
if (parentItem.isExpanded() && children.isEmpty()) {
parentItem.setExpanded(false);
}
}
示例4: findItem
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Find a tree item by object id.
*
* @param <T> the type parameter
* @param root the root item.
* @param objectId the object id.
* @return the tree item or null.
*/
@FXThread
public static @Nullable <T> TreeItem<T> findItem(@NotNull final TreeItem<T> root, final long objectId) {
final T value = root.getValue();
if (value instanceof UObject && ((UObject) value).getObjectId() == objectId) {
return root;
}
final ObservableList<TreeItem<T>> children = root.getChildren();
if (!children.isEmpty()) {
for (final TreeItem<T> treeItem : children) {
final TreeItem<T> result = findItem(treeItem, objectId);
if (result != null) return result;
}
}
return null;
}
示例5: findItemForValue
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Find a tree item by its value.
*
* @param <T> the type parameter
* @param root the root item.
* @param object the value.
* @return the tree item or null.
*/
@FXThread
public @Nullable static <T> TreeItem<T> findItemForValue(@NotNull final TreeItem<T> root, @Nullable final Object object) {
if (object == null) return null;
if (Objects.equals(root.getValue(), object)) {
return root;
}
final ObservableList<TreeItem<T>> children = root.getChildren();
if (!children.isEmpty()) {
for (final TreeItem<T> treeItem : children) {
final TreeItem<T> result = findItemForValue(treeItem, object);
if (result != null) return result;
}
}
return null;
}
示例6: ServiceControl
import javafx.collections.ObservableList; //导入方法依赖的package包/类
public ServiceControl(ServerControl serverControl, ServiceModel service) {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("fxml/service.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
this.serverControl = serverControl;
this.service = service;
final ConfigurationModel configuration = App.getConfiguration();
final String actionName = service.getActionName();
action = configuration.getActionByName(actionName);
this.setText(action.getDescription());
final ObservableList<Node> formEntriesControls = formEntriesContainer.getChildren();
formEntryControls = buildUserParamsControls();
formEntriesControls.addAll(formEntryControls);
if (formEntriesControls.isEmpty()) {
formEntriesContainer.getChildren().add(0, new Label("Nothing to configure for this service."));
}
}
示例7: refreshHeight
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Refresh height of list view.
*/
private void refreshHeight() {
final ListView<TextureLayer> listView = getListView();
final ObservableList<TextureLayer> items = listView.getItems();
if (items.isEmpty()) {
listView.setPrefHeight(0D);
} else {
listView.setPrefHeight(items.size() * CELL_SIZE);
}
}
示例8: getChildren
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@Override public ObservableList<TreeItem<Test>> getChildren() {
ObservableList<TreeItem<Test>> children = super.getChildren();
if (!children.isEmpty()) {
if (testRunner.showFailures()) {
List<TreeItem<Test>> failures = children.stream().filter(new Predicate<TreeItem<Test>>() {
@Override public boolean test(TreeItem<Test> t) {
return ((TestTreeItem) t).getState() == State.ERROR || ((TestTreeItem) t).getState() == State.FAILURE;
}
}).collect(Collectors.toList());
children.setAll(failures);
} else {
if (children.containsAll(allChildren)) {
return children;
}
children.setAll(allChildren);
}
} else {
if (test instanceof TestSuite) {
TestSuite suite = (TestSuite) test;
int countTestCases = suite.testCount();
for (int i = 0; i < countTestCases; i++) {
children.add(new TestTreeItem(suite.testAt(i), testRunner));
}
allChildren.setAll(children);
}
}
return children;
}
示例9: notifyChangeProperty
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Notify about changed property.
*
* @param object the object
* @param propertyName the property name
*/
@FXThread
public void notifyChangeProperty(@NotNull final Object object, @NotNull final String propertyName) {
final VBox container = getContainer();
final ObservableList<Node> children = container.getChildren();
if (children.isEmpty()) return;
children.stream().map(node -> (C) node).filter(editingComponent -> editingComponent.getProcessedObject() ==
object).forEach(editingComponent -> editingComponent.notifyChangeProperty(object, propertyName));
}
示例10: getTypeByName
import javafx.collections.ObservableList; //导入方法依赖的package包/类
public ProjectType getTypeByName(String typeName)
throws UnsupportedProjectTypeException
{
Predicate<ProjectType> filter = (type) -> typeName.equals(type.getName());
ObservableList<ProjectType> validTypes = supportedProjectTypes.filtered(filter);
if (validTypes.isEmpty())
throw new UnsupportedProjectTypeException(typeName);
else
return supportedProjectTypes.get(0);
}
示例11: getType
import javafx.collections.ObservableList; //导入方法依赖的package包/类
private ProjectType getType(File file) throws UnsupportedFileExtensionException
{
String extension = FilenameUtils.getExtension(file.getAbsolutePath());
Predicate<ProjectType> filter = (type) -> type.isFileExtensionSupported(extension);
ObservableList<ProjectType> validTypes = supportedProjectTypes.filtered(filter);
if (validTypes.isEmpty())
throw new UnsupportedFileExtensionException(extension);
else
return supportedProjectTypes.get(0);
}
示例12: smooth
import javafx.collections.ObservableList; //导入方法依赖的package包/类
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) {
if (fillElements.isEmpty()) return;
// as we do not have direct access to the data, first recreate the list of all the data points we have
final Point2D[] dataPoints = new Point2D[strokeElements.size()];
for (int i = 0; i < strokeElements.size(); i++) {
final PathElement element = strokeElements.get(i);
if (element instanceof MoveTo) {
final MoveTo move = (MoveTo) element;
dataPoints[i] = new Point2D(move.getX(), move.getY());
} else if (element instanceof LineTo) {
final LineTo line = (LineTo) element;
final double x = line.getX(), y = line.getY();
dataPoints[i] = new Point2D(x, y);
}
}
double firstX = dataPoints[0].getX();
double lastX = dataPoints[dataPoints.length - 1].getX();
Point2D[] points = Helper.subdividePoints(dataPoints, getSubDivisions());
fillElements.clear();
fillElements.add(new MoveTo(firstX, HEIGHT));
strokeElements.clear();
strokeElements.add(new MoveTo(points[0].getX(), points[0].getY()));
for (Point2D p : points) {
if (Double.compare(p.getX(), firstX) >= 0) {
fillElements.add(new LineTo(p.getX(), p.getY()));
strokeElements.add(new LineTo(p.getX(), p.getY()));
}
}
fillElements.add(new LineTo(lastX, HEIGHT));
fillElements.add(new LineTo(0, HEIGHT));
fillElements.add(new ClosePath());
}
示例13: refresh
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Refresh the layers list.
*/
@FXThread
public void refresh() {
final ListView<TextureLayer> listView = getListView();
final MultipleSelectionModel<TextureLayer> selectionModel = listView.getSelectionModel();
final TextureLayer selectedItem = selectionModel.getSelectedItem();
final ObservableList<TextureLayer> items = listView.getItems();
items.clear();
final int maxLevels = getMaxLevels() - 1;
for (int i = 0; i < maxLevels; i++) {
final float scale = getTextureScale(i);
if (scale == -1F) continue;
items.add(new TextureLayer(this, i));
}
if (items.contains(selectedItem)) {
selectionModel.select(selectedItem);
} else if (!items.isEmpty()) {
selectionModel.select(items.get(0));
}
final ExecutorManager executorManager = ExecutorManager.getInstance();
executorManager.addFXTask(this::refreshHeight);
executorManager.addFXTask(this::refreshAddButton);
}
示例14: handle
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@Override
public void handle(KeyEvent event) {
TextField editor = comboBox.getEditor();
String text = editor.getText();
if (event.getCode() == KeyCode.RIGHT
|| event.getCode() == KeyCode.LEFT
|| event.isControlDown()
|| event.getCode() == KeyCode.HOME
|| event.getCode() == KeyCode.END
|| event.getCode() == KeyCode.TAB) {
return;
}
else if(event.getCode() == KeyCode.UP) {
caretPos = -1;
moveCaret(text.length());
return;
}
else if(event.getCode() == KeyCode.DOWN) {
if(!comboBox.isShowing()) {
comboBox.show();
}
caretPos = -1;
moveCaret(text.length());
return;
}
else if(event.getCode() == KeyCode.BACK_SPACE) {
moveCaretToPos = true;
caretPos = editor.getCaretPosition();
}
else if(event.getCode() == KeyCode.DELETE) {
moveCaretToPos = true;
caretPos = editor.getCaretPosition();
}
String upperCaseText = text.toUpperCase();
ObservableList<T> list = FXCollections.observableArrayList(data.stream()
.filter(s -> transform.apply(s).toUpperCase().startsWith(upperCaseText))
.collect(Collectors.toList()));
comboBox.setItems(list);
if (event.getCode() == KeyCode.ENTER
|| event.getCode() == KeyCode.ESCAPE) {
if (!list.isEmpty()) {
comboBox.getEditor().setText(transform.apply(list.get(0)));
comboBox.getSelectionModel().select(0);
comboBox.hide();
}
else {
comboBox.getEditor().setText(text);
}
}
else {
comboBox.getEditor().setText(text);
if(!moveCaretToPos) {
caretPos = -1;
}
moveCaret(text.length());
if(!list.isEmpty()) {
comboBox.show();
}
}
}
示例15: onClick
import javafx.collections.ObservableList; //导入方法依赖的package包/类
private void onClick(Runnable onSelection, Runnable onDeselection) {
ObservableList<String> selectedItems = tablesList.getSelectionModel().getSelectedItems();
if (selectedItems.isEmpty()) {
onDeselection.run();
} else {
onSelection.run();
}
}