Example usage for org.apache.wicket.markup.html.form EnumChoiceRenderer EnumChoiceRenderer

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

Introduction

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

Prototype

public EnumChoiceRenderer(Component resourceSource) 

Source Link

Document

Constructor

Usage

From source file:abid.password.wicket.fields.PasswordTypeChoice.java

License:Apache License

public PasswordTypeChoice(final String id, final IModel<PasswordType> model) {
    super(id);//from   w  w w .  ja va2s.  co  m
    setModel(model);
    setChoices(Arrays.asList(PasswordType.values()));
    setChoiceRenderer(new EnumChoiceRenderer<PasswordType>(this));
}

From source file:abid.password.wicket.fields.TimeParameterChoice.java

License:Apache License

public TimeParameterChoice(final String id, final IModel<TimeParameter> model, List<TimeParameter> list) {
    super(id);//  w  ww  .j  a v a2s.  co m
    setModel(model);
    if (list == null) {
        list = Arrays.asList(TimeParameter.values());
    }
    setChoices(list);
    setChoiceRenderer(new EnumChoiceRenderer<TimeParameter>(this));
}

From source file:au.org.theark.report.web.component.dataextraction.filter.form.QueryFilterForm.java

License:Open Source License

private void initOperatorDdc(final ListItem<QueryFilterVO> item) {
    Collection<Operator> operatorList = Arrays.asList(Operator.values());
    //ChoiceRenderer<Operator> choiceRenderer = new ChoiceRenderer<Operator>(Constants.PUBLIC_FIELD_NAME, Constants.ID);
    operatorDdc = new DropDownChoice<Operator>("queryFilter.operator",
            new PropertyModel(item.getModelObject(), "queryFilter.operator"), (List<Operator>) operatorList,
            new EnumChoiceRenderer<Operator>(QueryFilterForm.this));

    operatorDdc.setOutputMarkupId(true);
    operatorDdc.setRequired(true);/*from   www .  ja  v  a  2 s. c  o m*/
    operatorDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Operator operatorFromDDC = item.getModelObject().getQueryFilter().getOperator();
            item.get("secondValue").setEnabled(operatorFromDDC.equals(Operator.BETWEEN));
            target.add(item.get("secondValue"));
        }
    });
    item.add(operatorDdc);

    secondValueTxtFld = new TextField<String>("secondValue",
            new PropertyModel(item.getModelObject(), "queryFilter.secondValue"));
    secondValueTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            /* we may want to perform some live validation based on the type of field we are selecting*/
            log.info("onchange of SECOND VALUE");
            target.add(feedbackPanel);
        }
    });
    secondValueTxtFld.setOutputMarkupPlaceholderTag(true);
    secondValueTxtFld.setEnabled(false);
    item.add(secondValueTxtFld);
}

From source file:au.org.theark.report.web.component.dataextraction.filter.form.QueryFilterForm.java

License:Open Source License

private void initFieldCategoryDdc(final ListItem<QueryFilterVO> item) {

    List<FieldCategory> fieldCategoryList = Arrays.asList(FieldCategory.values());
    fieldCategoryDdc = new DropDownChoice<FieldCategory>("fieldCategory",
            new PropertyModel(item.getModelObject(), "fieldCategory"), (List<FieldCategory>) fieldCategoryList,
            new EnumChoiceRenderer<FieldCategory>(QueryFilterForm.this));
    fieldCategoryDdc.setNullValid(false);
    if (item.getModelObject() == null || item.getModelObject().getFieldCategory() == null) {
        fieldCategoryDdc.setDefaultModelObject(FieldCategory.DEMOGRAPHIC_FIELD);
    }/*from   w ww. j  av a 2 s.  c  om*/
    fieldCategoryDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            FieldCategory catFromDDC = item.getModelObject().getFieldCategory();

            switch (catFromDDC) {

            case DEMOGRAPHIC_FIELD: {
                Collection<DemographicField> demographicFieldCategoryList = iArkCommonService
                        .getAllDemographicFields();
                ChoiceRenderer<DemographicField> choiceRenderer = new ChoiceRenderer<DemographicField>(
                        Constants.PUBLIC_FIELD_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<DemographicField>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.demographicField"),
                        (List<DemographicField>) demographicFieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                //               item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;
            }

            case BIOSPECIMEN_FIELD: {
                Collection<BiospecimenField> BiospecimenFieldCategoryList = iArkCommonService
                        .getAllBiospecimenFields();
                ChoiceRenderer<BiospecimenField> choiceRenderer = new ChoiceRenderer<BiospecimenField>(
                        Constants.PUBLIC_FIELD_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<BiospecimenField>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.biospecimenField"),
                        (List<BiospecimenField>) BiospecimenFieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                //item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;

            }

            case BIOCOLLECTION_FIELD: {
                Collection<BiocollectionField> biocollectionFieldCategoryList = iArkCommonService
                        .getAllBiocollectionFields();
                ChoiceRenderer<BiocollectionField> choiceRenderer = new ChoiceRenderer<BiocollectionField>(
                        Constants.PUBLIC_FIELD_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<BiocollectionField>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.biocollectionField"),
                        (List<BiocollectionField>) biocollectionFieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                //item.getModelObject().getQueryFilter().setBiocollectionField(null);
                item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;
            }

            case SUBJECT_CFD: {
                ArkFunction arkFunction = iArkCommonService
                        .getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD);

                List<CustomFieldDisplay> fieldCategoryList = iArkCommonService
                        .getCustomFieldDisplaysIn(getModelObject().getStudy(), arkFunction);
                ChoiceRenderer<CustomFieldDisplay> choiceRenderer = new ChoiceRenderer<CustomFieldDisplay>(
                        Constants.CUSTOM_FIELD_DOT_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<CustomFieldDisplay>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.customFieldDisplay"),
                        (List<CustomFieldDisplay>) fieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                //item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;
            }

            case PHENO_FD: {
                ArkFunction arkFunction = iArkCommonService
                        .getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY);

                List<PhenoDataSetFieldDisplay> fieldCategoryList = iPhenoService
                        .getPhenoFieldDisplaysIn(getModelObject().getStudy(), arkFunction);
                ChoiceRenderer<PhenoDataSetFieldDisplay> choiceRenderer = new ChoiceRenderer<PhenoDataSetFieldDisplay>(
                        "descriptiveNameIncludingCFGName", Constants.ID);
                fieldDdc = new DropDownChoice<PhenoDataSetFieldDisplay>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.phenoDataSetFieldDisplay"),
                        (List<PhenoDataSetFieldDisplay>) fieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                //item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;
            }

            case BIOCOLLECTION_CFD: {
                ArkFunction arkFunction = iArkCommonService
                        .getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_LIMS_CUSTOM_FIELD);

                List<CustomFieldDisplay> fieldCategoryList = iArkCommonService
                        .getCustomFieldDisplaysIn(getModelObject().getStudy(), arkFunction);
                ChoiceRenderer<CustomFieldDisplay> choiceRenderer = new ChoiceRenderer<CustomFieldDisplay>(
                        Constants.CUSTOM_FIELD_DOT_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<CustomFieldDisplay>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.customFieldDisplay"),
                        (List<CustomFieldDisplay>) fieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                //item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;
            }

            case BIOSPECIMEN_CFD: {
                ArkFunction arkFunction = iArkCommonService
                        .getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_BIOSPECIMEN);

                List<CustomFieldDisplay> fieldCategoryList = iArkCommonService
                        .getCustomFieldDisplaysIn(getModelObject().getStudy(), arkFunction);
                ChoiceRenderer<CustomFieldDisplay> choiceRenderer = new ChoiceRenderer<CustomFieldDisplay>(
                        Constants.CUSTOM_FIELD_DOT_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<CustomFieldDisplay>("queryFilter.field",
                        new PropertyModel(item.getModelObject(), "queryFilter.customFieldDisplay"),
                        (List<CustomFieldDisplay>) fieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                //item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setConsentStatusField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                break;
            }

            case CONSENT_STATUS_FIELD: {
                Collection<ConsentStatusField> consentStatusFieldCategoryList = iArkCommonService
                        .getAllConsentStatusFields();
                ChoiceRenderer<ConsentStatusField> choiceRenderer = new ChoiceRenderer<ConsentStatusField>(
                        Constants.PUBLIC_FIELD_NAME, Constants.ID);
                fieldDdc = new DropDownChoice<ConsentStatusField>("queryFilter.field",
                        new PropertyModel<ConsentStatusField>(item.getModelObject(),
                                "queryFilter.consentStatusField"),
                        (List<ConsentStatusField>) consentStatusFieldCategoryList, choiceRenderer);
                fieldDdc.setRequired(true);
                item.getModelObject().getQueryFilter().setBiospecimenField(null);
                item.getModelObject().getQueryFilter().setBiocollectionField(null);
                item.getModelObject().getQueryFilter().setCustomFieldDisplay(null);
                item.getModelObject().getQueryFilter().setDemographicField(null);
                item.getModelObject().getQueryFilter().setPhenoDataSetFieldDisplay(null);
                //item.getModelObject().getQueryFilter().setConsentStatusField(null);
                break;
            }

            }

            fieldDdc.setOutputMarkupId(true);
            fieldDdc.setRequired(true);
            fieldDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                /**
                * 
                */
                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    log.debug("Change of fieldDDc");
                }

                @Override
                protected void onError(AjaxRequestTarget target, RuntimeException e) {
                    target.add(feedbackPanel);
                }
            });
            item.addOrReplace(fieldDdc);
            target.add(item);

            /*item.setOutputMarkupId(true);
            item.addOrReplace(fieldDdc);
            target.add(item);*/

        }
    });
    item.add(fieldCategoryDdc);

}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.HeaderConfigUI.java

License:Apache License

/**
 * Create the DataType drop down. When the data type is changed, the offsets will be recalculated and updated.
 *///from   w w  w. j a v a2s . c  o m
private DropDownChoice<HeaderDataType> getDataTypeDropdown() {
    DropDownChoice<HeaderDataType> dropDown = new DropDownChoice<HeaderDataType>("dataType",
            HeaderDataType.getOptions(), new EnumChoiceRenderer<HeaderDataType>(this)) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (hasErrorMessage()) {
                String style = "background-color:#ffff00;";
                String oldStyle = tag.getAttribute("style");
                tag.put("style", style + oldStyle);
            }
        }
    };

    dropDown.setRequired(true);

    // When the data type is changed, the offsets are recalculated and displayed
    dropDown.add(new OnChangeAjaxBehavior() {
        @SuppressWarnings("unchecked")
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // Recalculate and display the offsets
            updateOffsets(target);

            // Disable value field when DataType does not use a value.
            DropDownChoice<HeaderDataType> choice = (DropDownChoice<HeaderDataType>) getComponent();
            MarkupContainer parent = choice.getParent();
            HeaderDataType dataType = choice.getConvertedInput();
            target.add(
                    parent.get("rawValue").setEnabled(dataType.isHasValue()).setVisible(dataType.isHasValue()));
            target.add(parent.get("size").setEnabled(dataType.isArrayAllowed()));
        }
    });

    dropDown.add(new UniqueListItemValidator<HeaderDataType>(dropDown) {
        @Override
        public String getValue(IValidatable<HeaderDataType> validatable) {
            return String.valueOf(validatable.getValue().name());
        }
    }.setMessageKey("dataType.SpecialTypesValidator").setFilterList(HeaderDataType.getSpecialItemNames()));

    return dropDown;
}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java

License:Apache License

private DropDownChoice<QueueMode> getQueueModeDropdown() {
    DropDownChoice<QueueMode> dropDown = new DropDownChoice<QueueMode>("queueMode", QueueMode.getOptions(),
            new EnumChoiceRenderer<QueueMode>(this));
    dropDown.setOutputMarkupId(true);/*from   w  w w.j ava2s  .c  o m*/
    return dropDown;
}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java

License:Apache License

private DropDownChoice<MessageType> getMessageTypeDropdown() {
    DropDownChoice<MessageType> dropDown = new DropDownChoice<MessageType>("messageType",
            MessageType.getOptions(), new EnumChoiceRenderer<MessageType>(this));
    dropDown.setOutputMarkupId(true);//from   www  .  jav a 2 s .c o m

    // When the MessageType is changed, the tag length type dropdowns are updated
    dropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateTagLength(target);

            // Reset feedback messages
            target.addChildren(getPage(), FeedbackPanel.class);
        }
    });

    return dropDown;
}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java

License:Apache License

private DropDownChoice<OptionalDataType> getMessageIdTypeDropdown() {
    DropDownChoice<OptionalDataType> dropDown = new DropDownChoice<OptionalDataType>("messageIdType",
            new PropertyModel<OptionalDataType>(getDefaultModel(), "messageIdType"),
            OptionalDataType.getOptions(), new EnumChoiceRenderer<OptionalDataType>(this));

    // When the MessageId Type is changed, the offsets are recalculated and displayed
    dropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override//from   ww  w.  jav a2 s .  co  m
        protected void onUpdate(AjaxRequestTarget target) {
            updateOffsets(target);

            // Reset feedback messages
            target.addChildren(getPage(), FeedbackPanel.class);
        }
    });

    return dropDown;
}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java

License:Apache License

private DropDownChoice<TagLengthType> getTagLengthTypeDropDown() {
    DropDownChoice<TagLengthType> dropDown = new DropDownChoice<TagLengthType>("tagLengthType",
            TagLengthType.getOptions(), new EnumChoiceRenderer<TagLengthType>(this)) {
        @Override/*from  w ww. j  a  v  a2s . c o m*/
        public boolean isVisible() {
            return currentMessage.isVariableLength();
        }
    };

    dropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(feedback);
        }

        @Override
        protected void onError(AjaxRequestTarget target, RuntimeException e) {
            target.add(feedback);
        }
    });

    dropDown.setOutputMarkupId(true);
    dropDown.setOutputMarkupPlaceholderTag(true);

    dropDown.add(new UniqueListItemValidator<TagLengthType>(dropDown) {
        @Override
        public String getValue(IValidatable<TagLengthType> validatable) {
            return String.valueOf(validatable.getValue().name());
        }
    }.setMessageKey("tagLengthType.OnlyOnePackedBasedValidator")
            .setFilterList(new String[] { TagLengthType.PACKET_BASED.name() }));

    return dropDown;
}

From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java

License:Apache License

/**
 * Create the DataType dropdown. When the datatype is changed, the offsets will be recalculated and updated.
 *///from w  w w  . ja v  a 2 s .c o m
private DropDownChoice<BinaryDataType> getDataTypeDropdown() {
    DropDownChoice<BinaryDataType> dropDown = new DropDownChoice<BinaryDataType>("dataType",
            BinaryDataType.getOptions(), new EnumChoiceRenderer<BinaryDataType>(this)) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (hasErrorMessage()) {
                String style = "background-color:#ffff00;";
                String oldStyle = tag.getAttribute("style");
                tag.put("style", style + oldStyle);
            }
        }
    };

    dropDown.setRequired(true);

    // When the datatype is changed, the offsets are recalculated and displayed
    dropDown.add(new OnChangeAjaxBehavior() {
        @SuppressWarnings("unchecked")
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // Recalculate and display the offsets
            updateOffsets(target);

            // Disable input fields when DataType is a special type.
            // Current state is determined by the enabled state of TextField("id")
            DropDownChoice<BinaryDataType> choice = (DropDownChoice<BinaryDataType>) getComponent();
            MarkupContainer parent = choice.getParent();
            Component idTextField = parent.get("id");
            BinaryDataType dataType = choice.getConvertedInput();
            if (dataType.isSpecial() && idTextField.isEnabled()) {
                // DataType changed to special type
                // Store current values
                ((TextField<Integer>) idTextField).getRawInput();
                idTextField.replaceWith(getSpecialIdTextField().setEnabled(false));
                target.add(parent.get("id"));
                target.add(parent.get("alias").setVisible(false));
            } else if (!idTextField.isEnabled()) {
                idTextField.replaceWith(getIdTextField());
                target.add(parent.get("id").setEnabled(true));
                target.add(parent.get("alias").setVisible(true));
            }
            target.add(parent.get("size").setEnabled(dataType.isArrayAllowed()));
            target.add(parent.get("tagLengthType").setEnabled(dataType.supportsVariableLength()));
            if (!dataType.supportsVariableLength()) {
                EditorListItem<TagConfig> listItem = getComponent().findParent(EditorListItem.class);
                if (listItem != null) {
                    listItem.getModelObject().setTagLengthType(TagLengthType.FIXED_LENGTH);
                }
            }
        }
    });

    dropDown.add(new UniqueListItemValidator<BinaryDataType>(dropDown) {
        @Override
        public String getValue(IValidatable<BinaryDataType> validatable) {
            return String.valueOf(validatable.getValue().name());
        }
    }.setMessageKey("dataType.SpecialTypesValidator")
            .setFilterList(new String[] { BinaryDataType.MessageAge.name() }));

    return dropDown;
}