19 package org.sleuthkit.autopsy.timeline.ui.listvew;
21 import javafx.scene.control.Menu;
22 import javafx.scene.control.MenuItem;
23 import javafx.scene.control.SeparatorMenuItem;
24 import javax.swing.JMenu;
25 import javax.swing.JMenuItem;
26 import javax.swing.JPopupMenu;
27 import javax.swing.MenuElement;
28 import javax.swing.SwingUtilities;
34 class SwingFXMenuUtils {
36 private SwingFXMenuUtils() {
47 public static MenuItem createFXMenu(MenuElement jMenuElement) {
48 if (jMenuElement == null) {
50 return new SeparatorMenuItem();
51 }
else if (jMenuElement instanceof JMenu) {
52 return new MenuAdapter((JMenu) jMenuElement);
53 }
else if (jMenuElement instanceof JPopupMenu) {
54 return new MenuAdapter((JPopupMenu) jMenuElement);
56 return new MenuItemAdapter((JMenuItem) jMenuElement);
66 super(jMenuItem.getText());
67 setDisable(jMenuItem.isEnabled() ==
false);
68 setOnAction(actionEvent -> SwingUtilities.invokeLater(jMenuItem::doClick));
84 super(jMenu.getText());
85 setDisable(jMenu.isEnabled() ==
false);
95 super(jPopupMenu.getLabel());
96 setDisable(jPopupMenu.isEnabled() ==
false);
107 for (MenuElement menuElement : menu.getSubElements()) {
108 if (menuElement == null) {
110 getItems().add(
new SeparatorMenuItem());
112 }
else if (menuElement instanceof JMenuItem) {
113 getItems().add(SwingFXMenuUtils.createFXMenu(menuElement));
115 }
else if (menuElement instanceof JPopupMenu) {
118 throw new UnsupportedOperationException(
"Unown MenuElement subclass: " + menuElement.getClass().getName());