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

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

Introduction

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

Prototype

public String getContentId() 

Source Link

Document

Returns the id of content component.

Usage

From source file:org.geoserver.qos.web.TypesListBuilder.java

License:Open Source License

@Override
public WebMarkupContainer build(WebMarkupContainer mainDiv, ModalWindow modalWindow,
        IModel<WfsAdHocQueryConstraints> model) {
    WebMarkupContainer layersDiv = new WebMarkupContainer("layersDiv");
    layersDiv.setOutputMarkupId(true);/*w w w . j ava  2  s. co m*/
    mainDiv.add(layersDiv);

    final ListView<String> layersListView = new ListView<String>("layersList",
            new PropertyModel<>(model, "typeNames")) {
        @Override
        protected void populateItem(ListItem<String> item) {
            TextField<String> layerField = new TextField<>("layerName", item.getModel());
            layerField.setEnabled(false);
            item.add(layerField);
            AjaxSubmitLink deleteLayerLink = new AjaxSubmitLink("deleteLayer") {
                @Override
                protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
                    super.onAfterSubmit(target, form);
                    model.getObject().getTypeNames().remove(item.getModel().getObject());
                    target.add(mainDiv);
                }
            };
            item.add(deleteLayerLink);
        }
    };
    layersDiv.add(layersListView);

    // Autocomplete add to list:
    //        final AutoCompleteTextField<String> addTypeNameField =
    //                new AutoCompleteTextField<String>("addTypeNameField", new
    // PropertyModel<>(typeToAdd, "value")) {
    //                    @Override
    //                    protected Iterator<String> getChoices(String arg0) {
    //                        return null;
    //                    }
    //                };

    final AjaxLink addLayerLink = new AjaxLink("addLayer") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            WorkspaceInfo wsi = mainDiv.findParent(QosWfsAdminPanel.class).getMainModel().getObject()
                    .getWorkspace();
            modalWindow.setInitialHeight(375);
            modalWindow.setInitialWidth(525);
            modalWindow.setTitle("Choose layer");
            modalWindow.setContent(new LayerListPanel(modalWindow.getContentId(), wsi) {
                @Override
                protected void handleLayer(org.geoserver.catalog.LayerInfo layer, AjaxRequestTarget target) {
                    if (model.getObject().getTypeNames() == null) {
                        model.getObject().setTypeNames(new ArrayList<>());
                    }
                    if (!model.getObject().getTypeNames().contains(layer.prefixedName())) {
                        model.getObject().getTypeNames().add(layer.prefixedName());
                    }
                    modalWindow.close(target);
                    target.add(mainDiv);
                };
            });
            modalWindow.show(target);
        }
    };
    layersDiv.add(addLayerLink);
    return layersDiv;
}

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);/*from   w  w w. j av a  2  s .  c o  m*/

    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.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  .jav a  2s  . co 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  ww  w .  j a  v a  2s .c  om*/
            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.jaulp.wicket.data.provider.examples.refreshingview.ModalDialogWithStylePanel.java

License:Apache License

public ModalDialogWithStylePanel(String id) {
    super(id);//  w ww.  j a  v a 2  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.obiba.onyx.quartz.core.wicket.layout.impl.simplified.QuestionCategoryOpenAnswerDefinitionPanel.java

License:Open Source License

private ModalWindow createPadModalWindow(String padId) {
    ModalWindow newPadWindow = new ModalWindow(padId);

    DataType type = getOpenAnswerDefinition().getDataType();
    if (type.equals(DataType.INTEGER) || type.equals(DataType.DECIMAL)) {
        pad = new NumericPad(newPadWindow.getContentId(), getQuestionModel(), getQuestionCategoryModel(),
                getOpenAnswerDefinitionModel()) {
            /**/* www.java 2 s .  c o  m*/
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public boolean isRequired() {
                // is never required because in a array the pad allows deselecting the category when setting a null value
                return false;
            }
        };

        newPadWindow.setTitle(new StringResourceModel("NumericPadTitle", pad, null));
        newPadWindow.setContent(pad);
        newPadWindow.setCssClassName("onyx");
        newPadWindow.setInitialWidth(288);
        newPadWindow.setInitialHeight(365);
        newPadWindow.setResizable(false);

        // same as cancel
        newPadWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
            private static final long serialVersionUID = 1L;

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

        return newPadWindow;
    }
    throw new UnsupportedOperationException("Pad for type " + type + " not supported yet.");
}

From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.simplified.SimplifiedOpenAnswerDefinitionPanel.java

License:Open Source License

public AbstractOpenAnswerDefinitionPanel createPad(ModalWindow padWindow) {
    DataType type = getOpenAnswerDefinition().getDataType();
    if (type.equals(DataType.INTEGER) || type.equals(DataType.DECIMAL)) {
        NumericPad pad = new NumericPad(padWindow.getContentId(), getQuestionModel(),
                getQuestionCategoryModel(), getOpenAnswerDefinitionModel());
        padWindow.setTitle(new StringResourceModel("NumericPadTitle", pad, null));
        return pad;
    } else {/*from   ww  w  .java  2  s  . co  m*/
        throw new UnsupportedOperationException("Pad for type " + type + " not supported yet.");
    }
}

From source file:org.onexus.ui.api.utils.panels.HelpMark.java

License:Apache License

public HelpMark(final String panelId, final String title, final String displayLabel, final String helpText) {
    super(panelId);

    // Add modal window
    final ModalWindow modal = new ModalWindow("modalWindowEmbeeded");
    modal.setTitle(title);//from  www. j a  va2  s .co  m
    modal.setInitialWidth(700);
    modal.setInitialHeight(500);
    add(modal);

    // Add mark label
    final WebMarkupContainer container = new WebMarkupContainer("displayLabel");
    container.add(new Label("label", displayLabel));
    add(container);

    // Add question mark icon
    Image img = null;
    container.add(img = new Image("imageHelp", Icons.HELP) {

        @Override
        protected boolean shouldAddAntiCacheParameter() {
            return false;
        }

    });
    img.add(new AjaxEventBehavior("onclick") {

        @Override
        protected void onEvent(final AjaxRequestTarget target) {

            if (modal != null) {
                modal.setInitialWidth(700);
                modal.setInitialHeight(500);
                modal.setContent(new HelpContentPanel(modal.getContentId(), helpText));
                modal.show(target);
            }

        }

    });

    // Visible only if there is some
    setVisible(helpText != null);

}

From source file:org.onexus.website.api.utils.panels.HelpMark.java

License:Apache License

public HelpMark(final String panelId, final String title, final String displayLabel, final String helpText) {
    super(panelId);

    // Add modal window
    final ModalWindow modal = new ModalWindow("modalWindowEmbeeded");
    modal.setTitle(title);/*from   www  . j  a  v a  2s .co m*/
    modal.setInitialWidth(700);
    modal.setInitialHeight(500);
    add(modal);

    // Add mark label
    final WebMarkupContainer container = new WebMarkupContainer("displayLabel");
    container.add(new Label("label", displayLabel));
    add(container);

    // Add question mark icon
    Image img = new Image("imageHelp", Icons.HELP) {

        @Override
        protected boolean shouldAddAntiCacheParameter() {
            return false;
        }

    };

    container.add(img);
    img.add(new AjaxEventBehavior("onclick") {

        @Override
        protected void onEvent(final AjaxRequestTarget target) {

            if (modal != null) {
                modal.setInitialWidth(700);
                modal.setInitialHeight(500);
                modal.setContent(new HelpContentPanel(modal.getContentId(), helpText));
                modal.show(target);
            }

        }

    });

    // Visible only if there is some
    setVisible(helpText != null);

}

From source file:org.sakaiproject.attendance.tool.pages.BasePage.java

License:Educational Community License

protected AjaxLink<?> getAddEditWindowAjaxLink(final AttendanceEvent obj, final String id) {
    return new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            final ModalWindow window = getAddOrEditItemWindow();
            window.setTitle(new ResourceModel("attendance.add.edit.header"));
            window.setContent(// w w w  .  j  av a2  s  .co  m
                    new EventInputPanel(window.getContentId(), window, new CompoundPropertyModel<>(obj)));
            window.show(target);
        }
    };
}