Search in sources :

Example 56 with MenuItem

use of javafx.scene.control.MenuItem in project jgnash by ccavanaugh.

the class TestFxPlugin method start.

@Override
public void start(final PluginPlatform pluginPlatform) {
    System.out.println("Starting test plugin");
    if (pluginPlatform != PluginPlatform.Fx) {
        throw new RuntimeException("Invalid platform");
    }
    Platform.runLater(() -> {
        //for API test.  Lookup allows plugins to find nodes within the application scene
        final Node node = MainView.getInstance().lookup("#fileMenu");
        if (node != null) {
            System.out.println("found the file menu");
            // Not really a node, but the skin for the node,
            System.out.println(node.getClass().toString());
        }
        assert MainView.getInstance().lookup("#importMenu") != null;
        // Install a menu item
        final MenuBar menuBar = MainView.getInstance().getMenuBar();
        menuBar.getMenus().stream().filter(menu -> menu.getId().equals("fileMenu")).forEach(menu -> {
            System.out.println("found the file menu");
            menu.getItems().add(new MenuItem("Plugin Menu"));
        });
    });
}
Also used : Platform(javafx.application.Platform) Color(javafx.scene.paint.Color) MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem) FxPlugin(jgnash.plugin.FxPlugin) Node(javafx.scene.Node) MainView(jgnash.uifx.views.main.MainView) Rectangle(javafx.scene.shape.Rectangle) Node(javafx.scene.Node) MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem)

Example 57 with MenuItem

use of javafx.scene.control.MenuItem in project jgnash by ccavanaugh.

the class PopOverButton method setContentNode.

/**
     * Sets the value of the content property.
     *
     * @param content the new content node value
     */
public final void setContentNode(final Node content) {
    contentNode.set(content);
    final VBox vBox = new VBox(5);
    vBox.setAlignment(Pos.CENTER);
    vBox.getChildren().setAll(content);
    final MenuItem menuItem = new MenuItem();
    menuItem.setGraphic(vBox);
    getItems().setAll(menuItem);
}
Also used : MenuItem(javafx.scene.control.MenuItem) VBox(javafx.scene.layout.VBox)

Example 58 with MenuItem

use of javafx.scene.control.MenuItem in project jgnash by ccavanaugh.

the class Mt940Plugin method installFxMenu.

private static void installFxMenu() {
    final MenuBar menuBar = MainView.getInstance().getMenuBar();
    menuBar.getMenus().stream().filter(menu -> "fileMenu".equals(menu.getId())).forEach(menu -> menu.getItems().stream().filter(menuItem -> menuItem instanceof Menu).filter(menuItem -> "importMenu".equals(menuItem.getId())).forEach(menuItem -> {
        final MenuItemEx importMenuItem = new MenuItemEx(ResourceUtils.getString("Menu.ImportMt940.Name"));
        importMenuItem.setOnAction(event -> ImportMt940FxAction.showAndWait());
        ((Menu) menuItem).getItems().add(MENU_INDEX, importMenuItem);
    }));
}
Also used : MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem) SwingPlugin(jgnash.plugin.SwingPlugin) MainView(jgnash.uifx.views.main.MainView) ResourceUtils(jgnash.util.ResourceUtils) MessageBus(jgnash.engine.message.MessageBus) Logger(java.util.logging.Logger) Level(java.util.logging.Level) Menu(javafx.scene.control.Menu) Platform(javafx.application.Platform) JMenuItem(javax.swing.JMenuItem) MessageChannel(jgnash.engine.message.MessageChannel) FxPlugin(jgnash.plugin.FxPlugin) Message(jgnash.engine.message.Message) MessageListener(jgnash.engine.message.MessageListener) MenuBar(javafx.scene.control.MenuBar) Menu(javafx.scene.control.Menu)

Aggregations

MenuItem (javafx.scene.control.MenuItem)58 ContextMenu (javafx.scene.control.ContextMenu)32 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)20 Menu (javafx.scene.control.Menu)19 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)9 Node (javafx.scene.Node)7 File (java.io.File)6 MenuBar (javafx.scene.control.MenuBar)6 VBox (javafx.scene.layout.VBox)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 CommonContextMenuEvent (com.kyj.fx.voeditor.visual.events.CommonContextMenuEvent)4 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)4 ActionEvent (javafx.event.ActionEvent)4 FXML (javafx.fxml.FXML)4 Scene (javafx.scene.Scene)4 ImageView (javafx.scene.image.ImageView)4 BorderPane (javafx.scene.layout.BorderPane)4 Logger (org.slf4j.Logger)4 EventHandler (javafx.event.EventHandler)3