use of cz.metacentrum.perun.webgui.tabs.TabItemWithUrl in project perun by CESNET.
the class MainMenuItem method build.
/**
* Re-build main menu item
* (check if item is selected)
*/
public void build() {
Widget widget = new Widget();
boolean enabled = (tabItem != null);
// if menu item enabled - show hyperlink
if (enabled) {
widget = new Hyperlink(title, session.getTabManager().getLinkForTab(tabItem));
widget.removeStyleName("mainMenuNotActive");
// else show plain text
} else {
widget = new HTML(title);
widget.addStyleName("mainMenuNotActive");
}
if (tabItem != null && session.getTabManager().getActiveTab() != null) {
this.active = (tabItem.getUrlWithParameters().equals(((TabItemWithUrl) session.getTabManager().getActiveTab()).getUrlWithParameters()));
// IF ACTIVE TAB IS GROUP ADMIN - GROUPS
if (((TabItemWithUrl) session.getTabManager().getActiveTab()).getUrlWithParameters().startsWith(GroupsTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + tabItem.getUrl() + "?vo=")) {
this.active = ((TabItemWithUrl) tabItem).getUrlWithParameters().startsWith(GroupsTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + tabItem.getUrl() + "?vo=");
}
// hack for services tabs
if (((TabItemWithUrl) session.getTabManager().getActiveTab()).getUrlWithParameters().startsWith(String.valueOf(ServicesTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + "list")) || ((TabItemWithUrl) session.getTabManager().getActiveTab()).getUrlWithParameters().startsWith(String.valueOf(ServicesTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + "detail")) || ((TabItemWithUrl) session.getTabManager().getActiveTab()).getUrlWithParameters().startsWith(String.valueOf(ServicesTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + "exec-view"))) {
this.active = ((TabItemWithUrl) tabItem).getUrlWithParameters().startsWith(String.valueOf(ServicesTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + "list")) || ((TabItemWithUrl) tabItem).getUrlWithParameters().startsWith(String.valueOf(ServicesTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + "detail")) || ((TabItemWithUrl) tabItem).getUrlWithParameters().startsWith(String.valueOf(ServicesTabs.URL + UrlMapper.TAB_NAME_SEPARATOR + "exec-view"));
}
} else {
this.active = false;
}
if (active) {
widget.addStyleName("mainMenuActive");
} else {
widget.removeStyleName("mainMenuActive");
}
this.widget = widget;
}
Aggregations