Search in sources :

Example 6 with MenuBar

use of javafx.scene.control.MenuBar 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 7 with MenuBar

use of javafx.scene.control.MenuBar 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

MenuBar (javafx.scene.control.MenuBar)7 Menu (javafx.scene.control.Menu)6 MenuItem (javafx.scene.control.MenuItem)6 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Platform (javafx.application.Platform)2 Scene (javafx.scene.Scene)2 TreeItem (javafx.scene.control.TreeItem)2 BorderPane (javafx.scene.layout.BorderPane)2 FxPlugin (jgnash.plugin.FxPlugin)2 MainView (jgnash.uifx.views.main.MainView)2 JsonElement (com.google.gson.JsonElement)1 DatabaseTreeNode (com.kyj.fx.voeditor.visual.component.sql.dbtree.DatabaseTreeNode)1 DatabaseItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree)1 PostgreDatabaseItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.postgre.PostgreDatabaseItemTree)1 PostgreTableItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.postgre.PostgreTableItemTree)1 SaveSQLFileFunction (com.kyj.fx.voeditor.visual.component.sql.functions.SaveSQLFileFunction)1 CommonsSqllPan (com.kyj.fx.voeditor.visual.component.sql.view.CommonsSqllPan)1 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)1