Search in sources :

Example 1 with BasePage

use of org.apache.openmeetings.web.pages.BasePage in project openmeetings by apache.

the class ChatToolbar method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    BasePage page = (BasePage) getPage();
    add(toolbar.add(new WebMarkupContainer("hyperlink").add(AttributeModifier.append("class", page.isRtl() ? "dropdown-menu-left" : "dropdown-menu-right"))));
    add(download);
    delBtn = new ConfirmableAjaxBorder("delete", getString("80"), getString("832"), chatForm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            final String scope = chatForm.getScope();
            final boolean admin = hasAdminLevel(getRights());
            chatForm.process(() -> {
                if (admin) {
                    chatDao.deleteGlobal();
                    clean(target, ID_ALL);
                }
                return true;
            }, r -> {
                if (admin || isModerator(cm, getUserId(), r.getId())) {
                    chatDao.deleteRoom(r.getId());
                    clean(target, scope);
                }
                return true;
            }, u -> {
                chatDao.deleteUser(u.getId());
                clean(target, scope);
                return true;
            });
        }
    };
    toolbar.add(delBtn.setVisible(hasAdminLevel(getRights())).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    toolbar.add(save.setVisible(hasAdminLevel(getRights())).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true).add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            download.initiate(target);
        }
    }));
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) WebSession.getUserId(org.apache.openmeetings.web.app.WebSession.getUserId) BasePage(org.apache.openmeetings.web.pages.BasePage) NONE(org.apache.wicket.util.time.Duration.NONE) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) JQueryWidget(com.googlecode.wicket.jquery.core.IJQueryWidget.JQueryWidget) EVT_CLICK(org.apache.openmeetings.web.common.BasePanel.EVT_CLICK) IWysiwygToolbar(com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.IWysiwygToolbar) User(org.apache.openmeetings.db.entity.user.User) RoomPanel.isModerator(org.apache.openmeetings.web.room.RoomPanel.isModerator) ChatDao(org.apache.openmeetings.db.dao.basic.ChatDao) StringResourceStream(org.apache.wicket.util.resource.StringResourceStream) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) IModel(org.apache.wicket.model.IModel) ChatMessage(org.apache.openmeetings.db.entity.basic.ChatMessage) WebSession.getDateFormat(org.apache.openmeetings.web.app.WebSession.getDateFormat) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ID_ALL(org.apache.openmeetings.core.util.WebSocketHelper.ID_ALL) AuthLevelUtil.hasAdminLevel(org.apache.openmeetings.db.util.AuthLevelUtil.hasAdminLevel) HttpServletResponse(javax.servlet.http.HttpServletResponse) Component(org.apache.wicket.Component) AttributeModifier(org.apache.wicket.AttributeModifier) Panel(org.apache.wicket.markup.html.panel.Panel) List(java.util.List) AjaxDownloadBehavior(org.apache.wicket.extensions.ajax.AjaxDownloadBehavior) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ClientManager(org.apache.openmeetings.web.app.ClientManager) IResourceStream(org.apache.wicket.util.resource.IResourceStream) WebSession.getRights(org.apache.openmeetings.web.app.WebSession.getRights) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) BasePage(org.apache.openmeetings.web.pages.BasePage) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

JQueryWidget (com.googlecode.wicket.jquery.core.IJQueryWidget.JQueryWidget)1 IWysiwygToolbar (com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.IWysiwygToolbar)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 List (java.util.List)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ID_ALL (org.apache.openmeetings.core.util.WebSocketHelper.ID_ALL)1 ChatDao (org.apache.openmeetings.db.dao.basic.ChatDao)1 ChatMessage (org.apache.openmeetings.db.entity.basic.ChatMessage)1 User (org.apache.openmeetings.db.entity.user.User)1 AuthLevelUtil.hasAdminLevel (org.apache.openmeetings.db.util.AuthLevelUtil.hasAdminLevel)1 ClientManager (org.apache.openmeetings.web.app.ClientManager)1 WebSession.getDateFormat (org.apache.openmeetings.web.app.WebSession.getDateFormat)1 WebSession.getRights (org.apache.openmeetings.web.app.WebSession.getRights)1 WebSession.getUserId (org.apache.openmeetings.web.app.WebSession.getUserId)1 EVT_CLICK (org.apache.openmeetings.web.common.BasePanel.EVT_CLICK)1 ConfirmableAjaxBorder (org.apache.openmeetings.web.common.ConfirmableAjaxBorder)1 BasePage (org.apache.openmeetings.web.pages.BasePage)1 RoomPanel.isModerator (org.apache.openmeetings.web.room.RoomPanel.isModerator)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 Component (org.apache.wicket.Component)1