Example usage for org.apache.wicket.markup.html.form ListMultipleChoice setMaxRows

List of usage examples for org.apache.wicket.markup.html.form ListMultipleChoice setMaxRows

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form ListMultipleChoice setMaxRows.

Prototype

public final ListMultipleChoice<T> setMaxRows(final int maxRows) 

Source Link

Document

Sets the number of visible rows in the listbox.

Usage

From source file:org.obiba.onyx.ruby.core.wicket.tube.RemarkSelectorPanel.java

License:Open Source License

/**
 * Panel for the remark selection list/*w  ww.  ja  v  a  2 s .  co  m*/
 * @param id
 * @param rowModel
 * @param tubeRegistrationConfiguration
 */
public RemarkSelectorPanel(String id, IModel rowModel,
        TubeRegistrationConfiguration tubeRegistrationConfiguration) {
    super(id, rowModel);
    setOutputMarkupId(true);

    List<Remark> remarks = tubeRegistrationConfiguration.getAvailableRemarks();

    RegisteredParticipantTube registeredParticipantTube = (RegisteredParticipantTube) rowModel.getObject();
    Set<String> tubeRemarks = registeredParticipantTube.getRemarks();

    for (Remark remark : remarks) {
        if (tubeRemarks.contains(remark.getCode())) {
            selectedRemark.add(remark);
        }
    }

    ListMultipleChoice listRemarks = new ListMultipleChoice("remarkSelect",
            new PropertyModel(this, "selectedRemark"), remarks, new IChoiceRenderer() {
                private static final long serialVersionUID = 1L;

                public Object getDisplayValue(Object object) {
                    Remark remark = (Remark) object;
                    return (new SpringStringResourceModel(remark.getCode()).getString());
                }

                public String getIdValue(Object object, int index) {
                    Remark remark = (Remark) object;
                    return remark.getCode();
                }
            });

    listRemarks.setMaxRows(4);

    add(listRemarks);

    // Allow no pre-defined remarks
    setVisible(remarks.size() > 0);
}

From source file:org.opensingular.form.wicket.mapper.selection.MultipleSelectBSMapper.java

License:Apache License

@Override
@SuppressWarnings("rawtypes")
protected Component formGroupAppender(BSControls formGroup, IModel<? extends SInstance> model,
        final List<?> opcoesValue) {
    final ListMultipleChoice choices = retrieveChoices(model, opcoesValue);
    formGroup.appendSelect(choices.setMaxRows(5), true);
    return choices;
}

From source file:org.opensingular.form.wicket.mapper.selection.MultipleSelectMapper.java

License:Apache License

protected Component formGroupAppender(BSControls formGroup, IModel<? extends SInstance> model,
        final List<?> opcoesValue) {
    final ListMultipleChoice<?> choices = retrieveChoices(model, opcoesValue);
    formGroup.appendSelect(choices.setMaxRows(5), true, false);
    return choices;
}

From source file:org.syncope.console.pages.NotificationTaskModalPage.java

License:Apache License

public NotificationTaskModalPage(final TaskTO taskTO) {
    super(taskTO);

    final AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"),
            new PropertyModel<String>(taskTO, "sender"), false);
    sender.setEnabled(false);/*from w w  w  .  j a va  2  s . c  o  m*/
    profile.add(sender);

    final ListMultipleChoice<String> recipients = new ListMultipleChoice<String>("recipients",
            new ArrayList<String>(((NotificationTaskTO) taskTO).getRecipients()));
    recipients.setMaxRows(5);
    recipients.setEnabled(false);
    profile.add(recipients);

    final AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"),
            new PropertyModel<String>(taskTO, "subject"), false);
    subject.setEnabled(false);
    profile.add(subject);

    final TextArea<String> textBody = new TextArea<String>("textBody",
            new PropertyModel<String>(taskTO, "textBody"));
    textBody.setEnabled(false);
    profile.add(textBody);

    final TextArea<String> htmlBody = new TextArea<String>("htmlBody",
            new PropertyModel<String>(taskTO, "htmlBody"));
    htmlBody.setEnabled(false);
    profile.add(htmlBody);

    final AjaxTextFieldPanel traceLevel = new AjaxTextFieldPanel("traceLevel", getString("traceLevel"),
            new PropertyModel<String>(taskTO, "traceLevel"), false);
    traceLevel.setEnabled(false);
    profile.add(traceLevel);
}

From source file:ro.nextreports.server.web.core.migration.ExportPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public ExportPanel(String id) {
    super(id);/*from   w ww.ja v  a  2 s  .c  om*/

    final FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
    feedbackPanel.setOutputMarkupId(true);
    add(feedbackPanel);

    Form<Void> exportForm = new Form<Void>("exportForm");
    add(exportForm);

    final Model<ArrayList<String>> choiceModel = new Model<ArrayList<String>>();
    final ListMultipleChoice listChoice = new ListMultipleChoice("listChoice", choiceModel,
            new PropertyModel<String>(this, "list"));
    listChoice.setMaxRows(10);
    listChoice.setOutputMarkupId(true);
    exportForm.add(listChoice);

    AjaxLink addLink = new AjaxLink<Void>("addElement") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ModalWindow dialog = findParent(BasePage.class).getDialog();
            dialog.setTitle(getString("Settings.migration.export.entity.add"));
            dialog.setInitialWidth(350);
            dialog.setUseInitialHeight(false);

            AddEntityPanel addEntityPanel = new AddEntityPanel() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onOk(AjaxRequestTarget target) {
                    Iterator<Entity> entities = getEntities();
                    if (!entities.hasNext()) {
                        error(getString("Settings.migration.export.entity.select"));
                        target.add(getFeedbackPanel());
                        return;
                    }
                    while (entities.hasNext()) {
                        Entity entity = entities.next();
                        String path = entity.getPath();
                        path = path.substring(StorageConstants.NEXT_SERVER_ROOT.length() + 1);
                        if (!list.contains(path)) {
                            list.add(path);
                        }
                    }
                    ModalWindow.closeCurrent(target);
                    target.add(listChoice);
                }

            };
            dialog.setContent(new FormPanel<Void>(dialog.getContentId(), addEntityPanel, true) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onConfigure() {
                    super.onConfigure();
                    setOkButtonValue(getString("add"));
                }

            });
            dialog.show(target);
        }

    };
    addLink.add(new SimpleTooltipBehavior(getString("Settings.migration.export.entity.add")));
    exportForm.add(addLink);

    AjaxSubmitLink removeLink = new AjaxSubmitLink("removeElement", exportForm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            for (String sel : choiceModel.getObject()) {
                for (Iterator<?> it = list.iterator(); it.hasNext();) {
                    if (sel.equals(it.next())) {
                        it.remove();
                    }
                }
            }
            if (target != null) {
                target.add(listChoice);
            }
        }

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

    };
    removeLink.add(new SimpleTooltipBehavior(getString("Settings.migration.export.entity.remove")));
    exportForm.add(removeLink);

    TextField<String> exportField = new TextField<String>("exportPath",
            new PropertyModel<String>(this, "exportPath"));
    exportField.setLabel(new Model<String>(getString("Settings.migration.export.path")));
    exportForm.add(exportField);

    exportForm.add(new AjaxSubmitLink("export") {

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

            // we do not use TextField validation with setRequired because we have a submit button (remove entity)
            // which must work without validation
            if ((exportPath == null) || "".endsWith(exportPath.trim())) {
                error(getString("Settings.migration.export.path.select"));
                target.add(feedbackPanel);
                return;
            }

            NextServerApplication.setMaintenance(true);

            MigrationObject mo = new MigrationObject();
            List<DataSource> dsList = new ArrayList<DataSource>();
            List<Report> reportList = new ArrayList<Report>();
            List<Chart> chartList = new ArrayList<Chart>();
            List<DashboardState> dashboards = new ArrayList<DashboardState>();
            mo.setDataSources(dsList);
            mo.setReports(reportList);
            mo.setCharts(chartList);
            mo.setDashboards(dashboards);

            FileOutputStream fos = null;
            try {

                if (list.size() == 0) {
                    error(getString("Settings.migration.export.entity.select"));
                } else {

                    for (String pathM : list) {
                        populateLists(pathM, mo);
                    }

                    XStream xstream = new XStream(new DomDriver());
                    SimpleDateFormat sdf = new SimpleDateFormat("dd_MM_yyyy_hh_mm");
                    fos = new FileOutputStream(
                            exportPath + File.separator + "migration-" + sdf.format(new Date()) + ".xml");
                    xstream.toXML(mo, fos);

                    info(getString("Settings.migration.export.info"));
                }
            } catch (Throwable t) {
                error(t.getMessage());
            } finally {
                NextServerApplication.setMaintenance(false);
                if (fos != null) {
                    try {
                        fos.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }

            target.add(feedbackPanel);

        }

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

    });
}

From source file:ro.nextreports.server.web.report.ManualListPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public ManualListPanel(QueryParameter parameter, final IModel<List<Serializable>> listModel, int rows,
        AjaxFormComponentUpdatingBehavior ajaxUpdate) {

    super("palette");
    this.parameter = parameter;
    this.updatingBehavior = ajaxUpdate;

    Form form = new Form("form");

    final FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
    feedbackPanel.setOutputMarkupId(true);
    add(feedbackPanel);/* ww  w  .  j  a v  a2s. c  om*/

    final TextField<String> textField = new TextField<String>("txtValue",
            new PropertyModel<String>(this, "objectModel")) {

        // needed in wicket 1.5 (our model object is of a generic type Serializable instead of String)
        // and an error is raised saying "1 is not a valid serializable") if no converter added
        // wicket 1.4 did not need this
        @Override
        public <C> IConverter<C> getConverter(Class<C> type) {
            return new AbstractConverter() {

                public Object convertToObject(String value, Locale locale) {
                    return value;
                }

                @Override
                protected Class getTargetType() {
                    return String.class;
                }

            };
        }
    };
    textField.setVisible(false);

    final DateTimeField txtTime = new DateTimeField("txtTime", new PropertyModel<Date>(this, "objectModel")) {

        private static final long serialVersionUID = 1L;

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

        protected DatePicker newDatePicker() {
            return new DatePicker() {
                private static final long serialVersionUID = 1L;

                @Override
                protected void configure(final Map<String, Object> widgetProperties,
                        final IHeaderResponse response, final Map<String, Object> initVariables) {
                    super.configure(widgetProperties, response, initVariables);
                }

                @Override
                protected boolean enableMonthYearSelection() {
                    return true;
                }

            };
        }

    };
    txtTime.setVisible(false);

    final Model<ArrayList<Serializable>> choiceModel = new Model<ArrayList<Serializable>>();
    final ListMultipleChoice listChoice = new ListMultipleChoice("listChoice", choiceModel, listModel);
    listChoice.setMaxRows(rows);
    listChoice.setOutputMarkupId(true);
    listChoice.add(ajaxUpdate);

    final String type = parameter.getValueClassName();
    if (QueryParameter.DATE_VALUE.equals(type) || QueryParameter.TIME_VALUE.equals(type)
            || QueryParameter.TIMESTAMP_VALUE.equals(type)) {
        txtTime.setVisible(true);
    } else {
        textField.setVisible(true);
    }

    AjaxSubmitLink addLink = new AjaxSubmitLink("addElement", form) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (objectModel == null) {
                return;
            }

            List<Serializable> model = listModel.getObject();
            if (objectModel instanceof String) {
                try {
                    List<Serializable> values = getValues((String) objectModel, type);

                    for (Serializable value : values) {
                        if (!model.contains(value)) {
                            model.add(value);
                        }
                    }
                } catch (NumberFormatException ex) {
                    error("Invalid value type.");
                }
            } else if (!model.contains(objectModel)) {
                model.add(objectModel);
            }

            if (target != null) {
                target.add(listChoice);
            }
        }

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

    };
    addLink.add(new SimpleTooltipBehavior("Add value"));

    AjaxSubmitLink removeLink = new AjaxSubmitLink("removeElement", form) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            for (Serializable sel : choiceModel.getObject()) {
                for (Iterator<?> it = listModel.getObject().iterator(); it.hasNext();) {
                    if (sel.equals(it.next())) {
                        it.remove();
                    }
                }
            }
            if (target != null) {
                target.add(listChoice);
            }
        }

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

    };
    removeLink.add(new SimpleTooltipBehavior("Remove selected values"));

    form.add(textField);
    form.add(txtTime);
    form.add(listChoice);
    form.add(addLink);
    form.add(removeLink);

    add(form);
}