Joined: May 28, 2015
Post Count: 607
Status:
Offline
Grouping of plug-in actions
Is it possible to group the plug-in actions on the Tools menu as actions "Create photo...", "Create photos at points of view..." and "Create video..." of the 3D View menu? By default, all actions of a plug-in are separated in Tools menu.
----------------------------------------
EnkoNyito
France
Joined: Nov 7, 2005
Post Count: 9181
Status:
Offline
Re: Grouping of plug-in actions
Not in the current version, since a separator is added before each plug-in menu item. I guess it would be nice, but specifying groups of menu items might not be so easy to implement. If you have a simple idea, please share it.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Joined: May 28, 2015
Post Count: 607
Status:
Offline
Re: Grouping of plug-in actions
I thought that adding a loop with the list of plug-ins to put a separator after the last action of a menu would work. A plug-in as AdvancedEditing can have several actions divided in different menus so it is not easy to group them by menu.
----------------------------------------
EnkoNyito
Joined: May 28, 2015
Post Count: 607
Status:
Offline
Re: Grouping of plug-in actions
What do you think about this?
// Add menus to menu bar JMenuBar menuBar = new JMenuBar(); fileMenu.addSeparator(); // test (enkonyito) menuBar.add(fileMenu); editMenu.addSeparator(); // test (enkonyito) menuBar.add(editMenu); furnitureMenu.addSeparator(); // test (enkonyito) menuBar.add(furnitureMenu); if (controller.getPlanController().getView() != null) { planMenu.addSeparator(); // test (enkonyito) menuBar.add(planMenu); } if (controller.getHomeController3D().getView() != null) { preview3DMenu.addSeparator(); // test (enkonyito) menuBar.add(preview3DMenu); } menuBar.add(helpMenu);
// Add plugin actions menu items // debut test (enkonyito) // Create missing menu for (Action pluginAction : this.pluginActions) { String pluginMenu = (String)pluginAction.getValue(PluginAction.Property.MENU.name()); if (pluginMenu != null) { boolean pluginMenuExisting = false; for (int i = 0; i < menuBar.getMenuCount(); i++) { JMenu menu = menuBar.getMenu(i); if (menu.getText().equals(pluginMenu)) { pluginMenuExisting = true; break; } } if (!pluginMenuExisting) { // Create missing menu before last menu JMenu menu = new JMenu(pluginMenu); menuBar.add(menu, menuBar.getMenuCount() - 1); } } } // Group plug-in actions by menu for (int i = 0; i < menuBar.getMenuCount(); i++) { JMenu menu = menuBar.getMenu(i); for (Plugin plugin : this.plugins) { boolean pluginActionAdded = false; createActionsPlugin(plugin); for (Action pluginAction : this.actionsPlugin) { String pluginMenu = (String)pluginAction.getValue(PluginAction.Property.MENU.name()); if (pluginMenu != null) { if (menu.getText().equals(pluginMenu)) { // Add menu item to existing menu menu.add(new ResourceAction.MenuItemAction(pluginAction)); pluginActionAdded = true; } } } if (pluginActionAdded) { menu.addSeparator(); } } } // fin test (enkonyito)
//debut test (enkonyito) private void createActionsPlugin(Plugin plugin) { this.actionsPlugin = new ArrayList<Action>(); if (plugin != null) { for (final PluginAction pluginAction : plugin.getActions()) { // Create a Swing action adapter to plug-in action this.actionsPlugin.add(new ActionAdapter(pluginAction)); } } } //fin test (enkonyito)