|
16 | 16 |
|
17 | 17 | package com.techsenger.weaverbird.gui.menu; |
18 | 18 |
|
| 19 | +import com.techsenger.tabshell.core.ShellFxView; |
| 20 | +import com.techsenger.tabshell.core.menu.AbstractMenuItemHandler; |
| 21 | +import com.techsenger.tabshell.core.menu.MenuItemHandler; |
| 22 | +import com.techsenger.tabshell.core.registry.AbstractControlRegistrar; |
| 23 | +import com.techsenger.tabshell.core.registry.ControlFactory; |
| 24 | +import com.techsenger.tabshell.layout.tabhost.TabHostFxView; |
| 25 | +import com.techsenger.tabshell.material.icon.FontIconView; |
| 26 | +import com.techsenger.tabshell.material.menu.ManagedMenu; |
| 27 | +import com.techsenger.tabshell.material.menu.ManagedMenuGroup; |
| 28 | +import com.techsenger.tabshell.material.menu.ManagedMenuItem; |
19 | 29 | import com.techsenger.weaverbird.core.api.Framework; |
20 | 30 | import com.techsenger.weaverbird.gui.console.ConsoleTabFxView; |
21 | 31 | import com.techsenger.weaverbird.gui.console.ConsoleTabPresenter; |
|
24 | 34 | import com.techsenger.weaverbird.gui.style.ConsoleIcons; |
25 | 35 | import com.techsenger.weaverbird.net.client.api.ClientService; |
26 | 36 | import com.techsenger.weaverbird.net.client.api.ClientServiceFactory; |
27 | | -import com.techsenger.tabshell.core.CoreComponents; |
28 | | -import com.techsenger.tabshell.core.ShellFxView; |
29 | | -import com.techsenger.tabshell.core.registry.AbstractControlRegistrar; |
30 | | -import com.techsenger.tabshell.core.registry.ControlFactory; |
31 | | -import com.techsenger.tabshell.layout.tabhost.TabHostFxView; |
32 | | -import com.techsenger.tabshell.material.icon.FontIconView; |
33 | | -import com.techsenger.tabshell.material.menu.NamedMenu; |
34 | | -import com.techsenger.tabshell.material.menu.NamedMenuGroup; |
35 | | -import com.techsenger.tabshell.material.menu.NamedMenuItem; |
36 | 37 | import javafx.scene.input.KeyCode; |
37 | 38 | import javafx.scene.input.KeyCodeCombination; |
38 | 39 | import javafx.scene.input.KeyCombination; |
@@ -65,53 +66,61 @@ public void register() { |
65 | 66 | } |
66 | 67 |
|
67 | 68 | protected void registerMenu() { |
68 | | - ControlFactory<NamedMenu> f = (v) -> { |
69 | | - return new NamedMenu(FileMenu.NAME, "_File", 0); |
| 69 | + ControlFactory<ShellFxView<?>, ManagedMenu> f = (v) -> { |
| 70 | + return new ManagedMenu(FileMenu.NAME, "_File", 0); |
70 | 71 | }; |
71 | | - addRegistration(getRegistry().registerMenu(CoreComponents.SHELL, null, f)); |
| 72 | + addRegistration(getRegistry().mainMenu().registerMenu(null, f)); |
72 | 73 | } |
73 | 74 |
|
74 | 75 | private void registerMainGroup() { |
75 | | - ControlFactory<NamedMenuGroup> f = (v) -> new NamedMenuGroup(FileMenu.MAIN, 100); |
76 | | - addRegistration(getRegistry().registerMenuGroup(CoreComponents.SHELL, FileMenu.NAME, f)); |
| 76 | + ControlFactory<ShellFxView<?>, ManagedMenuGroup> f = (v) -> new ManagedMenuGroup(FileMenu.MAIN, 100); |
| 77 | + addRegistration(getRegistry().mainMenu().registerMenuGroup(FileMenu.NAME, f)); |
77 | 78 | } |
78 | 79 |
|
79 | 80 | private void registerConsoleItem() { |
80 | | - ControlFactory<NamedMenuItem> f = (v) -> { |
81 | | - var item = new NamedMenuItem(FileMenu.CONSOLE, false, false, false, "C_onsole", 100); |
| 81 | + ControlFactory<ShellFxView<?>, ManagedMenuItem> f = (v) -> { |
| 82 | + var item = new ManagedMenuItem("C_onsole", 100); |
82 | 83 | item.setGraphic(new FontIconView(ConsoleIcons.CONSOLE)); |
83 | 84 | item.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN)); |
84 | | - item.setOnAction((e) -> { |
85 | | - var shell = (ShellFxView<?>) v; |
86 | | - var consoleView = new ConsoleTabFxView<>(shell); |
87 | | - var consolePresenter = new ConsoleTabPresenter<>(consoleView, framework, client, null); |
88 | | - consolePresenter.initialize(); |
89 | | - TabHostFxView<?> workspace = (TabHostFxView<?>) shell.getComposer().getWorkspace(); |
90 | | - workspace.getComposer().addTab(consoleView); |
91 | | - }); |
92 | | - return item; |
| 85 | + var handler = new AbstractMenuItemHandler<ShellFxView<?>>(item, shell) { |
93 | 86 |
|
| 87 | + @Override |
| 88 | + public void onAction() { |
| 89 | + var shell = getComponent(); |
| 90 | + var consoleView = new ConsoleTabFxView<>(shell); |
| 91 | + var consolePresenter = new ConsoleTabPresenter<>(consoleView, framework, client, null); |
| 92 | + consolePresenter.initialize(); |
| 93 | + TabHostFxView<?> workspace = (TabHostFxView<?>) shell.getComposer().getWorkspace(); |
| 94 | + workspace.getComposer().addTab(consoleView); |
| 95 | + } |
| 96 | + }; |
| 97 | + MenuItemHandler.setHandler(item, handler); |
| 98 | + return item; |
94 | 99 | }; |
95 | | - addRegistration(getRegistry().registerMenuItem(CoreComponents.SHELL, FileMenu.MAIN, f)); |
| 100 | + addRegistration(getRegistry().mainMenu().registerMenuItem(FileMenu.MAIN, f)); |
96 | 101 | } |
97 | 102 |
|
98 | 103 | private void registerDiagramItem() { |
99 | | - ControlFactory<NamedMenuItem> f = (v) -> { |
100 | | - var item = new NamedMenuItem(FileMenu.DIAGRAM, false, false, false, "D_iagrams", 200); |
| 104 | + ControlFactory<ShellFxView<?>, ManagedMenuItem> f = (v) -> { |
| 105 | + var item = new ManagedMenuItem("D_iagrams", 200); |
101 | 106 | item.setGraphic(new FontIconView(ConsoleIcons.DIAGRAMS)); |
102 | 107 | item.setAccelerator(new KeyCodeCombination(KeyCode.D, KeyCombination.CONTROL_DOWN)); |
103 | | - item.setOnAction((e) -> { |
104 | | - var shell = (ShellFxView<?>) v; |
105 | | - var diagramView = new DiagramTabFxView<>(shell); |
106 | | - var diagramPresenter = new DiagramTabPresenter<>(diagramView, framework, client, null); |
107 | | - diagramPresenter.initialize(); |
108 | | - TabHostFxView<?> workspace = (TabHostFxView<?>) shell.getComposer().getWorkspace(); |
109 | | - workspace.getComposer().addTab(diagramView); |
110 | | - }); |
| 108 | + var handler = new AbstractMenuItemHandler<ShellFxView<?>>(item, shell) { |
| 109 | + @Override |
| 110 | + public void onAction() { |
| 111 | + var shell = getComponent(); |
| 112 | + var diagramView = new DiagramTabFxView<>(shell); |
| 113 | + var diagramPresenter = new DiagramTabPresenter<>(diagramView, framework, client, null); |
| 114 | + diagramPresenter.initialize(); |
| 115 | + TabHostFxView<?> workspace = (TabHostFxView<?>) shell.getComposer().getWorkspace(); |
| 116 | + workspace.getComposer().addTab(diagramView); |
| 117 | + } |
| 118 | + }; |
| 119 | + MenuItemHandler.setHandler(item, handler); |
111 | 120 | return item; |
112 | 121 |
|
113 | 122 | }; |
114 | | - addRegistration(getRegistry().registerMenuItem(CoreComponents.SHELL, FileMenu.MAIN, f)); |
| 123 | + addRegistration(getRegistry().mainMenu().registerMenuItem(FileMenu.MAIN, f)); |
115 | 124 | } |
116 | 125 |
|
117 | 126 | // private void registerSettingsItem() { |
|
0 commit comments