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

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

Introduction

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

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:com.doculibre.constellio.wicket.panels.admin.indexing.AdminIndexingPanel.java

License:Open Source License

private void configurePopUp(ModalWindow modal, final String textPopUp, String titlePopUp) {
    modal.add(new OpenWindowOnLoadBehavior());
    modal.setContent(new SimpleContentPanel(modal.getContentId(), textPopUp));
    modal.setTitle(titlePopUp);/*from  www . ja  v a  2s  . com*/
    modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modal.setMaskType(ModalWindow.MaskType.TRANSPARENT);
    modal.setInitialWidth(200);
    modal.setWidthUnit("px");
    modal.setResizable(false);
    modal.setUseInitialHeight(false);
    modal.setCookieName("wicket-tips/styledModal");
    modal.setPageCreator(new ModalWindow.PageCreator() {
        @Override
        public Page createPage() {
            // TODO Auto-generated method stub
            return new PopUpPage(textPopUp);
        }
    });
}

From source file:com.evolveum.midpoint.gui.api.page.PageBase.java

License:Apache License

protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
    final ModalWindow modal = new ModalWindow(id);
    add(modal);/*w ww .jav  a  2  s . c o  m*/

    modal.setResizable(false);
    modal.setTitle(title);
    modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100)));

    modal.setInitialWidth(width);
    modal.setWidthUnit("px");
    modal.setInitialHeight(height);
    modal.setHeightUnit("px");

    modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {

        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget target) {
            return true;
        }
    });

    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        @Override
        public void onClose(AjaxRequestTarget target) {
            modal.close(target);
        }
    });

    modal.add(new AbstractDefaultAjaxBehavior() {

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;"));
            response.render(JavaScriptHeaderItem.forScript(
                    "$(document).ready(function() {\n" + "  $(document).bind('keyup', function(evt) {\n"
                            + "    if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n"
                            + "        evt.preventDefault();\n" + "    }\n" + "  });\n" + "});",
                    id));
        }

        @Override
        protected void respond(AjaxRequestTarget target) {
            modal.close(target);
        }
    });

    return modal;
}

From source file:com.evolveum.midpoint.web.component.util.SimplePanel.java

License:Apache License

protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
    final ModalWindow modal = new ModalWindow(id);
    add(modal);//ww  w .ja  va 2  s . c o  m

    modal.setResizable(false);
    modal.setTitle(title);
    modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100)));

    modal.setInitialWidth(width);
    modal.setWidthUnit("px");
    modal.setInitialHeight(height);
    modal.setHeightUnit("px");

    modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {

        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget target) {
            return true;
        }
    });

    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        @Override
        public void onClose(AjaxRequestTarget target) {
            modal.close(target);
        }
    });

    modal.add(new AbstractDefaultAjaxBehavior() {

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;"));
            response.render(JavaScriptHeaderItem.forScript(
                    "$(document).ready(function() {\n" + "  $(document).bind('keyup', function(evt) {\n"
                            + "    if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n"
                            + "        evt.preventDefault();\n" + "    }\n" + "  });\n" + "});",
                    id));
        }

        @Override
        protected void respond(AjaxRequestTarget target) {
            modal.close(target);

        }
    });

    return modal;
}

From source file:com.evolveum.midpoint.web.page.PageTemplate.java

License:Apache License

protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
    final ModalWindow modal = new ModalWindow(id);
    add(modal);//w w  w.j  ava  2 s .c o m

    modal.setResizable(false);
    modal.setTitle(title);
    modal.setCookieName(PageTemplate.class.getSimpleName() + ((int) (Math.random() * 100)));

    modal.setInitialWidth(width);
    modal.setWidthUnit("px");
    modal.setInitialHeight(height);
    modal.setHeightUnit("px");

    modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {

        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget target) {
            return true;
        }
    });

    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        @Override
        public void onClose(AjaxRequestTarget target) {
            modal.close(target);
        }
    });

    modal.add(new AbstractDefaultAjaxBehavior() {

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;"));
            response.render(JavaScriptHeaderItem.forScript(
                    "$(document).ready(function() {\n" + "  $(document).bind('keyup', function(evt) {\n"
                            + "    if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n"
                            + "        evt.preventDefault();\n" + "    }\n" + "  });\n" + "});",
                    id));
        }

        @Override
        protected void respond(AjaxRequestTarget target) {
            modal.close(target);
        }
    });

    return modal;
}

From source file:com.userweave.pages.test.DisplaySurveyUI.java

License:Open Source License

private void addModalWindow(SurveyExecution surveyExecution) {
    String ID = "modalWindow";
    if (surveyExecution == null || evaluateError(surveyExecution) != ErrorType.NONE
            || studyService.isAtLeastOneAdminRegistered(surveyExecution.getStudy().getParentProject())) {
        add(new WebMarkupContainer(ID));
    } else {//from  w  w w . j  a  v a  2 s.  c o m
        final ModalWindow modalWindow = new CustomModalWindow(ID);
        modalWindow.setInitialHeight(379);
        add(modalWindow);

        modalWindow.add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onTimer(AjaxRequestTarget target) {
                this.stop();
                modalWindow.show(target);
            }
        });

        modalWindow.setPageCreator(new ModalWindow.PageCreator() {
            private static final long serialVersionUID = 1L;

            @Override
            public Page createPage() {
                return new InformAboutIncompleteRegistrationPage(modalWindow);
            }
        });
    }

}

From source file:de.widone.web.page.base.BasePage.java

License:Apache License

public BasePage() {
    super();/*from w  ww  .j a  v  a  2s  . c o m*/
    final ModalWindow modalWindow = new ModalWindow("modalWindow");
    modalWindow.setContent(new UserDetailsPanel(modalWindow.getContentId(), new CurrentUserModel()));
    modalWindow.add(new Behavior() {
        @Override
        public void onEvent(Component component, IEvent<?> event) {
            if (event.getPayload() instanceof CancelEvent) {
                modalWindow.close(((CancelEvent) event.getPayload()).getTarget());
            }
        }
    });
    add(new Label("loginName", new StringResourceModel("loginName", this,
            new CompoundPropertyModel<User>(((WiDoneSession) WebSession.get()).getUser()))));
    add(modalWindow);
    add(new AjaxFallbackLink<Void>("userDetails") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            modalWindow.show(target);
        }
    });
    add(new AjaxFallbackLink<Void>("logout") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            WebSession.get().invalidate();
            setResponsePage(SignInPage.class);
        }
    });
}

From source file:mil.nga.giat.elasticsearch.ElasticConfigurationPanel.java

License:Open Source License

/**
 * Adds Elasticsearch configuration panel link, configure modal dialog and 
 * implements modal callback./*from  ww  w .  ja v  a 2s .  com*/
 * 
 * @see {@link ElasticConfigurationPage#done}
 */

public ElasticConfigurationPanel(final String panelId, final IModel model) {
    super(panelId, model);
    final FeatureTypeInfo fti = (FeatureTypeInfo) model.getObject();

    final ModalWindow modal = new ModalWindow("modal");
    modal.setInitialWidth(800);
    modal.setTitle(new ParamResourceModel("modalTitle", ElasticConfigurationPanel.this));
    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        @Override
        public void onClose(AjaxRequestTarget target) {
            if (_layerInfo != null) {
                GeoServerApplication app = (GeoServerApplication) getApplication();
                final FeatureTypeInfo ft = (FeatureTypeInfo) getResourceInfo();

                app.getCatalog().getResourcePool().clear(ft);
                app.getCatalog().getResourcePool().clear(ft.getStore());
                setResponsePage(new ElasticResourceConfigurationPage(ft));
            }
        }
    });

    if (fti.getMetadata().get(ElasticLayerConfiguration.KEY) == null) {
        modal.add(new OpenWindowOnLoadBehavior());
    }

    modal.setContent(new ElasticConfigurationPage(panelId, model) {
        @Override
        void done(AjaxRequestTarget target, LayerInfo layerInfo, ElasticLayerConfiguration layerConfig) {
            _layerInfo = layerInfo;
            _layerConfig = layerConfig;
            modal.close(target);
        }
    });
    add(modal);

    AjaxLink findLink = new AjaxLink("edit") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            modal.show(target);
        }
    };
    final Fragment attributePanel = new Fragment("esPanel", "esPanelFragment", this);
    attributePanel.setOutputMarkupId(true);
    add(attributePanel);
    attributePanel.add(findLink);
}

From source file:org.dcm4chee.web.war.folder.StudyListPage.java

License:LGPL

private Link<Object> getStudyPermissionLink(final ModalWindow modalWindow,
        final AbstractEditableDicomModel model, TooltipBehaviour tooltip) {

    int[] winSize = WebCfgDelegate.getInstance().getWindowSize("studyPerm");
    ModalWindowLink studyPermissionLink = new ModalWindowLink("studyPermissions", modalWindow, winSize[0],
            winSize[1]) {// w ww. j  av  a  2  s.c  o  m

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (checkExists(model, target)) {
                modalWindow.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public Page createPage() {
                        return new StudyPermissionsPage(model);
                    }
                });

                modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClose(AjaxRequestTarget target) {
                        updateStudyPermissions();
                        query(target);
                        modalWindow.getPage().setOutputMarkupId(true);
                        target.addComponent(modalWindow.getPage());
                        target.addComponent(header);
                    }
                });
                modalWindow.add(new ModalWindowLink.DisableDefaultConfirmBehavior());
                modalWindow.setTitle("");
                modalWindow.setCloseButtonCallback(null);
                modalWindow.show(target);
            }
        }

        @Override
        public boolean isVisible() {
            return studyPermissionHelper.isManageStudyPermissions() && model.getDataset() != null
                    && !(model instanceof PatientModel && !((PatientModel) model).isExpandable());
        }
    };
    Image image = new Image("studyPermissionsImg", ImageManager.IMAGE_FOLDER_STUDY_PERMISSIONS);
    image.add(new ImageSizeBehaviour("vertical-align: middle;"));
    if (tooltip != null)
        image.add(tooltip);
    studyPermissionLink.add(image);
    return studyPermissionLink;
}

From source file:org.geoserver.solr.SolrConfigurationPanel.java

License:Open Source License

/**
 * Adds SOLR configuration panel link, configure modal dialog and implements modal callback
 * /*w ww . j  a v a 2  s .  co  m*/
 * @see {@link SolrConfigurationPage#done}
 */

public SolrConfigurationPanel(final String panelId, final IModel model) {
    super(panelId, model);
    final FeatureTypeInfo fti = (FeatureTypeInfo) model.getObject();

    final ModalWindow modal = new ModalWindow("modal");
    modal.setInitialWidth(800);
    modal.setTitle(new ParamResourceModel("modalTitle", SolrConfigurationPanel.this));
    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        @Override
        public void onClose(AjaxRequestTarget target) {
            if (_layerInfo != null) {
                GeoServerApplication app = (GeoServerApplication) getApplication();
                FeatureTypeInfo ft = (FeatureTypeInfo) getResourceInfo();

                //Override _isNew state, based on resource informations into catalog
                if (ft.getId() != null
                        && app.getCatalog().getResource(ft.getId(), ResourceInfo.class) != null) {
                    _isNew = false;
                } else {
                    _isNew = true;
                }

                app.getCatalog().getResourcePool().clear(ft);
                app.getCatalog().getResourcePool().clear(ft.getStore());
                setResponsePage(new ResourceConfigurationPage(_layerInfo, _isNew));
            }
        }
    });

    if (fti.getId() == null) {
        modal.add(new OpenWindowOnLoadBehavior());
    }

    modal.setContent(new SolrConfigurationPage(panelId, model) {
        @Override
        void done(AjaxRequestTarget target, ResourceInfo resource) {
            ResourceConfigurationPage page = (ResourceConfigurationPage) SolrConfigurationPanel.this.getPage();
            page.updateResource(resource, target);
            modal.close(target);
        }
    });
    add(modal);

    AjaxLink findLink = new AjaxLink("edit") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            modal.show(target);
        }
    };
    final Fragment attributePanel = new Fragment("solrPanel", "solrPanelFragment", this);
    attributePanel.setOutputMarkupId(true);
    add(attributePanel);
    attributePanel.add(findLink);
}