final NavigationMenu topMenu = getTopMenu(view, referringPageId, user, addStore);
model.addAttribute(topMenu.getName(), topMenu);
}
public static NavigationMenu getTopMenu(String view, String referringPageId, User user, boolean addStoreLink) {
NavigationMenu menu = new NavigationMenu("topnav");
if(view.startsWith(ViewNames.PAGE) || view.startsWith(ViewNames.MOBILE_HOME)) {
NavigationItem profile = new NavigationItem("page.profile.title", getDisplayName(user), "/app/person/id/" + user.getId() + "?referringPageId=" + referringPageId);
menu.addNavigationItem(profile);
if(addStoreLink){
NavigationItem store = new NavigationItem("page.store.title", null, "/app/store?referringPageId=" + referringPageId);
menu.addNavigationItem(store);
}
NavigationItem admin = getAdminItem(referringPageId);
menu.addNavigationItem(admin);
NavigationItem logout = getLogoutItem();
menu.addNavigationItem(logout);
} else if (view.startsWith(ViewNames.STORE)) {
NavigationItem addWidget = new NavigationItem("page.addwidget.title", null, "/app/store/widget/add?referringPageId=" + referringPageId);
menu.addNavigationItem(addWidget);
NavigationItem back = getBackItem(referringPageId);
menu.addNavigationItem(back);
NavigationItem admin = getAdminItem(referringPageId);
menu.addNavigationItem(admin);
NavigationItem logout = getLogoutItem();
menu.addNavigationItem(logout);
} else if (view.startsWith(ViewNames.PERSON_PROFILE) || view.startsWith(ViewNames.USER_NOT_FOUND)) {
NavigationItem back = getBackItem(referringPageId);
menu.addNavigationItem(back);
NavigationItem admin = getAdminItem(referringPageId);
menu.addNavigationItem(admin);
NavigationItem logout = getLogoutItem();
menu.addNavigationItem(logout);
}
else if (view.startsWith(ViewNames.ADD_WIDGET_FORM) || view.startsWith(ViewNames.WIDGET)) {
if(view.equals(ViewNames.WIDGET_MARKETPLACE)){
NavigationItem addWidget = new NavigationItem("page.widget.backToMarketplace", null, "/app/marketplace?referringPageId=" + referringPageId);
menu.addNavigationItem(addWidget);
}
NavigationItem addWidget = new NavigationItem("page.widget.backToStore", null, "/app/store?referringPageId=" + referringPageId);
menu.addNavigationItem(addWidget);
NavigationItem back = getBackItem(referringPageId);
menu.addNavigationItem(back);
NavigationItem admin = getAdminItem(referringPageId);
menu.addNavigationItem(admin);
NavigationItem logout = getLogoutItem();
menu.addNavigationItem(logout);
}
return menu;
}