Search in sources :

Example 6 with ConfirmableAjaxBorder

use of org.apache.openmeetings.web.common.ConfirmableAjaxBorder in project openmeetings by apache.

the class FileTreePanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    download.setDefaultModelObject(newDownloadMenuList());
    Droppable<BaseFileItem> trashToolbar = new Droppable<BaseFileItem>("trash-toolbar") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("hoverClass", Options.asString("ui-state-hover trash-toolbar-hover"));
            behavior.setOption("accept", Options.asString(".recorditem, .fileitem"));
        }

        @Override
        public JQueryBehavior newWidgetBehavior(String selector) {
            return new DroppableBehavior(selector, this) {

                private static final long serialVersionUID = 1L;

                @Override
                protected JQueryAjaxBehavior newOnDropAjaxBehavior(IJQueryAjaxAware source) {
                    return new OnDropAjaxBehavior(source) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public CharSequence getCallbackFunctionBody(CallbackParameter... parameters) {
                            String dialogId = UUID.randomUUID().toString();
                            String statement = "var $drop = $(this);";
                            statement += "$('body').append('<div id=" + dialogId + ">" + getString("713") + "</div>');";
                            statement += "$( '#" + dialogId + "' ).dialog({ title: '" + escapeEcmaScript(getString("80")) + "', classes: {'ui-dialog-titlebar': 'ui-corner-all no-close'}, buttons: [";
                            statement += "	{ text: '" + escapeEcmaScript(getString("54")) + "', click: function() { $drop.append(ui.draggable); $(this).dialog('close'); " + super.getCallbackFunctionBody(parameters) + " } },";
                            statement += "	{ text: '" + escapeEcmaScript(getString("lbl.cancel")) + "', click: function() { $(this).dialog('close'); } } ";
                            statement += "],";
                            statement += "close: function(event, ui) { $(this).dialog('destroy').remove(); }";
                            statement += "});";
                            return statement;
                        }
                    };
                }
            };
        }

        @Override
        public void onDrop(AjaxRequestTarget target, Component component) {
            Object o = component.getDefaultModelObject();
            if (o instanceof BaseFileItem) {
                BaseFileItem f = (BaseFileItem) o;
                if (isSelected(f)) {
                    deleteAll(target);
                } else {
                    delete(f, target);
                }
            }
        }
    };
    form.add(trashToolbar);
    trashToolbar.add(getUpload());
    trashToolbar.add(createDir);
    trashToolbar.add(new WebMarkupContainer("refresh").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            update(target);
        }
    }));
    trashToolbar.add(trashBorder = new ConfirmableAjaxBorder("trash", getString("80"), getString("713"), trashConfirm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isClickable() {
            return !readOnly && !selected.isEmpty();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            deleteAll(target);
        }
    });
    form.add(trees.add(tree).setOutputMarkupId(true));
    updateSizes();
    form.add(sizes.add(new Label("homeSize", homeSize), new Label("publicSize", publicSize)).setOutputMarkupId(true));
    form.add(errorsDialog);
    setReadOnly(false, null);
}
Also used : JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Droppable(com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) Label(org.apache.wicket.markup.html.basic.Label) CallbackParameter(org.apache.wicket.ajax.attributes.CallbackParameter) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IJQueryAjaxAware(com.googlecode.wicket.jquery.core.ajax.IJQueryAjaxAware) Component(org.apache.wicket.Component) DroppableBehavior(com.googlecode.wicket.jquery.ui.interaction.droppable.DroppableBehavior)

Example 7 with ConfirmableAjaxBorder

use of org.apache.openmeetings.web.common.ConfirmableAjaxBorder in project openmeetings by apache.

the class EmailForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    // add a cancel button that can be used to submit the form via ajax
    delBtn = new ConfirmableAjaxBorder("ajax-cancel-button", getString("80"), getString("833"), this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            emailDao.delete(getModelObject().getId());
            setModelObject(new MailMessage());
            target.add(list, EmailForm.this);
        }
    };
    add(delBtn.setOutputMarkupId(true).setEnabled(false));
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MailMessage(org.apache.openmeetings.db.entity.basic.MailMessage) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder)

Aggregations

ConfirmableAjaxBorder (org.apache.openmeetings.web.common.ConfirmableAjaxBorder)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 List (java.util.List)3 Label (org.apache.wicket.markup.html.basic.Label)3 Form (org.apache.wicket.markup.html.form.Form)3 AjaxButton (com.googlecode.wicket.jquery.ui.form.button.AjaxButton)2 Iterator (java.util.Iterator)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 User (org.apache.openmeetings.db.entity.user.User)2 Component (org.apache.wicket.Component)2 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 JQueryWidget (com.googlecode.wicket.jquery.core.IJQueryWidget.JQueryWidget)1 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 Options (com.googlecode.wicket.jquery.core.Options)1 IJQueryAjaxAware (com.googlecode.wicket.jquery.core.ajax.IJQueryAjaxAware)1 JQueryIcon (com.googlecode.wicket.jquery.ui.JQueryIcon)1 JQueryUIBehavior (com.googlecode.wicket.jquery.ui.JQueryUIBehavior)1 Droppable (com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable)1 DroppableBehavior (com.googlecode.wicket.jquery.ui.interaction.droppable.DroppableBehavior)1