blob: 7a11487a5c8a24f50bad5fb623acfe1436828da4 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License") + you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openmeetings.web.common;
import org.apache.openmeetings.db.dao.basic.NavigationDao;
import org.apache.openmeetings.db.entity.basic.Naviglobal;
import org.apache.openmeetings.db.entity.basic.Navimain;
import org.apache.openmeetings.util.AuthLevelUtil;
import org.apache.openmeetings.web.app.Application;
import org.apache.openmeetings.web.app.WebSession;
import org.apache.openmeetings.web.pages.MainPage;
import org.apache.openmeetings.web.util.OmUrlFragment;
import org.apache.openmeetings.web.util.OmUrlFragment.MenuActions;
import org.apache.openmeetings.web.util.OmUrlFragment.MenuParams;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
/**
* Loads the menu items into the main area
*
* @author sebawagner
*
*/
public class MenuPanel extends BasePanel {
private static final long serialVersionUID = 1L;
public MenuPanel(String id) {
super(id);
setMarkupId(id);
final NavigationDao man = Application.getBean(NavigationDao.class);
add(new ListView<Naviglobal>("mainItem", man.getMainMenu(AuthLevelUtil.hasAdminLevel(WebSession.getRights()), WebSession.getUserId())) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<Naviglobal> item) {
Naviglobal gl = item.getModelObject();
item.add(new Label("label", getString("" + gl.getFieldvalues_id())).setRenderBodyOnly(true));
item.add(new ListView<Navimain>("childItem", gl.getMainnavi()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<Navimain> item) {
Navimain m = item.getModelObject();
final String name = getString("" + m.getFieldvalues_id());
final String desc = getString("" + m.getTooltip_fieldvalues_id());
final MenuActions action = MenuActions.valueOf(m.getAction());
final MenuParams params = m.getParams() != null ? MenuParams.valueOf(m.getParams()) : MenuParams.publicTabButton;
item.add(new Label("name", name), new Label("description", desc));
item.add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
((MainPage)getPage()).updateContents(new OmUrlFragment(action, params), target);
}
});
}
}.setReuseItems(true));
}
}.setReuseItems(true));
}
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
if (getMainPage().isRtl()) {
response.render(CssHeaderItem.forUrl("css/jquery.ui.menubar-rtl.css"));
}
}
}