Java Examples for javafx.scene.control.CheckMenuItem

The following java examples will help you to understand the usage of javafx.scene.control.CheckMenuItem. These source code samples are taken from different open source projects.

Example 1
Project: Cachoeira-master  File: TaskContextMenu.java View source code
private void refreshDependencyTaskMenu(ObservableList<MenuItem> menuItemsList, ITask task, ObservableList<ITask> taskList) {
    menuItemsList.clear();
    taskList.stream().filter(// Убираем возможность присвоить предшественником саму себя
     parentTask -> !parentTask.equals(task)).forEach( parentTask -> {
        CheckMenuItem checkMenuItem = new CheckMenuItem(parentTask.getName());
        task.getParentTasks().stream().filter( dependentTask -> parentTask.equals(dependentTask.getTask()) && !checkMenuItem.isSelected()).forEach( dependentTask -> checkMenuItem.setSelected(true));
        checkMenuItem.setOnAction( event -> {
            if (checkMenuItem.isSelected()) {
                controller.getCommandExecutor().execute(new AddParentTaskToTaskCommand(task, new DependentTask(parentTask, TaskDependencyType.FINISHSTART)));
                controller.getCommandExecutor().execute(new AddChildTaskToTaskCommand(parentTask, new DependentTask(task, null)));
            } else {
                task.getParentTasks().stream().filter( dependentTask -> dependentTask.getTask().equals(parentTask)).findFirst().ifPresent( dependentTask -> controller.getCommandExecutor().execute(new RemoveParentTaskFromTaskCommand(task, dependentTask)));
                parentTask.getChildTasks().stream().filter( dependentTask -> dependentTask.getTask().equals(task)).findFirst().ifPresent( dependentTask -> controller.getCommandExecutor().execute(new RemoveChildTaskFromTaskCommand(parentTask, dependentTask)));
            }
        });
        menuItemsList.add(checkMenuItem);
    });
    // Отключаем те задачи, которые уже находятся в списке последователей (childTasks),
    // чтобы нельзя было сделать закольцованность (например Задача 2 начинается после
    // Задачи 1, а Задача 1, после Задачи 2)
    setDisableSelectionChildTasks(task, menuItemsList);
}
Example 2
Project: mqtt-spy-master  File: ContextMenuUtils.java View source code
private static Menu createConnectionPaneMenu(final String name, final ConnectionController connectionController, final TitledPaneStatus status) {
    final Menu menu = new Menu(name);
    status.setContentMenu(menu);
    final CheckMenuItem hidden = new CheckMenuItem("Hidden");
    hidden.setSelected(true);
    final CheckMenuItem visible = new CheckMenuItem("Visible (attached to connection tab)");
    final CheckMenuItem detached = new CheckMenuItem("Visible (detached from connection tab)");
    menu.getItems().add(hidden);
    menu.getItems().add(visible);
    menu.getItems().add(detached);
    hidden.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent e) {
            connectionController.setPaneVisiblity(status, PaneVisibilityStatus.NOT_VISIBLE);
        }
    });
    visible.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent e) {
            connectionController.setPaneVisiblity(status, PaneVisibilityStatus.ATTACHED);
        }
    });
    detached.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent e) {
            connectionController.setPaneVisiblity(status, PaneVisibilityStatus.DETACHED);
        }
    });
    return menu;
}
Example 3
Project: AsciidocFX-master  File: ViewPanel.java View source code
private void initializePreviewContextMenus() {
    CheckMenuItem stopRenderingItem = new CheckMenuItem("Stop rendering");
    CheckMenuItem stopScrollingItem = new CheckMenuItem("Stop scrolling");
    CheckMenuItem stopJumpingItem = new CheckMenuItem("Stop jumping");
    stopRenderingItem.selectedProperty().addListener(( observable,  oldValue,  newValue) -> {
        controller.stopRenderingProperty().setValue(newValue);
    });
    stopScrollingItem.selectedProperty().addListener(( observable,  oldValue,  newValue) -> {
        stopScrolling.setValue(newValue);
    });
    stopJumpingItem.selectedProperty().addListener(( observable,  oldValue,  newValue) -> {
        stopJumping.setValue(newValue);
    });
    MenuItem refresh = MenuItemBuilt.item("Clear image cache").click( e -> {
        webEngine().executeScript("clearImageCache()");
    });
    getWebView().setOnContextMenuRequested( event -> {
        @SuppressWarnings("deprecation") final Iterator<Window> windows = Window.impl_getWindows();
        while (windows.hasNext()) {
            final Window window = windows.next();
            if (window instanceof ContextMenu) {
                Optional<Node> nodeOptional = Optional.ofNullable(window).map(Window::getScene).map(Scene::getRoot).map(Parent::getChildrenUnmodifiable).filter(( nodes) -> !nodes.isEmpty()).map( e -> e.get(0)).map( e -> e.lookup(".context-menu"));
                if (nodeOptional.isPresent()) {
                    ObservableList<Node> childrenUnmodifiable = ((Parent) nodeOptional.get()).getChildrenUnmodifiable();
                    ContextMenuContent cmc = (ContextMenuContent) childrenUnmodifiable.get(0);
                    cmc.getItemsContainer().getChildren().add(new Separator());
                    cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(stopRenderingItem));
                    cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(stopScrollingItem));
                    cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(stopJumpingItem));
                }
            }
        }
    });
}
Example 4
Project: jubula.core-master  File: MenuItemAdapter.java View source code
@Override
public boolean isSelected() {
    return //$NON-NLS-1$
    EventThreadQueuerJavaFXImpl.invokeAndWait(//$NON-NLS-1$
    "isSelected", new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            MenuItem item = getRealComponent();
            if (item instanceof Toggle) {
                return ((Toggle) item).isSelected();
            } else if (item instanceof CheckMenuItem) {
                return ((CheckMenuItem) item).isSelected();
            }
            return false;
        }
    });
}
Example 5
Project: JFTClient-master  File: JFTClient.java View source code
private MenuBar createMenu() {
    MenuBar menuBar = new MenuBar();
    Menu menuEdit = new Menu("Edit");
    MenuItem editHosts = new MenuItem("Hosts");
    editHosts.setOnAction( event -> createEditHostsDialog());
    menuEdit.getItems().add(editHosts);
    Menu menuView = new Menu("View");
    CheckMenuItem cmShowHiddenFiles = new CheckMenuItem("Show hidden files");
    cmShowHiddenFiles.setSelected(configDao.get().isShowHiddenFiles());
    cmShowHiddenFiles.selectedProperty().addListener(( observable,  oldValue,  newValue) -> {
        Config config = configDao.get();
        config.setShowHiddenFiles(newValue);
        configDao.save(config);
        cellLocal.refreshTree();
        if (cellRemote != null) {
            cellRemote.refreshTree();
        }
    });
    menuView.getItems().addAll(cmShowHiddenFiles);
    Menu menuSettings = new Menu("Settings");
    CheckMenuItem cmSavePasswords = new CheckMenuItem("Save passwords");
    cmSavePasswords.setSelected(configDao.get().isSavePasswords());
    cmSavePasswords.selectedProperty().addListener(( observable,  oldValue,  newValue) -> {
        Config config = configDao.get();
        config.setSavePasswords(newValue);
        configDao.save(config);
    });
    menuSettings.getItems().addAll(cmSavePasswords);
    menuBar.getMenus().addAll(menuEdit, menuView, menuSettings);
    return menuBar;
}
Example 6
Project: FXDesktopSearch-master  File: Undecorator.java View source code
/**
     * Manage buttons and menu items
     */
void initDecoration() {
    MenuItem minimizeMenuItem = null;
    // Menu
    final ContextMenu contextMenu = new ContextMenu();
    contextMenu.setAutoHide(true);
    if (minimize != null) {
        // Utility Stage
        minimizeMenuItem = new MenuItem(LOC.getString("Minimize"));
        minimizeMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.M, KeyCombination.SHORTCUT_DOWN));
        minimizeMenuItem.setOnAction( e -> switchMinimize());
        contextMenu.getItems().add(minimizeMenuItem);
    }
    if (maximize != null && stage.isResizable()) {
        // Utility Stage type
        maximizeMenuItem = new MenuItem(LOC.getString("Maximize"));
        maximizeMenuItem.setOnAction( e -> {
            switchMaximize();
            contextMenu.hide();
        });
        contextMenu.getItems().addAll(maximizeMenuItem, new SeparatorMenuItem());
    }
    // Fullscreen
    if (stageStyle != StageStyle.UTILITY && stage.isResizable()) {
        fullScreenMenuItem = new CheckMenuItem(LOC.getString("FullScreen"));
        fullScreenMenuItem.setOnAction( e -> switchFullscreen());
        fullScreenMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN, KeyCombination.SHORTCUT_DOWN));
        contextMenu.getItems().addAll(fullScreenMenuItem, new SeparatorMenuItem());
    }
    // Close
    MenuItem closeMenuItem = new MenuItem(LOC.getString("Close"));
    closeMenuItem.setOnAction( e -> switchClose());
    closeMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN));
    contextMenu.getItems().add(closeMenuItem);
    menu.setOnMousePressed( t -> {
        if (contextMenu.isShowing()) {
            contextMenu.hide();
        } else {
            contextMenu.show(menu, Side.BOTTOM, 0, 0);
        }
    });
    // Close button
    close.setTooltip(new Tooltip(LOC.getString("Close")));
    close.setOnAction( t -> switchClose());
    // Maximize button
    // If changed via contextual menu
    maximizeProperty().addListener(( ov,  t,  t1) -> {
        Tooltip tooltip = maximize.getTooltip();
        if (tooltip.getText().equals(LOC.getString("Maximize"))) {
            tooltip.setText(LOC.getString("Restore"));
            maximizeMenuItem.setText(LOC.getString("Restore"));
            maximize.getStyleClass().add("decoration-button-restore");
            resize.setVisible(false);
        } else {
            tooltip.setText(LOC.getString("Maximize"));
            maximizeMenuItem.setText(LOC.getString("Maximize"));
            maximize.getStyleClass().remove("decoration-button-restore");
            resize.setVisible(true);
        }
    });
    if (maximize != null) {
        // Utility Stage
        maximize.setTooltip(new Tooltip(LOC.getString("Maximize")));
        maximize.setOnAction( t -> switchMaximize());
    }
    if (fullscreen != null) {
        // Utility Stage
        fullscreen.setTooltip(new Tooltip(LOC.getString("FullScreen")));
        fullscreen.setOnAction( t -> switchFullscreen());
    }
    // Minimize button
    if (minimize != null) {
        // Utility Stage
        minimize.setTooltip(new Tooltip(LOC.getString("Minimize")));
        minimize.setOnAction( t -> switchMinimize());
    }
    // Transfer stage title to undecorator tiltle label
    title.setText(stage.getTitle());
}
Example 7
Project: jvarkit-master  File: BamStage.java View source code
/** build a Predicate for filtering on SAM FLAG using the checkboxes */
private Predicate<SAMRecord> makeFlagPredicate() {
    java.util.function.Predicate<SAMRecord> recFilter =  x -> true;
    for (final SAMFlag flag : this.flag2filterInMenuItem.keySet()) {
        CheckMenuItem cbox = this.flag2filterInMenuItem.get(flag);
        if (!cbox.isSelected())
            continue;
        recFilter = recFilter.and( R -> flag.isSet(R.getFlags()));
    }
    for (final SAMFlag flag : this.flag2filterOutMenuItem.keySet()) {
        CheckMenuItem cbox = this.flag2filterOutMenuItem.get(flag);
        if (!cbox.isSelected())
            continue;
        recFilter = recFilter.and( R -> !flag.isSet(R.getFlags()));
    }
    return recFilter;
}
Example 8
Project: Augendiagnose-master  File: MenuController.java View source code
public final CheckMenuItem getMenuOverlayPane() {
    return mMenuOverlayPane;
}
Example 9
Project: FXGL-master  File: DeveloperMenuBarController.java View source code
public void onShowBBox(ActionEvent event) {
    CheckMenuItem item = (CheckMenuItem) event.getSource();
    FXGL.setProperty("dev.showbbox", item.isSelected());
    app.getGameWorld().getEntitiesByComponent(ViewComponent.class).forEach( e -> {
        e.getComponentUnsafe(ViewComponent.class).turnOnDebugBBox(item.isSelected());
    });
}
Example 10
Project: JXTN-master  File: JFX.java View source code
/**
     * 建立新的{@link javafx.scene.control.CheckMenuItem}建構器。
     *
     * @return 新的{@link javafx.scene.control.CheckMenuItemMaker}
     */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static javafx.scene.control.CheckMenuItemMaker<javafx.scene.control.CheckMenuItem, ?> checkMenuItem() {
    return new javafx.scene.control.CheckMenuItemMaker();
}
Example 11
Project: griffon-master  File: JavaFXUtils.java View source code
public static void configure(@Nonnull final CheckMenuItem control, @Nonnull final JavaFXAction action) {
    configure((MenuItem) control, action);
    action.selectedProperty().addListener(( v,  o,  n) -> runInsideUIThread(() -> control.setSelected(n)));
    runInsideUIThread(() -> control.setSelected(action.isSelected()));
}