/** * This adds a special item that is a top level menu item to the menu, this will appear directly * below other menus that are currently added to the menu. This menu item has special styling to * make it more apparent on the menu visually. IMPORTANT: the order in which you call addMenuItem * and addSpecialMenuItem affects the order in which they appear on the menu, but also the order * in which they are shown when the showNextViewOnMenu is called. Care must be taken when calling * these methods to insure a consistent/logical UI. */ @Override public void addSpecialMenuItem(final View view, String description) { // TODO add description to the menu item super.addView(view); menuViewMap.get("").add(view); menuOrder.add(view); KSMenuItemData item = new KSMenuItemData(view.getName()); item.addSpecialStyle("ks-menu-layout-special-menu-item-panel"); viewMenuItemMap.put(view.getViewEnum(), item); item.setClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { DeferredCommand.addCommand( new Command() { @Override public void execute() { MenuSectionController.this.showView(view.getViewEnum(), showViewCallback); } }); } }); topLevelMenuItems.add(item); if (refreshMenuOnAdd) { menu.refresh(); } }
/* Adds 'name' of the menu above menu items. This menu name has no view */ public void addMenu(String title) { if (title != null && !title.equals("")) { KSMenuItemData item = new KSMenuItemData(title); topLevelMenuItems.add(item); List<View> list = new ArrayList<View>(); menuViewMap.put(title, list); if (refreshMenuOnAdd) { menu.refresh(); } } }
/** * Adds a view whose view name will appear as a link on the menu, the view will be shown when this * item is clicked. IMPORTANT: the order in which you call addMenuItem and addSpecialMenuItem * affects the order in which they appear on the menu, but also the order in which they are shown * when the showNextViewOnMenu is called. Care must be taken when calling these methods to insure * a consistent/logical UI. */ @Override public void addMenuItem(String parentMenu, final View view) { super.addView(view); KSMenuItemData parentItem = null; for (int i = 0; i < topLevelMenuItems.size(); i++) { if (topLevelMenuItems.get(i).getLabel().equals(parentMenu)) { parentItem = topLevelMenuItems.get(i); break; } } KSMenuItemData item = new KSMenuItemData(view.getName()); viewMenuItemMap.put(view.getViewEnum(), item); item.setClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { DeferredCommand.addCommand( new Command() { @Override public void execute() { MenuSectionController.this.showView(view.getViewEnum(), showViewCallback); } }); } }); if (parentItem != null) { menuOrder.add(view); parentItem.addSubItem(item); menuViewMap.get(parentMenu).add(view); } else { menuOrder.add(view); topLevelMenuItems.add(item); menuViewMap.get("").add(view); } if (refreshMenuOnAdd) { menu.refresh(); } }
public void revealMenuItems() { menu.refresh(); refreshMenuOnAdd = true; }
/** * Adds a view whose view the menu at first. addMenuItem() should not be called before this method * if it is intended for this to be the first view the user sees. revealMenuItems() must be called * to show any items that were added after this call. IMPORTANT: the order in which you call this * method, addMenuItem and addSpecialMenuItem affects the order in which they appear on the menu, * but also the order in which they are shown when the showNextViewOnMenu is called. Care must be * taken when calling these methods to insure a consistent/logical UI. */ public void addStartMenuItem(String parentMenu, final View view) { addMenuItem(parentMenu, view); this.setDefaultView(view.getViewEnum()); refreshMenuOnAdd = false; menu.refresh(); }