@Test public void commandManagerParseConfigTest() { Dictionary<Object,Object> props = new Properties(); props.put("toplevelMenuOrder", "File,Edit,View,Additions,Help"); props.put("submenu.File.groups", "start,new,close,save,print,open,import,additions,end"); props.put("submenu.Edit.groups", "start,undo,cut,find,add,end,additions"); props.put("submenu.View.groups", "start,additions,end"); props.put("submenu.Help.groups", "start,main,tools,updates,end,additions"); props.put("submenu.Default.groups", "start,main,end,additions"); Map<String, List<String>> expected = new HashMap<String, List<String>>(); expected.put("File", Arrays.asList("start", "new", "close", "save", "print", "open", "import", "additions", "end")); expected.put("Edit", Arrays.asList("start", "undo", "cut", "find", "add", "end","additions")); expected.put("View", Arrays.asList("start", "additions", "end")); expected.put("Help", Arrays.asList("start", "main", "tools", "updates", "end", "additions")); expected.put("Default", Arrays.asList("start", "main", "end", "additions")); CommandManager cmdManager = new CommandManager(); cmdManager.updateMenuConfig(props); Map<String, List<String>> actual = cmdManager.getMenuOrderConfig(); assertEquals(expected.get("File"), actual.get("File")); assertEquals(expected.get("Edit"), actual.get("Edit")); assertEquals(expected.get("View"), actual.get("View")); assertEquals(expected.get("Help"), actual.get("Help")); assertEquals(expected.get("Default"), actual.get("Default")); }
@SuppressWarnings("unchecked") public MenuBar get() { MenuBar menuBar = new MenuBar(); Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems(); for(Entry<String, Object> entry : sortedEntrySet) { if(entry.getValue() instanceof Map) { MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null); addMenuItems(menuItem, (Map<String, Object>) entry.getValue()); }else { menuBar.addItem(entry.getKey(), (Command) entry.getValue()); } } return menuBar; }
MenuBarBuilder extends MenuBuilder<MenuBar.Command, MenuItem> { @SuppressWarnings("unchecked") public MenuBar get() { MenuBar menuBar = new MenuBar(); Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems(); for(Entry<String, Object> entry : sortedEntrySet) { if(entry.getValue() instanceof Map) { MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null); addMenuItems(menuItem, (Map<String, Object>) entry.getValue()); }else { menuBar.addItem(entry.getKey(), (Command) entry.getValue()); } } return menuBar; } }
MenuBarBuilder extends MenuBuilder<MenuBar.Command, MenuItem> { @SuppressWarnings("unchecked") public MenuBar get() { MenuBar menuBar = new MenuBar(); Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems(); for(Entry<String, Object> entry : sortedEntrySet) { if(entry.getValue() instanceof Map) { MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null); addMenuItems(menuItem, (Map<String, Object>) entry.getValue()); }else { menuBar.addItem(entry.getKey(), (Command) entry.getValue()); } } return menuBar; } MenuBarBuilder(); }
MenuBarBuilder extends MenuBuilder<MenuBar.Command, MenuItem> { @SuppressWarnings("unchecked") public MenuBar get() { MenuBar menuBar = new MenuBar(); Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems(); for(Entry<String, Object> entry : sortedEntrySet) { if(entry.getValue() instanceof Map) { MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null); addMenuItems(menuItem, (Map<String, Object>) entry.getValue()); }else { menuBar.addItem(entry.getKey(), (Command) entry.getValue()); } } return menuBar; } MenuBarBuilder(); @SuppressWarnings("unchecked") MenuBar get(); }
MenuBarBuilder extends MenuBuilder<MenuBar.Command, MenuItem> { @SuppressWarnings("unchecked") public MenuBar get() { MenuBar menuBar = new MenuBar(); Set<Entry<String, Object>> sortedEntrySet = getSortedMenuItems(); for(Entry<String, Object> entry : sortedEntrySet) { if(entry.getValue() instanceof Map) { MenuBar.MenuItem menuItem = menuBar.addItem(entry.getKey(), null); addMenuItems(menuItem, (Map<String, Object>) entry.getValue()); }else { menuBar.addItem(entry.getKey(), (Command) entry.getValue()); } } return menuBar; } MenuBarBuilder(); @SuppressWarnings("unchecked") MenuBar get();  }