类javafx.scene.control.MultipleSelectionModel源码实例Demo

下面列出了怎么用javafx.scene.control.MultipleSelectionModel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: marathonv5   文件: RFXTreeViewTest.java
@Test
public void getTextForMultipleSelection() {
    @SuppressWarnings("rawtypes")
    TreeView treeView = (TreeView) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXTreeView rTreeView = new RFXTreeView(treeView, null, null, lr);
            @SuppressWarnings("rawtypes")
            MultipleSelectionModel selectionModel = treeView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 3);
            rTreeView.focusLost(new RFXTreeView(null, null, null, null));
            text.add(rTreeView.getAttribute("text"));
        }
    });
    new Wait("Waiting for tree text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"/Root node/Child Node 2\",\"/Root node/Child Node 3\"]", text.get(0));
}
 
源代码2 项目: marathonv5   文件: RFXListViewTest.java
@Test
public void getTextForMultipleSelection() {
    ListView<?> listView = (ListView<?>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            MultipleSelectionModel<?> selectionModel = listView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 8);
            RFXListView rfxListView = new RFXListView(listView, null, null, lr);
            rfxListView.focusLost(new RFXListView(null, null, null, lr));
            text.add(rfxListView.getAttribute("text"));
        }
    });
    new Wait("Waiting for list text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"Long Row 3\",\"Row 9\"]", text.get(0));
}
 
源代码3 项目: marathonv5   文件: RFXListViewTest.java
@Test
public void selectMultipleItemSelection() {
    ListView<?> listView = (ListView<?>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            MultipleSelectionModel<?> selectionModel = listView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 6);
            RFXListView rfxListView = new RFXListView(listView, null, null, lr);
            rfxListView.focusLost(new RFXListView(null, null, null, lr));
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("[\"Long Row 3\",\"Row 7\"]", recording.getParameters()[0]);
}
 
源代码4 项目: phoebus   文件: WidgetTree.java
/** Called by selection handler when selected widgets have changed, or on new model
 *  @param widgets Widgets to select in tree
 */
public void setSelectedWidgets(final List<Widget> widgets)
{
    if (! active.compareAndSet(false, true))
        return;
    try
    {
        final MultipleSelectionModel<TreeItem<WidgetOrTab>> selection = tree_view.getSelectionModel();
        selection.clearSelection();
        for (Widget widget : widgets)
            selection.select(widget2tree.get(widget));

        // If something's selected, show it.
        // Otherwise leave tree at current position.
        final int index = selection.getSelectedIndex();
        if (index >= 0)
            tree_view.scrollTo(index);
    }
    finally
    {
        active.set(false);
    }
}
 
源代码5 项目: phoebus   文件: AddAnnotationDialog.java
private boolean checkInput()
{
	if (traces.isEmpty())
	{
		new Alert(AlertType.INFORMATION, Messages.AddAnnotation_NoTraces).showAndWait();
		return false;
	}
	final MultipleSelectionModel<Trace<XTYPE>> seletion = trace_list.getSelectionModel();
	final Trace<XTYPE> item = seletion.isEmpty() ? traces.get(0) : seletion.getSelectedItem();
	final String content = text.getText().trim();
	if (content.isEmpty())
	{
		new Alert(AlertType.WARNING, Messages.AddAnnotation_NoContent).showAndWait();
		return false;
	}
	plot.addAnnotation(item, content);
    return true;
}
 
源代码6 项目: jmonkeybuilder   文件: VirtualAssetEditorDialog.java
@Override
@FxThread
protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() {

    final VirtualResourceTree<C> resourceTree = getResourceTree();
    final MultipleSelectionModel<TreeItem<VirtualResourceElement<?>>> selectionModel = resourceTree.getSelectionModel();
    final ReadOnlyObjectProperty<TreeItem<VirtualResourceElement<?>>> selectedItemProperty = selectionModel.selectedItemProperty();

    final Class<C> type = getObjectsType();
    final BooleanBinding typeCondition = new BooleanBinding() {

        @Override
        protected boolean computeValue() {
            final TreeItem<VirtualResourceElement<?>> treeItem = selectedItemProperty.get();
            return treeItem == null || !type.isInstance(treeItem.getValue().getObject());
        }

        @Override
        public Boolean getValue() {
            return computeValue();
        }
    };

    return Bindings.or(selectedItemProperty.isNull(), typeCondition);
}
 
源代码7 项目: jmonkeybuilder   文件: VirtualAssetEditorDialog.java
@Override
@FxThread
protected void processOk() {
    super.processOk();

    final VirtualResourceTree<C> resourceTree = getResourceTree();
    final MultipleSelectionModel<TreeItem<VirtualResourceElement<?>>> selectionModel = resourceTree.getSelectionModel();
    final TreeItem<VirtualResourceElement<?>> selectedItem = selectionModel.getSelectedItem();

    if (selectedItem == null) {
        hide();
        return;
    }

    final VirtualResourceElement<?> element = selectedItem.getValue();
    final Object object = element.getObject();
    final Class<C> type = getObjectsType();

    if (type.isInstance(object)) {
        getConsumer().accept(type.cast(object));
    }
}
 
源代码8 项目: jmonkeybuilder   文件: AssetEditorDialog.java
@Override
@FxThread
protected void processOk() {
    super.processOk();

    final ResourceTree resourceTree = getResourceTree();
    final MultipleSelectionModel<TreeItem<ResourceElement>> selectionModel = resourceTree.getSelectionModel();
    final TreeItem<ResourceElement> selectedItem = selectionModel.getSelectedItem();

    if (selectedItem == null) {
        hide();
        return;
    }

    processOpen(selectedItem.getValue());
}
 
源代码9 项目: jmonkeybuilder   文件: AppStateList.java
/**
 * Fill a list of app states.
 *
 * @param sceneNode the scene node
 */
@FxThread
public void fill(@NotNull final SceneNode sceneNode) {

    final ListView<EditableSceneAppState> listView = getListView();
    final MultipleSelectionModel<EditableSceneAppState> selectionModel = listView.getSelectionModel();
    final EditableSceneAppState selected = selectionModel.getSelectedItem();

    final ObservableList<EditableSceneAppState> items = listView.getItems();
    items.clear();

    final List<SceneAppState> appStates = sceneNode.getAppStates();
    appStates.stream().filter(EditableSceneAppState.class::isInstance)
            .map(EditableSceneAppState.class::cast)
            .forEach(items::add);

    if (selected != null && appStates.contains(selected)) {
        selectionModel.select(selected);
    }
}
 
源代码10 项目: jmonkeybuilder   文件: FilterList.java
/**
 * Fill a list of filters.
 *
 * @param sceneNode the scene node
 */
@FxThread
public void fill(@NotNull final SceneNode sceneNode) {

    final MultipleSelectionModel<EditableSceneFilter> selectionModel = listView.getSelectionModel();
    final EditableSceneFilter selected = selectionModel.getSelectedItem();

    final ObservableList<EditableSceneFilter> items = listView.getItems();
    items.clear();

    final List<SceneFilter> filters = sceneNode.getFilters();
    filters.stream().filter(EditableSceneFilter.class::isInstance)
            .map(EditableSceneFilter.class::cast)
            .forEach(items::add);

    if (selected != null && filters.contains(selected)) {
        selectionModel.select(selected);
    }
}
 
源代码11 项目: chart-fx   文件: ChartMeasurementSelector.java
public ChartMeasurementSelector(final ParameterMeasurements plugin, final AbstractChartMeasurement dataSetMeasurement, final int requiredNumberOfChartMeasurements) {
    super();
    if (plugin == null) {
        throw new IllegalArgumentException("plugin must not be null");
    }

    final Label label = new Label("Selected Measurement: ");
    GridPane.setConstraints(label, 0, 0);
    chartMeasurementListView = new ListView<>(plugin.getChartMeasurements().filtered(t -> !t.equals(dataSetMeasurement)));
    GridPane.setConstraints(chartMeasurementListView, 1, 0);
    chartMeasurementListView.setOrientation(Orientation.VERTICAL);
    chartMeasurementListView.setPrefSize(-1, DEFAULT_SELECTOR_HEIGHT);
    chartMeasurementListView.setCellFactory(list -> new ChartMeasurementLabel());
    chartMeasurementListView.setPrefHeight(Math.max(2, plugin.getChartMeasurements().size()) * ROW_HEIGHT + 2.0);
    MultipleSelectionModel<AbstractChartMeasurement> selModel = chartMeasurementListView.getSelectionModel();
    if (requiredNumberOfChartMeasurements == 1) {
        selModel.setSelectionMode(SelectionMode.SINGLE);
    } else if (requiredNumberOfChartMeasurements >= 2) {
        selModel.setSelectionMode(SelectionMode.MULTIPLE);
    }

    // add default initially selected ChartMeasurements
    if (selModel.getSelectedIndices().isEmpty() && plugin.getChartMeasurements().size() >= requiredNumberOfChartMeasurements) {
        for (int i = 0; i < requiredNumberOfChartMeasurements; i++) {
            selModel.select(i);
        }
    }

    if (selModel.getSelectedIndices().size() < requiredNumberOfChartMeasurements && LOGGER.isWarnEnabled()) {
        LOGGER.atWarn().addArgument(plugin.getChartMeasurements().size()).addArgument(requiredNumberOfChartMeasurements).log("could not add default selection: required {} vs. selected {}");
    }

    if (requiredNumberOfChartMeasurements >= 1) {
        getChildren().addAll(label, chartMeasurementListView);
    }
}
 
源代码12 项目: chart-fx   文件: DataSetSelector.java
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);
    }
}
 
源代码13 项目: marathonv5   文件: UpDownHandler.java
@Override
public void handle(ActionEvent event) {
    MultipleSelectionModel<ClassPathElement> selectionModel = classPathListView.getSelectionModel();
    ObservableList<ClassPathElement> items = classPathListView.getItems();
    int selectedIndex = selectionModel.getSelectedIndex();
    ClassPathElement selectedItem = selectionModel.getSelectedItem();
    items.remove(selectedItem);
    if (shouldMoveUp) {
        items.add(selectedIndex - 1, selectedItem);
    } else {
        items.add(selectedIndex + 1, selectedItem);
    }
    selectionModel.clearAndSelect(items.indexOf(selectedItem));
}
 
源代码14 项目: marathonv5   文件: HistoryUpDownHandler.java
@Override
public void handle(ActionEvent event) {
    MultipleSelectionModel<JSONObject> selectionModel = historyView.getSelectionModel();
    ObservableList<JSONObject> items = historyView.getItems();
    int selectedIndex = selectionModel.getSelectedIndex();
    JSONObject selectedItem = selectionModel.getSelectedItem();
    items.remove(selectedItem);
    if (shouldMoveUp) {
        items.add(selectedIndex - 1, selectedItem);
    } else {
        items.add(selectedIndex + 1, selectedItem);
    }
    selectionModel.select(selectedItem);
    TestRunnerHistory.getInstance().rewrite("favourites", items);
}
 
源代码15 项目: marathonv5   文件: ListLayout.java
private VBox createListView() {
    listViewBox = new VBox(5);
    classPathListView = new ListView<ClassPathElement>(classPathListItems);
    classPathListView.setPrefHeight(Node.BASELINE_OFFSET_SAME_AS_HEIGHT);
    classPathListView.setId("ClassPathList");
    classPathListView.setCellFactory((e) -> {
        ClassPathCell classPathCell = new ClassPathCell();
        classPathCell.setId("ClassPathCell");
        return classPathCell;
    });

    if (!isSingleSelection()) {
        classPathListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    }
    classPathListView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        MultipleSelectionModel<ClassPathElement> selectionModel = classPathListView.getSelectionModel();
        int itemCount = classPathListItems.size();
        int selectedIndex = selectionModel.getSelectedIndex();
        setButtonState(deleteButton, selectedIndex != -1);
        boolean enable = selectedIndex != 0 && selectedIndex != -1 && itemCount > 1;
        setButtonState(upButton, enable);
        enable = selectedIndex != itemCount - 1 && selectedIndex != -1 && itemCount > 1;
        setButtonState(downButton, enable);
    });
    listViewBox.getChildren().add(classPathListView);
    HBox.setHgrow(listViewBox, Priority.ALWAYS);
    VBox.setVgrow(classPathListView, Priority.ALWAYS);
    return listViewBox;
}
 
源代码16 项目: jmonkeybuilder   文件: AssetEditorDialog.java
@Override
@FxThread
protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() {
    final ResourceTree resourceTree = getResourceTree();
    final MultipleSelectionModel<TreeItem<ResourceElement>> selectionModel = resourceTree.getSelectionModel();
    final ReadOnlyObjectProperty<TreeItem<ResourceElement>> selectedItemProperty = selectionModel.selectedItemProperty();
    return selectedItemProperty.isNull();
}
 
源代码17 项目: jmonkeybuilder   文件: AppStateList.java
/**
 * Create components of this component.
 */
@FxThread
private void createComponents() {

    listView = new ListView<>();
    listView.setCellFactory(param -> new AppStateListCell(this));
    listView.setEditable(false);
    listView.setFocusTraversable(true);
    listView.prefHeightProperty().bind(heightProperty());
    listView.prefWidthProperty().bind(widthProperty());
    listView.setFixedCellSize(FxConstants.LIST_CELL_HEIGHT);

    final MultipleSelectionModel<EditableSceneAppState> selectionModel = listView.getSelectionModel();
    selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) ->
            selectHandler.accept(newValue));

    final Button addButton = new Button();
    addButton.setGraphic(new ImageView(Icons.ADD_12));
    addButton.setOnAction(event -> addAppState());

    final Button removeButton = new Button();
    removeButton.setGraphic(new ImageView(Icons.REMOVE_12));
    removeButton.setOnAction(event -> removeAppState());
    removeButton.disableProperty().bind(selectionModel.selectedItemProperty().isNull());

    final HBox buttonContainer = new HBox(addButton, removeButton);

    FXUtils.addToPane(listView, this);
    FXUtils.addToPane(buttonContainer, this);

    FXUtils.addClassTo(buttonContainer, CssClasses.DEF_HBOX);
    FXUtils.addClassTo(addButton, CssClasses.BUTTON_WITHOUT_RIGHT_BORDER);
    FXUtils.addClassTo(removeButton, CssClasses.BUTTON_WITHOUT_LEFT_BORDER);
    FXUtils.addClassTo(listView, CssClasses.TRANSPARENT_LIST_VIEW);

    DynamicIconSupport.addSupport(addButton, removeButton);
}
 
源代码18 项目: jmonkeybuilder   文件: AppStateList.java
/**
 * Handle removing an old app state.
 */
@FxThread
private void removeAppState() {

    final MultipleSelectionModel<EditableSceneAppState> selectionModel = getListView().getSelectionModel();
    final EditableSceneAppState appState = selectionModel.getSelectedItem();
    final SceneNode sceneNode = changeConsumer.getCurrentModel();

    changeConsumer.execute(new RemoveAppStateOperation(appState, sceneNode));
}
 
源代码19 项目: jmonkeybuilder   文件: FilterList.java
/**
 * Create components of this component.
 */
@FxThread
private void createComponents() {

    listView = new ListView<>();
    listView.setCellFactory(param -> new FilterListCell(this));
    listView.setEditable(false);
    listView.setFocusTraversable(true);
    listView.prefHeightProperty().bind(heightProperty());
    listView.prefWidthProperty().bind(widthProperty());
    listView.setFixedCellSize(FxConstants.LIST_CELL_HEIGHT);

    final MultipleSelectionModel<EditableSceneFilter> selectionModel = listView.getSelectionModel();
    selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) ->
            selectHandler.accept(newValue));

    final Button addButton = new Button();
    addButton.setGraphic(new ImageView(Icons.ADD_12));
    addButton.setOnAction(event -> addFilter());

    final Button removeButton = new Button();
    removeButton.setGraphic(new ImageView(Icons.REMOVE_12));
    removeButton.setOnAction(event -> removeFilter());
    removeButton.disableProperty().bind(selectionModel.selectedItemProperty().isNull());

    final HBox buttonContainer = new HBox(addButton, removeButton);

    FXUtils.addToPane(listView, this);
    FXUtils.addToPane(buttonContainer, this);

    FXUtils.addClassTo(buttonContainer, CssClasses.DEF_HBOX);
    FXUtils.addClassTo(addButton, CssClasses.BUTTON_WITHOUT_RIGHT_BORDER);
    FXUtils.addClassTo(removeButton, CssClasses.BUTTON_WITHOUT_LEFT_BORDER);
    FXUtils.addClassTo(listView, CssClasses.TRANSPARENT_LIST_VIEW);

    DynamicIconSupport.addSupport(addButton, removeButton);
}
 
源代码20 项目: jmonkeybuilder   文件: FilterList.java
/**
 * Remove the selected filter.
 */
@FxThread
private void removeFilter() {

    final MultipleSelectionModel<EditableSceneFilter> selectionModel = listView.getSelectionModel();
    final EditableSceneFilter filter = selectionModel.getSelectedItem();
    final SceneNode sceneNode = changeConsumer.getCurrentModel();

    changeConsumer.execute(new RemoveSceneFilterOperation(filter, sceneNode));
}
 
源代码21 项目: chart-fx   文件: ChartMeasurementSelector.java
public AbstractChartMeasurement getSelectedChartMeasurement() {
    MultipleSelectionModel<AbstractChartMeasurement> selModel = chartMeasurementListView.getSelectionModel();
    return selModel.getSelectedItem();
}
 
源代码22 项目: chart-fx   文件: ChartMeasurementSelector.java
public ObservableList<AbstractChartMeasurement> getSelectedChartMeasurements() {
    MultipleSelectionModel<AbstractChartMeasurement> selModel = chartMeasurementListView.getSelectionModel();
    return selModel.getSelectedItems();
}
 
源代码23 项目: chart-fx   文件: ValueIndicatorSelector.java
public ValueIndicatorSelector(final ParameterMeasurements plugin, final AxisMode axisMode, final int requiredNumberOfIndicators) {
    super();
    if (plugin == null) {
        throw new IllegalArgumentException("plugin must not be null");
    }
    this.axisMode = axisMode;
    reuseIndicators.setSelected(true);

    plugin.chartProperty().addListener(chartChangeListener);
    if (plugin.getChart() != null) {
        plugin.getChart().getPlugins().addListener(pluginsChanged);
        plugin.getChart().getPlugins().forEach(this::addNewIndicators);
        reuseIndicators.setSelected(plugin.getChart().getAxes().size() <= 2);
    }

    final Label label = new Label("re-use inidcators: ");
    GridPane.setConstraints(label, 0, 0);
    GridPane.setConstraints(reuseIndicators, 1, 0);
    reuseIndicators.selectedProperty().addListener((ch, o, n) -> indicatorListView.setDisable(!n));

    indicatorListView.setOrientation(Orientation.VERTICAL);
    indicatorListView.setPrefSize(-1, DEFAULT_SELECTOR_HEIGHT);
    indicatorListView.setCellFactory(list -> new DataSelectorLabel());
    indicatorListView.setPrefHeight(Math.max(2, valueIndicators.size()) * ROW_HEIGHT + 2.0);
    GridPane.setConstraints(indicatorListView, 1, 1);
    final MultipleSelectionModel<AbstractSingleValueIndicator> selModel = indicatorListView.getSelectionModel();
    selModel.getSelectedIndices().addListener(selectionChangeListener);
    if (requiredNumberOfIndicators == 0) {
        this.setVisible(false);
    } else if (requiredNumberOfIndicators == 1) {
        selModel.setSelectionMode(SelectionMode.SINGLE);
    } else if (requiredNumberOfIndicators >= 2) {
        selModel.setSelectionMode(SelectionMode.MULTIPLE);
    }
    if (selModel.getSelectedIndices().isEmpty()) {
        for (int i = 0; i < Math.min(2, valueIndicators.size()); i++) {
            selModel.select(valueIndicators.get(i));
        }
    }

    if (requiredNumberOfIndicators > 0) {
        getChildren().addAll(label, reuseIndicators, indicatorListView);
    }
}
 
源代码24 项目: chart-fx   文件: DataSetSelector.java
public DataSet getSelectedDataSet() {
    MultipleSelectionModel<DataSet> selModel = dataSetListView.getSelectionModel();
    return selModel.getSelectedItem();
}
 
源代码25 项目: chart-fx   文件: DataSetSelector.java
public ObservableList<DataSet> getSelectedDataSets() {
    MultipleSelectionModel<DataSet> selModel = dataSetListView.getSelectionModel();
    return selModel.getSelectedItems();
}
 
private ObservableList<AppModelObject> getSelectedModelObjects() {
    final MultipleSelectionModel<AppModelObject> selectionModel = listView.getSelectionModel();
    return selectionModel.getSelectedItems();
}
 
源代码27 项目: MSPaintIDE   文件: SettingsWindow.java
public SettingsWindow(MainGUI mainGUI, List<SettingItem> settingItems, String startPath) throws IOException {
    super();
    this.mainGUI = mainGUI;
    this.settingItems = settingItems;
    this.startPath = startPath;
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("gui/PopupWindow.fxml"));
    loader.setController(this);
    Parent root = loader.load();

    ImageView icon = new ImageView(getClass().getClassLoader().getResource("icons/taskbar/ms-paint-logo-colored.png").toString());
    icon.setFitHeight(25);
    icon.setFitWidth(25);

    JFXDecorator jfxDecorator = new JFXDecorator(this, root, false, true, true);
    jfxDecorator.setGraphic(icon);
    jfxDecorator.setTitle("Settings");

    Scene scene = new Scene(jfxDecorator);
    scene.getStylesheets().add("style.css");

    setScene(scene);
    this.mainGUI.getThemeManager().addStage(this);
    show();

    setTitle("Settings");
    getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("ms-paint-logo-taskbar.png")));

    toggleStuff = newValue -> Map.of(
            "gridpane-theme", "gridpane-theme-dark",
            "theme-text", "dark-text",
            "search-label", "dark",
            "found-context", "dark",
            "language-selection", "language-selection-dark"
    ).forEach((key, value) -> root.lookupAll("." + key)
            .stream()
            .map(Node::getStyleClass)
            .forEach(styles -> {
                if (newValue) {
                    styles.add(value);
                } else {
                    while (styles.remove(value));
                }
            }));

    SettingsManager.getInstance().onChangeSetting(Setting.DARK_THEME, toggleStuff, true);

    List<TreeItem<SettingItem>> children = tree.getRoot().getChildren();

    if (startPath != null) {
        children.stream().flatMap(x -> Stream.of(x.isLeaf() ? x : x.getChildren())).map(TreeItem.class::cast).forEach(genericItem -> {
            SettingItem item = ((TreeItem<SettingItem>) genericItem).getValue();

            MultipleSelectionModel<TreeItem<SettingItem>> selectionModel = tree.getSelectionModel();
            if (item.toString().equalsIgnoreCase(startPath)) selectionModel.select(genericItem);
        });
    }

    tree.getSelectionModel().select(0);
}
 
源代码28 项目: jmonkeybuilder   文件: AppStateList.java
/**
 * Clear selection.
 */
@FxThread
public void clearSelection() {
    final MultipleSelectionModel<EditableSceneAppState> selectionModel = getListView().getSelectionModel();
    selectionModel.select(null);
}
 
源代码29 项目: jmonkeybuilder   文件: AppStateList.java
/**
 * Get the current selected item.
 *
 * @return the current selected item.
 */
@FxThread
public @Nullable EditableSceneAppState getSelected() {
    final MultipleSelectionModel<EditableSceneAppState> selectionModel = getListView().getSelectionModel();
    return selectionModel.getSelectedItem();
}
 
源代码30 项目: jmonkeybuilder   文件: FilterList.java
/**
 * Clear selection.
 */
@FxThread
public void clearSelection() {
    final MultipleSelectionModel<EditableSceneFilter> selectionModel = listView.getSelectionModel();
    selectionModel.select(null);
}
 
 类所在包
 同包方法