-
Task
-
Resolution: Done
-
Major
-
None
-
2020 Week 28-30 (from Jul 6)
Goal: Once the context menu is triggered, it must show options for a contextual action.
Implementation details: Basically, this widget is going to be as simple and generic, as possible. This is because it is so common, that in future we could have more use cases, where a context menu is needed.
Let me describe its APIs via an utilization example:
@EventHandler("trigger-context-menu") public void triggerContextMenu(final ClickEvent event) { mainTree.appendChild(dRDContextMenu.getElement()); dRDContextMenu.resetMenuItems(); dRDContextMenu.setHeaderMenu("DRD ACTIONS", "fa fa-share-alt"); dRDContextMenu.addTextMenuItem("Create", true, () -> DomGlobal.console.log("Creates a new DRD with the selected node")); dRDContextMenu.addTextMenuItem("Add to", true, () -> DomGlobal.console.log("Adds a node the the selected DRD")); dRDContextMenu.addTextMenuItem("Remove", true, () -> DomGlobal.console.log("Removes the node from the current DRD (it corresponds to the same action in the trash icon)")); dRDContextMenu.show(); }
- The position of the widget will be decided by the container, in which the widget will be instantiated.
- A resetMenuItems method, it useful to clear all items belonging to such menu context instance.
- A setHeaderMenu method, it is used to set the menu header. It accepts two parameters: the header title and the header CSS class menu (you can use font awesome classes).
- A addTextMenuItem method, it is used to populate menu items list. It accepts item title, a boolean to set if such item is enabled or not, and a command to be executed when such item is clicked.
- show() and hide() methods, for widget visibility.
Note: The context menu widget can be extended to support different kind of menu item, for example multi-level items, or items that contain icons.