Example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close

List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close.

Prototype

public void close(final IPartialPageRequestHandler target) 

Source Link

Document

Closes the modal window.

Usage

From source file:com.locke.library.web.panels.attachment.AttachmentModalWindowPage.java

License:Apache License

public AttachmentModalWindowPage(final ModalWindow window, final HeaderContributor css, final Bytes maximumSize,
        final IModel<List<IAttachment>> model) {

    add(css);/*from   w  w  w  .  jav a2  s  .com*/
    add(new AjaxLink("ok") {
        private static final long serialVersionUID = -1202322017634128297L;

        public void onClick(AjaxRequestTarget target) {
            onOk();
            window.close(target);
        }
    });

    add(new AjaxLink("cancel") {
        private static final long serialVersionUID = -6141617859994868658L;

        public void onClick(AjaxRequestTarget target) {
            window.close(target);
        }
    });

    add(new AttachmentPanel("attachments", css, maximumSize, model, Feature.REMOVE_LINK, Feature.UPLOAD_FORM) {
        private static final long serialVersionUID = -9208749445562106471L;

        @Override
        protected void onRemove(final IAttachment attachment) {
            model.getObject().remove(attachment);
            info(getString("removedAttachment", new Model<IAttachment>(attachment)));
        }

        @Override
        protected void onUpload(final IAttachment attachment) {
            model.getObject().add(attachment);
            info(getString("uploadedAttachment", new Model<IAttachment>(attachment)));
        }
    });
}

From source file:com.modusoperandi.dragonfly.widgets.chart.SettingsPanel.java

License:Open Source License

/**
 * Instantiates a new settings page.//from w w  w  .java2 s .c o m
 *
 * @param id
 * @param modalWindow
 */
public SettingsPanel(final String id, final ModalWindow modalWindow) {

    super(id);

    configuration = new HashMap<>();

    final Form<?> dataForm = new Form<>("dataForm");
    add(dataForm);

    contentDiv = new WebMarkupContainer("contentDiv");
    contentDiv.setOutputMarkupId(true);
    dataForm.add(contentDiv);

    // ////////////////////////////
    // Type
    final RadioChoice<String> typeField = new RadioChoice<String>("type", new PropertyModel<>(this, "type"),
            Arrays.asList(
                    new String[] { XY, FACET_BAR, SERIES_LINE, FACET_PIE, TIMEWHEEL, HEAT_MAP_RING_MAP })) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getSuffix() {

            return "";
        }
    };

    typeField.add(new AjaxFormChoiceComponentUpdatingBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {

            type = getComponent().getDefaultModelObjectAsString();

            showDivs();

            target.add(contentDiv);
        }

    });
    contentDiv.add(typeField);

    // ////////////////////////////
    // Index Name
    populateIndices();

    indexDiv = new WebMarkupContainer("indexDiv");
    indexDiv.setOutputMarkupId(true);
    contentDiv.add(indexDiv);

    selectIndex = new DropDownChoice<>("dataSet", new PropertyModel<String>(this, "indexName"), indexList);
    selectIndex.add(new AjaxFormComponentUpdatingBehavior("focus") {

        private static final long serialVersionUID = 2981822623630720652L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {

            if (populateIndices()) {
                target.add(selectIndex);
            }
        }
    });
    selectIndex.add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 2981822623630720652L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {

            populateFieldsList(numericFieldsList, "double");
            populateFieldsList(allFieldsList, null);
            populateFieldsList(timeFieldsList, "date");
            populateFieldsList(locationFieldsList, "geo_point");

            if (numericFieldsList.size() > 0) {

                seriesYField = numericFieldsList.get(0);

                xField = numericFieldsList.get(0);
                yField = numericFieldsList.get(0);
            }

            if (allFieldsList.size() > 0) {

                countField = allFieldsList.get(0);

                pieCountField = allFieldsList.get(0);

                seriesXField = allFieldsList.get(0);

                hmrmLabelField = allFieldsList.get(0);
            }

            if (timeFieldsList.size() > 0) {

                twTimeField = timeFieldsList.get(0);

                hmrmTimeField = timeFieldsList.get(0);
            }

            if (locationFieldsList.size() > 0) {

                hmrmLocationField = locationFieldsList.get(0);
            }

            target.add(xSelectField);
            target.add(ySelectField);
            target.add(countSelectField);
            target.add(seriesXSelectField);
            target.add(seriesYSelectField);
            target.add(pieCountSelectField);
            target.add(twTimeSelectField);
            target.add(hmrmTimeSelectField);
            target.add(hmrmLocationSelectField);
            target.add(hmrmLabelSelectField);
        }
    });
    indexDiv.add(selectIndex);

    // ////////////////////////////
    // Type Panels
    configureXyDiv();
    configureFacetBarDiv();
    configureSeriesDiv();
    configureFacetPieDiv();
    configureTimewheelDiv();
    configureHeatMapRingMapDiv();

    showDivs();

    // ////////////////////////////
    // Buttons
    dataForm.add(new AjaxButton("okButton") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {

            configuration.clear();

            configuration.put("Index", indexName);
            configuration.put("Type", type);

            switch (type) {
            case XY:
                configuration.put("X", xField);
                configuration.put("Y", yField);
                break;

            case FACET_BAR:
                configuration.put("CountField", countField);
                configuration.put("MaxItems", maxItems);
                break;

            case SERIES_LINE:
                configuration.put("X", seriesXField);
                configuration.put("Y", seriesYField);
                break;

            case FACET_PIE:
                configuration.put("CountField", pieCountField);
                configuration.put("MaxItems", pieMaxItems);
                break;

            case TIMEWHEEL:
                configuration.put("TimeScale", twTimeScaleField);
                configuration.put("TimeField", twTimeField);
                configuration.put("ContrastScale", twContrastScaleField);
                break;

            case HEAT_MAP_RING_MAP:
                configuration.put("TimeScale", hmrmTimeScaleField);
                configuration.put("TimeField", hmrmTimeField);
                configuration.put("LocationField", hmrmLocationField);
                configuration.put("LabelField", hmrmLabelField);
                break;
            }

            ok = true;
            modalWindow.close(target);
        }
    });

    dataForm.add(new AjaxButton("cancelButton") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {

            configuration.clear();

            ok = false;
            modalWindow.close(target);
        }
    });
}

From source file:com.modusoperandi.dragonfly.widgets.map.MapSettingsPanel.java

License:Open Source License

/**
 * Instantiates a new map settings page.
 * /*from   w  w  w. j  a  va  2  s  . c  o  m*/
 * @param id
 * @param modalWindow
 */
public MapSettingsPanel(final String id, final ModalWindow modalWindow) {

    super(id);

    populateWmsPresetList();

    configuration = new HashMap<>();

    final Form<?> dataForm = new Form<>("dataForm");
    add(dataForm);

    contentDiv = new WebMarkupContainer("contentDiv");
    contentDiv.setOutputMarkupId(true);
    dataForm.add(contentDiv);

    // ////////////////////////////
    // Type

    final RadioChoice<String> typeField = new RadioChoice<String>("type", new PropertyModel<>(this, "type"),
            Arrays.asList(new String[] { HEAT_MAP, GEO_JSON, WMS })) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getSuffix() {

            return "";
        }
    };

    typeField.add(new AjaxFormChoiceComponentUpdatingBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {

            type = getComponent().getDefaultModelObjectAsString();

            showDivs();

            target.add(contentDiv);
            target.add(heatmapDiv);
            target.add(geojsonDiv);
            target.add(wmsDiv);
        }

    });
    contentDiv.add(typeField);

    // ////////////////////////////
    // Index Name

    populateIndices();

    indexDiv = new WebMarkupContainer("indexDiv");
    indexDiv.setOutputMarkupId(true);
    contentDiv.add(indexDiv);

    selectIndex = new DropDownChoice<>("dataSet", new PropertyModel<String>(this, "indexName"), indexList);
    selectIndex.setOutputMarkupId(true);
    selectIndex.add(new AjaxFormComponentUpdatingBehavior("focus") {

        private static final long serialVersionUID = 2981822623630720652L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {

            if (populateIndices()) {
                target.add(selectIndex);
            }
        }
    });
    selectIndex.add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 2981822623630720652L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {

            populateFieldsList(locationFieldList, "geo_point");
            if (locationFieldList.size() > 0) {
                hmLocation = locationFieldList.get(0);
            }

            populateFieldsList(stringFieldList, "string");
            if (stringFieldList.size() > 0) {
                geojson = stringFieldList.get(0);
            }

            target.add(geojsonField);
            target.add(hmLocationField);
        }
    });
    indexDiv.add(selectIndex);

    // ////////////////////////////
    // Type Panels

    configureHeatmapDiv();
    configureGeojsonDiv();
    configureWmsDiv();

    showDivs();

    // ////////////////////////////
    // Buttons

    dataForm.add(new AjaxButton("okButton") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {

            configuration.clear();

            switch (type) {
            case HEAT_MAP:
                configuration.put("Type", HEAT_MAP);
                configuration.put("Index", indexName);
                configuration.put("Location", hmLocation);
                configuration.put("HmTransparency", hmTransparency);
                configuration.put("HmRadius", hmRadius);
                break;

            case GEO_JSON:
                configuration.put("Type", GEO_JSON);
                configuration.put("Index", indexName);
                configuration.put("GeojsonField", geojson);
                break;

            case WMS:
                configuration.put("Type", WMS);
                configuration.put("TileURL", tileUrl);
                configuration.put("Name", wmsName);
                configuration.put("Format", wmsFormat);
                configuration.put("Attribution", wmsAttribution);
                configuration.put("Layers", wmsLayers);
                break;
            }

            ok = true;
            modalWindow.close(target);
        }
    });

    dataForm.add(new AjaxButton("cancelButton") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {

            configuration.clear();

            ok = false;
            modalWindow.close(target);
        }
    });
}

From source file:com.userweave.components.customModalWindow.BaseModalWindowPage.java

License:Open Source License

protected WebMarkupContainer getAcceptButton(String componentId, final ModalWindow window) {
    return new AjaxLink<Void>(componentId) {
        private static final long serialVersionUID = 1L;

        @Override//from w  w w .ja v  a  2 s .c o  m
        public void onClick(AjaxRequestTarget target) {
            if (window != null) {
                window.close(target);
            } else {
                onAccept(target);
            }
        }
    };
}

From source file:com.userweave.components.customModalWindow.BaseModalWindowPage.java

License:Open Source License

protected WebMarkupContainer getDeclineButton(String componentId, final ModalWindow window) {
    return new AjaxLink<Void>(componentId) {
        private static final long serialVersionUID = 1L;

        @Override/*from w w w.  j a  v a  2s  . c o  m*/
        public void onClick(AjaxRequestTarget target) {
            if (window != null) {
                window.close(target);
            } else {
                onDecline(target);
            }
        }
    };
}

From source file:com.userweave.module.methoden.questionnaire.page.report.question.dimensions.DimensionsReportPanel.java

License:Open Source License

@Override
protected Page getDetailsPage(final ModalWindow window, final Question q, final Integer object,
        final ListItem item) {
    return new AntipodeRatingPage(getValueModel(ratingStatistics.getRatingMean(object) + 1),
            getValueModel(ratingStatistics.getRatingStandardDeviation(object)),
            ratingStatistics.getTotalCount(object)) {
        private static final long serialVersionUID = 1L;

        @Override//from w w  w . j  a  v a  2s  . c  o m
        protected void onAccept(AjaxRequestTarget target) {
            window.close(target);
        }

        @Override
        protected void onDecline(AjaxRequestTarget target) {
            window.close(target);
        }

        @Override
        protected Component getRatingReport(String componentId) {
            DimensionsQuestion question = (DimensionsQuestion) q;

            final int numberOfRatingSteps = question.getNumberOfRatingSteps() != null
                    ? question.getNumberOfRatingSteps()
                    : 0;

            final AntipodePair antipodePair = (AntipodePair) item.getModelObject();

            Boolean noAnswerOption = question.getShowNoAnswerOption();

            if (noAnswerOption == null) {
                noAnswerOption = new Boolean(false);
            }

            return createRatingReport(componentId, antipodePair, createRatingListModel(ratingStatistics,
                    numberOfAnswers.intValue(), numberOfRatingSteps, object, noAnswerOption.booleanValue()));
        }
    };
}

From source file:com.userweave.module.methoden.questionnaire.page.report.question.multiplerating.MultipleRatingReportPanel.java

License:Open Source License

@Override
protected Page getDetailsPage(final ModalWindow window, final Question q, final Integer object, ListItem item) {
    return new AntipodeRatingPage(getValueModel(ratingStatistics.getRatingMean(object) + 1),
            getValueModel(ratingStatistics.getRatingStandardDeviation(object)),
            ratingStatistics.getTotalCount(object)) {
        private static final long serialVersionUID = 1L;

        @Override//www  . j  a  va 2  s  . co m
        protected void onAccept(AjaxRequestTarget target) {
            window.close(target);
        }

        @Override
        protected void onDecline(AjaxRequestTarget target) {
            window.close(target);
        }

        @Override
        protected Component getRatingReport(String componentId) {
            MultipleRatingQuestion question = (MultipleRatingQuestion) q;

            final int numberOfRatingSteps = question.getNumberOfRatingSteps() != null
                    ? question.getNumberOfRatingSteps()
                    : 0;

            final AntipodePair antipodePair = question.getAntipodePair();

            Boolean noAnswerOption = question.getShowNoAnswerOption();

            if (noAnswerOption == null) {
                noAnswerOption = new Boolean(false);
            }

            return createRatingReport(componentId, antipodePair, createRatingListModel(ratingStatistics,
                    numberOfAnswers.intValue(), numberOfRatingSteps, object, noAnswerOption.booleanValue()));
        }
    };
}

From source file:com.userweave.pages.administration.ChangePasswordPage.java

License:Open Source License

@Override
protected WebMarkupContainer getAcceptButton(String componentId, final ModalWindow window) {
    return new AjaxButton(componentId, getForm()) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w  ww.j ava  2s  . c om*/
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            if (changePassword(oldPasswordString, newPasswordString)) {
                window.close(target);
            } else {
                target.add(feedback);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
        }
    };
}

From source file:com.userweave.pages.base.ContactAndFeedbackPage.java

License:Open Source License

@Override
protected WebMarkupContainer getAcceptButton(String componentId, final ModalWindow window) {
    final AjaxSubmitLink link = new AjaxSubmitLink(componentId, getForm()) {
        private static final long serialVersionUID = 1L;

        @Override/*from   w w  w  .  ja v  a 2 s  .co  m*/
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            User user = UserWeaveSession.get().getUser();

            String subject = new StringResourceModel(feedbacktype.toString(), ContactAndFeedbackPage.this, null)
                    .getString();

            try {
                DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy");

                DateTimeFormatter localeFmt = fmt.withLocale(user.getLocale());

                DateTimeFormatter timeFmt = DateTimeFormat.forPattern("HH:mm");

                DateTime dateTime = new DateTime();

                String mailMessage = new StringResourceModel("mailMessage", ContactAndFeedbackPage.this, null,
                        new Object[] { user.getForename(), user.getSurname(), dateTime.toString(localeFmt),
                                dateTime.toString(timeFmt), subject, feedbackMessage }).getString();

                String subjectForMail = new StringResourceModel("mailSubject", ContactAndFeedbackPage.this,
                        null).getString();

                mailservice.sendMail(user.getEmail(), subjectForMail, mailMessage, "info@userweave.net", true);

                window.close(target);
            } catch (MessagingException e) {
                error(new StringResourceModel("mailMessageError", ContactAndFeedbackPage.this, null)
                        .getString());

                target.add(feedback);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
        }
    };

    return link;
}

From source file:com.userweave.pages.components.userfeedback.UserFeedbackPage.java

License:Open Source License

public UserFeedbackPage(final ModalWindow window) {

    final User user = getUser();

    final Model commentModel = new Model<String>() {
        String object;/*from  ww w  .  j a va2  s. co  m*/

        @Override
        public String getObject() {
            return object;
        }

        @Override
        public void setObject(String object) {
            this.object = object;
        }
    };

    final RadioGroup feedbackSelectionType = new RadioGroup("feedbackSelectionType", new Model());

    feedbackSelectionType.add(new Radio("question", new StringResourceModel("question", this, null)));
    feedbackSelectionType.add(new Radio("praise", new StringResourceModel("praise", this, null)));
    feedbackSelectionType.add(new Radio("critique", new StringResourceModel("critique", this, null)));
    feedbackSelectionType.add(new Radio("comment", new StringResourceModel("comment", this, null)));

    Form form = new Form("form") {
        @Override
        protected void onSubmit() {
            String message = new StringResourceModel("salutation", this, null).getObject().toString() + " "
                    + user.getForename() + " " + user.getSurname() + ",\n\n";
            message += new StringResourceModel("kind_of_feedback", this, null).getObject().toString() + " "
                    + feedbackSelectionType.getModel().getObject().toString() + ".\n\n";
            message += new StringResourceModel("feedback", this, null).getObject().toString() + " "
                    + commentModel.getObject() + "\n\n";
            message += new StringResourceModel("communicate", this, null).getObject().toString() + "\n\n";
            message += new StringResourceModel("discharge", this, null).getObject().toString();
            try {
                mailService.sendMail(user.getEmail(),
                        new StringResourceModel("feedback_mail_subject", this, null).getObject().toString(),
                        message, "feedback@userweave.net", true);
            } catch (MessagingException e) {
                e.printStackTrace();
            }
        }
    };

    add(form);

    form.add(feedbackSelectionType);

    form.add(new TextArea("textarea", commentModel));

    form.add(new DefaultButton("button",
            new StringResourceModel("submit_feedback_panel", UserFeedbackPage.this, null), form) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            window.close(target);
        }

    });
}