Java Code Examples for javafx.collections.FXCollections#emptyObservableList()

The following examples show how to use javafx.collections.FXCollections#emptyObservableList() . 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: ApplicationStages.java    From cssfx with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated do not use this method anymore,
 * @see Window#getWindows for similar functionnality
 */
@Deprecated(forRemoval = true, since = "11.0.2")
public static ObservableList<Stage> monitoredStages(Stage ... restrictedTo) {
    try {
        ObservableList<Stage> stages = Window.getWindows().stream()
                .map(Stage.class::cast)
                .collect(
                        Collectors.collectingAndThen(toList(), FXCollections::observableArrayList)
                );
        logger(ApplicationStages.class).debug("successfully retrieved JavaFX stages by calling javafx.stage.Window.getWindows()");
        return stages;
    } catch (Exception e) {
        logger(ApplicationStages.class).error("cannot observe stages changes by calling javafx.stage.Window.getWindows()", e);
    }
    return FXCollections.emptyObservableList();
}
 
Example 2
Source File: MetricPaneController.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ObservableList<MetricResult> evaluateAllMetrics(Node n) {
    LanguageMetricsProvider<?, ?> provider = getGlobalLanguageVersion().getLanguageVersionHandler().getLanguageMetricsProvider();
    if (provider == null) {
        return FXCollections.emptyObservableList();
    }
    List<MetricResult> resultList =
        provider.computeAllMetricsFor(n)
                .entrySet()
                .stream()
                .map(e -> new MetricResult(e.getKey(), e.getValue()))
                .collect(Collectors.toList());
    return FXCollections.observableArrayList(resultList);
}
 
Example 3
Source File: NodeDetailPaneController.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Gets the XPath attributes of the node for display within a listview.
 */
private ObservableList<Attribute> getAttributes(Node node) {
    if (node == null) {
        xpathAttributesTableView.setPlaceholder(new Label("Select a node to show its attributes"));
        return FXCollections.emptyObservableList();
    }

    ObservableList<Attribute> result = FXCollections.observableArrayList();
    Iterator<Attribute> attributeAxisIterator = node.getXPathAttributesIterator();
    while (attributeAxisIterator.hasNext()) {
        Attribute attribute = attributeAxisIterator.next();

        if (!(isHideCommonAttributes() && IGNORABLE_ATTRIBUTES.contains(attribute.getName()))) {

            try {
                result.add(attribute);
            } catch (Exception ignored) {
                // some attributes throw eg numberformat exceptions
            }

        }
    }

    result.sort(Comparator.comparing(Attribute::getName));
    xpathAttributesTableView.setPlaceholder(new Label("No available attributes"));
    return result;
}
 
Example 4
Source File: DataSetSelector.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public DataSetSelector(final ParameterMeasurements plugin, final int requiredNumberOfDataSets) {
    super();
    if (plugin == null) {
        throw new IllegalArgumentException("plugin must not be null");
    }

    // wrap observable Array List, to prevent resetting the selection model whenever getAllDatasets() is called
    // somewhere in the code.
    allDataSets = plugin.getChart() != null ? FXCollections.observableArrayList(plugin.getChart().getAllDatasets()) : FXCollections.emptyObservableList();

    final Label label = new Label("Selected Dataset: ");
    GridPane.setConstraints(label, 0, 0);
    dataSetListView = new ListView<>(allDataSets);
    GridPane.setConstraints(dataSetListView, 1, 0);
    dataSetListView.setOrientation(Orientation.VERTICAL);
    dataSetListView.setPrefSize(-1, DEFAULT_SELECTOR_HEIGHT);
    dataSetListView.setCellFactory(list -> new DataSetLabel());
    dataSetListView.setPrefHeight(Math.max(2, allDataSets.size()) * ROW_HEIGHT + 2.0);
    MultipleSelectionModel<DataSet> selModel = dataSetListView.getSelectionModel();
    if (requiredNumberOfDataSets == 1) {
        selModel.setSelectionMode(SelectionMode.SINGLE);
    } else if (requiredNumberOfDataSets >= 2) {
        selModel.setSelectionMode(SelectionMode.MULTIPLE);
    }

    // add default initially selected DataSets
    if (selModel.getSelectedIndices().isEmpty() && allDataSets.size() >= requiredNumberOfDataSets) {
        for (int i = 0; i < requiredNumberOfDataSets; i++) {
            selModel.select(i);
        }
    }

    if (requiredNumberOfDataSets >= 1) {
        getChildren().addAll(label, dataSetListView);
    }
}
 
Example 5
Source File: ApplicationStages.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static ObservableList<Stage> monitoredStages(Stage ...restrictedTo) {
    try {
        Class<?> sh = Class.forName("com.sun.javafx.stage.StageHelper");
        Method m = sh.getMethod("getStages");
        ObservableList<Stage> stages = (ObservableList<Stage>) m.invoke(null, new Object[0]);
        logger(ApplicationStages.class).debug("successfully retrieved JavaFX stages from com.sun.javafx.stage.StageHelper");
        return stages;
    } catch (Exception e) {
        logger(ApplicationStages.class).error("cannot observe stages changes by calling com.sun.javafx.stage.StageHelper.getStages()", e);
    }
    return FXCollections.emptyObservableList();
}
 
Example 6
Source File: ChildrenGetter.java    From scenic-view with GNU General Public License v3.0 5 votes vote down vote up
public static ObservableList<Node> getChildren(Node node) {
    if (node == null) return FXCollections.emptyObservableList();
    
    if (node instanceof Parent) {
        return ((Parent)node).getChildrenUnmodifiable();
    } else if (node instanceof SubScene) {
        return ((SubScene)node).getRoot().getChildrenUnmodifiable();
    }
    
    return FXCollections.emptyObservableList();
}
 
Example 7
Source File: TreeFileItem.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Builds tree item children.
 *
 * @return tree item children
 */
private ObservableList<TreeFileItem> buildChildren() {
  if (file != null && file.isDirectory()) {
    File[] files = file.listFiles();
    if (files != null) {
      ObservableList<TreeFileItem> children = FXCollections.observableArrayList();
      for (File f : files) {
        if (!f.isHidden() && (f.isDirectory() || FS.isAssemblyFile(f))) {
          children.add(new TreeFileItem(f, false, expanded));
        }
      }
      // sort children
      children.sort(new Comparator<TreeFileItem>() {
        @Override
        public int compare(TreeFileItem p, TreeFileItem q) {
          String fn = p.getFile().getName().toString();
          String qn = q.getFile().getName().toString();
          boolean pd = p.getFile().isDirectory();
          boolean qd = q.getFile().isDirectory();
          if (pd && !qd)
            return -1;
          else if (!pd && qd)
            return 1;
          else
            return fn.compareToIgnoreCase(qn);
        }
      });
      return children;
    }
  }
  return FXCollections.emptyObservableList();
}
 
Example 8
Source File: MultisetBinding.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ObservableList<?> getDependencies() {
	if (dependencies == null) {
		return FXCollections.emptyObservableList();
	}
	return FXCollections.unmodifiableObservableList(dependencies);
}
 
Example 9
Source File: SetMultimapBinding.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ObservableList<?> getDependencies() {
	if (dependencies == null) {
		return FXCollections.emptyObservableList();
	}
	return FXCollections.unmodifiableObservableList(dependencies);
}
 
Example 10
Source File: NoSelectionModel.java    From milkman with MIT License 4 votes vote down vote up
@Override
public ObservableList<Integer> getSelectedIndices() {
    return FXCollections.emptyObservableList();
}
 
Example 11
Source File: NoSelectionModel.java    From milkman with MIT License 4 votes vote down vote up
@Override
public ObservableList<T> getSelectedItems() {
    return FXCollections.emptyObservableList();
}
 
Example 12
Source File: GroupShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Override
default @NotNull ObservableList<Point> getPoints() {
	return FXCollections.emptyObservableList();
}