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

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

Introduction

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

Prototype

String CONTENT_ID

To view the source code for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow CONTENT_ID.

Click Source Link

Document

the default id of the content component

Usage

From source file:ro.fortsoft.wicket.pivot.web.PivotPanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();

    // create a pivot model
    pivotModel = createPivotModel(getModelObject());

    // create pivot field action factory
    pivotFieldActionsFactory = createPivotFieldActionsFactory();

    pivotModel.calculate();/*from   w  w  w.  jav a 2  s. co m*/

    areasContainer = new WebMarkupContainer("areas");
    areasContainer.setOutputMarkupId(true);
    add(areasContainer);

    RepeatingView areaRepeater = new RepeatingView("area");
    areasContainer.add(areaRepeater);
    List<PivotField.Area> areas = PivotField.Area.getValues();
    for (PivotField.Area area : areas) {
        areaRepeater.add(new PivotAreaPanel(areaRepeater.newChildId(), area));
    }

    pivotTable = createPivotTabel("pivotTable", pivotModel);
    add(pivotTable);

    modal = new ModalWindow("modal");
    modal.setAutoSize(true);
    add(modal);

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

        @Override
        public void onClick(AjaxRequestTarget target) {
            modal.setTitle("Configuration");
            modal.setContent(
                    new PivotConfigStoragePanel(ModalWindow.CONTENT_ID, pivotModel, pivotConfigStorage));
            modal.setAutoSize(true);
            modal.show(target);
            modal.setWindowClosedCallback(new WindowClosedCallback() {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClose(AjaxRequestTarget target) {
                    target.add(PivotPanel.this);
                    if (pivotModel.isAutoCalculate())
                        compute(target);
                    computeLink.setVisible(!pivotModel.isAutoCalculate());
                }
            });
        }

        @Override
        public boolean isVisible() {
            return super.isVisible() && pivotConfigStorage != null;
        }
    };
    add(configStoreButton);

    AjaxCheckBox showGrandTotalForColumnCheckBox = new AjaxCheckBox("showGrandTotalForColumn",
            new PropertyModel<Boolean>(this, "pivotModel.showGrandTotalForColumn")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            if (pivotModel.isAutoCalculate()) {
                compute(target);
            }
        }

    };
    add(showGrandTotalForColumnCheckBox);

    AjaxCheckBox showGrandTotalForRowCheckBox = new AjaxCheckBox("showGrandTotalForRow",
            new PropertyModel<Boolean>(this, "pivotModel.showGrandTotalForRow")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            if (pivotModel.isAutoCalculate()) {
                compute(target);
            }
        }

    };
    add(showGrandTotalForRowCheckBox);

    AjaxCheckBox autoCalculateCheckBox = new AjaxCheckBox("autoCalculate",
            new PropertyModel<Boolean>(this, "pivotModel.autoCalculate")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            computeLink.setVisible(!pivotModel.isAutoCalculate());
            target.add(computeLink);

            if (pivotModel.isAutoCalculate() && !pivotTable.isVisible()) {
                compute(target);
            }
        }

    };
    add(autoCalculateCheckBox);

    computeLink = new IndicatingAjaxLink<Void>("compute") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            compute(target);
        }

        /*
         * @Override public boolean isEnabled() { return verify(); }
         */

    };
    computeLink.setOutputMarkupPlaceholderTag(true);
    computeLink.add(AttributeModifier.append("class", new ButtonCssClassModel()));
    computeLink.setVisible(!pivotModel.isAutoCalculate());
    add(computeLink);

    downloadContainer = new WebMarkupContainer("downloadContainer");
    downloadContainer.setOutputMarkupPlaceholderTag(true);
    downloadContainer.setVisible(pivotTable.isVisible() && (pivotExporters.length > 0));
    add(downloadContainer);

    RepeatingView downloadExports = new RepeatingView("downloadExport");
    downloadContainer.add(downloadExports);
    for (final PivotExporter exporter : pivotExporters) {
        Link<Void> downloadLink = new Link<Void>(downloadExports.newChildId()) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {
                pivotModel.calculate();
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                try {
                    exporter.exportPivot(getPivotModel(), out);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                ResourceRequestHandler downloadHandler = new ResourceRequestHandler(
                        new ByteArrayResource(exporter.getFormatMimetype(), out.toByteArray(),
                                pivotExportFilename + "." + exporter.getFilenameExtension()),
                        null);
                RequestCycle.get().scheduleRequestHandlerAfterCurrent(downloadHandler);
            }
        };
        downloadExports.add(downloadLink);
        IModel<String> resourceModel = new StringResourceModel("downloadAs", downloadLink,
                Model.of(exporter.getFormatName()));
        downloadLink.add(new Label("label", resourceModel));
        downloadLink.setOutputMarkupPlaceholderTag(true);
        downloadLink.add(AttributeModifier.append("class", new ButtonCssClassModel()));
    }

    add(new PivotResourcesBehavior());
    if (pivotModel.isAutoCalculate()) {
        compute(null);
    }

    setOutputMarkupId(true);
}