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

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

Introduction

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

Prototype

public void show(final IPartialPageRequestHandler target) 

Source Link

Document

Shows the modal window.

Usage

From source file:org.geoserver.web.data.layergroup.RootLayerEntryPanel.java

License:Open Source License

@SuppressWarnings({ "rawtypes" })
public RootLayerEntryPanel(String id, final Form form, WorkspaceInfo workspace) {
    super(id);/* w ww. j av a  2  s. com*/

    setOutputMarkupId(true);

    final TextField<LayerInfo> rootLayerField = new TextField<LayerInfo>("rootLayer") {
        @Override
        public IConverter getConverter(Class<?> type) {
            return form.getConverter(type);
        }
    };
    rootLayerField.setOutputMarkupId(true);
    rootLayerField.setRequired(true);
    add(rootLayerField);

    // global styles
    List<StyleInfo> globalStyles = new ArrayList<StyleInfo>();
    List<StyleInfo> allStyles = GeoServerApplication.get().getCatalog().getStyles();
    for (StyleInfo s : allStyles) {
        if (s.getWorkspace() == null) {
            globalStyles.add(s);
        }
    }

    // available styles
    List<StyleInfo> styles = new ArrayList<StyleInfo>();
    styles.addAll(globalStyles);
    if (workspace != null) {
        styles.addAll(GeoServerApplication.get().getCatalog().getStylesByWorkspace(workspace));
    }

    DropDownChoice<StyleInfo> styleField = new DropDownChoice<StyleInfo>("rootLayerStyle", styles) {
        @Override
        public IConverter getConverter(Class<?> type) {
            return form.getConverter(type);
        }
    };
    styleField.setNullValid(true);
    add(styleField);

    final ModalWindow popupWindow = new ModalWindow("popup");
    add(popupWindow);
    add(new AjaxLink("add") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            popupWindow.setInitialHeight(375);
            popupWindow.setInitialWidth(525);
            popupWindow.setTitle(new ParamResourceModel("chooseLayer", this));
            popupWindow.setContent(new LayerListPanel(popupWindow.getContentId()) {
                @Override
                protected void handleLayer(LayerInfo layer, AjaxRequestTarget target) {
                    popupWindow.close(target);
                    ((LayerGroupInfo) form.getModelObject()).setRootLayer(layer);
                    target.addComponent(rootLayerField);
                }
            });

            popupWindow.show(target);
        }
    });
}

From source file:org.geoserver.web.demo.DemoRequestsPage.java

License:Open Source License

private void setUpDemoRequestsForm(final File demoDir) {
    final IModel requestModel = getDefaultModel();

    final Form demoRequestsForm;
    demoRequestsForm = new Form("demoRequestsForm");
    demoRequestsForm.setOutputMarkupId(true);
    demoRequestsForm.setModel(requestModel);
    add(demoRequestsForm);/*from   ww w .  j  av a  2s  .com*/

    final List<String> demoList = getDemoList(demoDir);
    final DropDownChoice demoRequestsList;
    final IModel reqFileNameModel = new PropertyModel(requestModel, "requestFileName");
    demoRequestsList = new DropDownChoice("demoRequestsList", reqFileNameModel, demoList,
            new IChoiceRenderer() {
                public String getIdValue(Object obj, int index) {
                    return String.valueOf(obj);
                }

                public Object getDisplayValue(Object obj) {
                    return obj;
                }
            });
    demoRequestsForm.add(demoRequestsList);

    /*
     * Wanted to use a simpler OnChangeAjaxBehavior but target.addComponent(body) does not make
     * the EditAreaBehavior to update the body contents inside it, but instead puts the plain
     * TextArea contents above the empty xml editor
     */
    demoRequestsList.add(new AjaxFormSubmitBehavior(demoRequestsForm, "onchange") {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            final String reqFileName = demoRequestsList.getModelValue();
            final String contents;
            String proxyBaseUrl;
            final String baseUrl;
            {
                WebRequest request = (WebRequest) DemoRequestsPage.this.getRequest();
                HttpServletRequest httpServletRequest;
                httpServletRequest = ((WebRequest) request).getHttpServletRequest();
                proxyBaseUrl = GeoServerExtensions.getProperty("PROXY_BASE_URL");
                if (StringUtils.isEmpty(proxyBaseUrl)) {
                    GeoServer gs = getGeoServer();
                    proxyBaseUrl = gs.getGlobal().getSettings().getProxyBaseUrl();
                    if (StringUtils.isEmpty(proxyBaseUrl)) {
                        baseUrl = ResponseUtils.baseURL(httpServletRequest);
                    } else {
                        baseUrl = proxyBaseUrl;
                    }
                } else {
                    baseUrl = proxyBaseUrl;
                }
            }
            try {
                contents = getFileContents(reqFileName);
            } catch (IOException e) {
                LOGGER.log(Level.WARNING, "Can't load demo file " + reqFileName, e);
                throw new WicketRuntimeException("Can't load demo file " + reqFileName, e);
            }

            boolean demoRequestIsHttpGet = reqFileName.endsWith(".url");
            final String service = reqFileName.substring(0, reqFileName.indexOf('_')).toLowerCase();
            if (demoRequestIsHttpGet) {
                String url = ResponseUtils.appendPath(baseUrl, contents);
                urlTextField.setModelObject(url);
                body.setModelObject("");
            } else {
                String serviceUrl = ResponseUtils.appendPath(baseUrl, service);
                urlTextField.setModelObject(serviceUrl);
                body.setModelObject(contents);
            }

            // target.addComponent(urlTextField);
            // target.addComponent(body);
            /*
             * Need to setResponsePage, addComponent causes the EditAreaBehavior to sometimes
             * not updating properly
             */
            setResponsePage(DemoRequestsPage.this);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            // nothing to do
        }
    });

    urlTextField = new TextField("url", new PropertyModel(requestModel, "requestUrl"));
    urlTextField.setMarkupId("requestUrl");
    urlTextField.setOutputMarkupId(true);
    demoRequestsForm.add(urlTextField);

    body = new CodeMirrorEditor("body", new PropertyModel(requestModel, "requestBody"));
    // force the id otherwise this blasted thing won't be usable from other forms
    // body.setMarkupId("requestBody");
    // body.setOutputMarkupId(true);
    body.setTextAreaMarkupId("requestBody");
    //body.add(new EditAreaBehavior());
    demoRequestsForm.add(body);

    username = new TextField("username", new PropertyModel(requestModel, "userName"));
    demoRequestsForm.add(username);

    password = new PasswordTextField("password", new PropertyModel(requestModel, "password"));
    password.setRequired(false);
    demoRequestsForm.add(password);

    final ModalWindow responseWindow;

    responseWindow = new ModalWindow("responseWindow");
    add(responseWindow);
    responseWindow.setPageMapName("demoResponse");
    responseWindow.setCookieName("demoResponse");

    responseWindow.setPageCreator(new ModalWindow.PageCreator() {

        public Page createPage() {
            return new DemoRequestResponse(requestModel);
        }
    });

    demoRequestsForm.add(new AjaxSubmitLink("submit", demoRequestsForm) {
        @Override
        public void onSubmit(AjaxRequestTarget target, Form testWfsPostForm) {
            responseWindow.show(target);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            // we need to force EditArea to update the textarea contents (which it hides)
            // before submitting the form, otherwise the contents won't be the ones the user
            // edited
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    return "document.getElementById('requestBody').value = document.gsEditors.requestBody.getValue();"
                            + script;
                }
            };
        }

    });
}

From source file:org.geoserver.wms.web.data.LayerAttributePanel.java

License:Open Source License

public LayerAttributePanel(String id, AbstractStylePage parent) throws IOException {
    super(id, parent);

    //Change layer link
    PropertyModel<String> layerNameModel = new PropertyModel<String>(parent.getLayerModel(), "prefixedName");
    add(new SimpleAjaxLink<String>("changeLayer", layerNameModel) {
        private static final long serialVersionUID = 7341058018479354596L;

        public void onClick(AjaxRequestTarget target) {
            ModalWindow popup = parent.getPopup();

            popup.setInitialHeight(400);
            popup.setInitialWidth(600);//from w  w w  . ja v  a 2s.  c  o  m
            popup.setTitle(new Model<String>("Choose layer to edit"));
            popup.setContent(new LayerChooser(popup.getContentId(), parent));
            popup.show(target);
        }
    });

    this.setDefaultModel(parent.getLayerModel());

    updateAttributePanel();
}

From source file:org.geoserver.wms.web.data.OpenLayersPreviewPanel.java

License:Open Source License

public OpenLayersPreviewPanel(String id, AbstractStylePage parent) {
    super(id, parent);
    this.olPreview = new WebMarkupContainer("olPreview").setOutputMarkupId(true);

    // Change layer link
    PropertyModel<String> layerNameModel = new PropertyModel<String>(parent.getLayerModel(), "prefixedName");
    add(new SimpleAjaxLink<String>("change.layer", layerNameModel) {
        private static final long serialVersionUID = 7341058018479354596L;

        public void onClick(AjaxRequestTarget target) {
            ModalWindow popup = parent.getPopup();

            popup.setInitialHeight(400);
            popup.setInitialWidth(600);/*from  w  w  w. ja v a2s  .c o m*/
            popup.setTitle(new Model<String>("Choose layer to edit"));
            popup.setContent(new LayerChooser(popup.getContentId(), parent));
            popup.show(target);
        }
    });
    add(olPreview);
    setOutputMarkupId(true);

    try {
        ensureLegendDecoration();
    } catch (IOException e) {
        LOGGER.log(Level.WARNING,
                "Failed to put legend layout file in the data directory, the legend decoration will not appear",
                e);
    }
}

From source file:org.geoserver.wps.web.WPSRequestBuilder.java

License:Open Source License

public WPSRequestBuilder(String procName) {
    // the form/*from  w ww.ja v  a 2  s.c om*/
    Form form = new Form("form");
    add(form);

    // the actual request builder component
    ExecuteRequest execRequest = new ExecuteRequest();
    if (procName != null)
        execRequest.processName = procName;

    builder = new WPSRequestBuilderPanel("requestBuilder", execRequest);
    form.add(builder);

    // the xml popup window
    final ModalWindow xmlWindow = new ModalWindow("xmlWindow");
    add(xmlWindow);
    xmlWindow.setPageCreator(new ModalWindow.PageCreator() {

        public Page createPage() {
            return new PlainCodePage(xmlWindow, responseWindow, getRequestXML());
        }
    });

    // the output response window
    responseWindow = new ModalWindow("responseWindow");
    add(responseWindow);
    responseWindow.setPageMapName("demoResponse");
    responseWindow.setCookieName("demoResponse");

    responseWindow.setPageCreator(new ModalWindow.PageCreator() {

        @SuppressWarnings("unchecked")
        public Page createPage() {
            DemoRequest request = new DemoRequest(null);
            HttpServletRequest http = ((WebRequest) WPSRequestBuilder.this.getRequest())
                    .getHttpServletRequest();
            String url = ResponseUtils.buildURL(ResponseUtils.baseURL(http), "ows",
                    Collections.singletonMap("strict", "true"), URLType.SERVICE);
            request.setRequestUrl(url);
            request.setRequestBody((String) responseWindow.getDefaultModelObject());
            request.setUserName(builder.username);
            request.setPassword(builder.password);
            return new DemoRequestResponse(new Model(request));
        }
    });

    form.add(new AjaxSubmitLink("execute") {

        @SuppressWarnings("unchecked")
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            responseWindow.setDefaultModel(new Model(getRequestXML()));
            responseWindow.show(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form form) {
            super.onError(target, form);
            target.addComponent(builder.getFeedbackPanel());
        }
    });

    form.add(new AjaxSubmitLink("executeXML") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            try {
                getRequestXML();
                xmlWindow.show(target);
            } catch (Exception e) {
                error(e.getMessage());
                target.addComponent(getFeedbackPanel());
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form form) {
            target.addComponent(getFeedbackPanel());
        }
    });
}

From source file:org.jaulp.wicket.data.provider.examples.refreshingview.ModalDialogWithStylePanel.java

License:Apache License

public ModalDialogWithStylePanel(String id) {
    super(id);/*w  ww  .  j  a  va2  s  .co m*/
    final ModalWindow modal = new ModalWindow("modal");
    modal.setCssClassName("w_vegas");
    modal.setTitle("Trivial Modal");

    AjaxLink<Void> modalLink = new AjaxLink<Void>("modalLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            target.appendJavaScript("var originalStyle = $('.wicket-modal').attr('style');"
                    + "$('.wicket-modal').attr('style', originalStyle + 'opacity: 0.5;');");
        }
    };
    Fragment modalFragment = new Fragment(modal.getContentId(), "modalContent", this);
    modalFragment.add(modalLink);
    modal.setContent(modalFragment);

    add(modal);
    add(new AjaxLink<Void>("openModal") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            modal.show(target);
        }
    });
}

From source file:org.jaulp.wicket.dialogs.examples.HomePage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 *
 * @param parameters/*w  w  w  .  j a  v  a2  s  . co m*/
 *            Page parameters
 */
public HomePage(final PageParameters parameters) {

    final WebMarkupContainer wmc = new WebMarkupContainer("comments");
    wmc.setOutputMarkupId(true);

    final List<MessageBean> noteList = new ArrayList<MessageBean>();
    final MessageBean messageBean = new MessageBean();
    messageBean.setMessageContent("hello");
    final ModalWindow modalWindow = new BaseModalWindow<MessageBean>("baseModalWindow", "Title", 350, 160,
            new CompoundPropertyModel<MessageBean>(messageBean)) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onCancel(final AjaxRequestTarget target) {
            target.add(wmc);
            close(target);
        }

        @Override
        public void onSelect(final AjaxRequestTarget target, final MessageBean object) {
            MessageBean clone = (MessageBean) WicketObjects.cloneObject(object);
            noteList.add(clone);
            // Clear the content from textarea in the dialog.
            object.setMessageContent("");
            target.add(wmc);
            close(target);
        }

    };
    modalWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modalWindow.setResizable(false);
    add(modalWindow);

    final AjaxLink<String> linkToModalWindow = new AjaxLink<String>("linkToModalWindow") {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            modalWindow.show(target);
        }
    };
    // Add the WebMarkupContainer...
    add(wmc);

    final Label linkToModalWindowLabel = new Label("linkToModalWindowLabel", "show modal dialog");
    linkToModalWindow.add(linkToModalWindowLabel);
    // The AjaxLink to open the modal window
    add(linkToModalWindow);
    // here we must set the message content from the bean in a repeater...
    final ListView<MessageBean> repliesAndNotesListView = new ListView<MessageBean>("repliesAndNotesListView",
            noteList) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<MessageBean> item) {
            final MessageBean repliesandnotes = item.getModelObject();
            item.add(new RepliesandnotesPanel("repliesandnotesPanel", repliesandnotes));

        }
    };
    repliesAndNotesListView.setVisible(true);
    wmc.add(repliesAndNotesListView);

    @SuppressWarnings("rawtypes")
    Link showUploadPage = new Link("showUploadPage") {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(new UploadPage(getPageParameters()));
        }

    };
    add(showUploadPage);

    add(new ModalDialogWithStylePanel("modalDialogWithStylePanel"));

}

From source file:org.jaulp.wicket.dialogs.examples.UploadPage.java

License:Apache License

public UploadPage(PageParameters parameters) {
    super(parameters);
    final ModalWindow uploadFileDialog = new ModalWindow("uploadFileDialog");

    add(uploadFileDialog);/*from   www . j  a va2 s  . com*/

    final UploadFilePanel uploadFilePanel = new UploadFilePanel("content");
    uploadFileDialog.setContent(uploadFilePanel);

    add(new AjaxLink<Void>("showUpdoadFileDialog") {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            uploadFileDialog.show(target);
        }
    });
}

From source file:org.jnotary.service.web.CRLPanel.java

License:Open Source License

private void initGui() throws Exception {
    addURLsModule();/*www  .  jav a  2  s  .c  o  m*/
    final ModalWindow modalWindow = createModalWindow("modalAdd", null);
    add(modalWindow);
    add(new AjaxLink<Void>("addUrlLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            modalWindow.show(target);
        }
    });
}

From source file:org.jnotary.service.web.CRLPanel.java

License:Open Source License

private ListView<CrlDistributionPoint> createListView(final WebMarkupContainer wmc) throws Exception {
    initListData();//ww  w  . j av a  2  s. c  o m

    return new ListView<CrlDistributionPoint>("repeating",
            new PropertyModel<List<CrlDistributionPoint>>(this, "crlUrls")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<CrlDistributionPoint> item) {
            final CrlDistributionPoint cp = item.getModel().getObject();

            if (cp.getIssuerHash() == null || certMap.get(cp.getIssuerHash()) == null)
                item.add(new Label("issuerDescription",
                        "<p style=\"color:red\">NOT FOUND!!!: " + cp.getIssuerDescription() + "</p>")
                                .setEscapeModelStrings(false));
            else
                item.add(new Label("issuerDescription",
                        new PropertyModel<CrlDistributionPoint>(cp, "issuerDescription"))
                                .setEscapeModelStrings(false));
            item.add(new Label("crlUrl", new PropertyModel<CrlDistributionPoint>(cp, "crlUrl")));

            final Long crlUrlId = cp.getId();
            final ModalWindow modalWindow = createModalWindow("modalEdit", crlUrlId);
            item.add(modalWindow);
            item.add(new AjaxLink<Void>("editUrlLink") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    modalWindow.show(target);
                }
            });
            item.add(createRemoveButton(wmc, cp.getId()));

            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (rowIndex++ % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
}