use of org.phoebus.ui.spi.MenuEntry in project phoebus by ControlSystemStudio.
the class MenuEntryService method populateMenuTree.
/**
* @param root
* @param menuEntries
*/
synchronized void populateMenuTree(MenuTreeNode root, List<MenuEntry> menuEntries) {
// Sort hidden menu entries to allow binary search
Arrays.sort(Preferences.hide_spi_menu);
for (MenuEntry menuEntry : menuEntries) {
// Skip hidden menu entries
final String clazz = menuEntry.getClass().getName();
if (Arrays.binarySearch(Preferences.hide_spi_menu, clazz) >= 0)
continue;
MenuTreeNode parent = root;
List<String> path = Arrays.asList(menuEntry.getMenuPath().split("\\."));
for (String p : path) {
Optional<MenuTreeNode> child = parent.getChild(p);
if (child.isPresent()) {
parent = child.get();
} else {
MenuTreeNode node = new MenuTreeNode(p);
parent.addChildren(node);
parent = node;
}
}
parent.addMenuEntries(menuEntry);
}
}
use of org.phoebus.ui.spi.MenuEntry in project phoebus by ControlSystemStudio.
the class PhoebusApplication method addMenuNode.
private void addMenuNode(Menu parent, MenuTreeNode node) {
for (MenuEntry entry : node.getMenuItems()) {
MenuItem m = createMenuItem(entry);
parent.getItems().add(m);
}
for (MenuTreeNode child : node.getChildren()) {
Menu childMenu = new Menu(child.getName());
addMenuNode(childMenu, child);
parent.getItems().add(childMenu);
}
}
use of org.phoebus.ui.spi.MenuEntry in project phoebus by ControlSystemStudio.
the class MenuEntryServiceTest method test.
@Test
public void test() {
List<MenuEntry> menuEntries = Arrays.asList(new testMenuEntry("applications.display", "greetings"), new testMenuEntry("applications.display", "hello"));
MenuTreeNode root = new MenuTreeNode("Applications");
MenuEntryService.getInstance().populateMenuTree(root, menuEntries);
assertTrue("Parsing MenuEntries: ", root.getChildren().size() == 1);
assertTrue("Parsing MenuEntries: ", root.getMenuItems().size() == 0);
MenuTreeNode applicationsNode = root.getChildren().get(0);
assertTrue("Parsing MenuEntries: ", applicationsNode.getChildren().size() == 1);
assertTrue("Parsing MenuEntries: ", applicationsNode.getMenuItems().size() == 0);
MenuTreeNode displayNode = applicationsNode.getChildren().get(0);
assertTrue("Parsing MenuEntries: ", displayNode.getChildren().size() == 0);
assertTrue("Parsing MenuEntries: ", displayNode.getMenuItems().size() == 2);
}
Aggregations