Search in sources :

Example 1 with BinaryFieldPanel

use of org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel in project syncope by apache.

the class ParametersDetailsPanel method getFieldPanel.

@SuppressWarnings({ "rawtypes", "unchecked" })
private Panel getFieldPanel(final String id, final AttrTO attrTO) {
    final String valueHeaderName = getString("values");
    final PlainSchemaTO schemaTO = schemaRestClient.read(SchemaType.PLAIN, attrTO.getSchema());
    final FieldPanel panel;
    switch(schemaTO.getType()) {
        case Date:
            final String datePattern = schemaTO.getConversionPattern() == null ? SyncopeConstants.DEFAULT_DATE_PATTERN : schemaTO.getConversionPattern();
            if (StringUtils.containsIgnoreCase(datePattern, "H")) {
                panel = new AjaxDateTimeFieldPanel("panel", schemaTO.getKey(), new Model<>(), datePattern);
            } else {
                panel = new AjaxDateFieldPanel("panel", schemaTO.getKey(), new Model<>(), datePattern);
            }
            break;
        case Boolean:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(Arrays.asList("true", "false"));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid(false);
            break;
        case Enum:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(SchemaUtils.getEnumeratedValues(schemaTO));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid("false".equalsIgnoreCase(schemaTO.getMandatoryCondition()));
            break;
        case Long:
            panel = new AjaxSpinnerFieldPanel.Builder<Long>().build(id, valueHeaderName, Long.class, new Model<Long>());
            break;
        case Double:
            panel = new AjaxSpinnerFieldPanel.Builder<Double>().build(id, valueHeaderName, Double.class, new Model<Double>());
            break;
        case Binary:
            panel = new BinaryFieldPanel(id, valueHeaderName, new Model<>(), schemaTO.getMimeType(), schema.getModelObject());
            break;
        case Encrypted:
            panel = new EncryptedFieldPanel(id, valueHeaderName, new Model<>(), true);
            break;
        default:
            panel = new AjaxTextFieldPanel(id, valueHeaderName, new Model<>(), false);
    }
    if (schemaTO.isMultivalue()) {
        return new MultiFieldPanel.Builder<>(new PropertyModel<List<String>>(attrTO, "values")).build(id, valueHeaderName, panel);
    } else {
        panel.setNewModel(attrTO.getValues());
    }
    panel.setRequired("true".equalsIgnoreCase(schemaTO.getMandatoryCondition()));
    return panel;
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)

Example 2 with BinaryFieldPanel

use of org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel in project syncope by apache.

the class ParametersCreateWizardAttrStep method getFieldPanel.

@SuppressWarnings({ "rawtypes", "unchecked" })
private Panel getFieldPanel(final String id, final AttrTO attrTO, final PlainSchemaTO plainSchemaTO) {
    final String valueHeaderName = getString("values");
    final FieldPanel panel;
    switch(plainSchemaTO.getType()) {
        case Date:
            final String dataPattern = plainSchemaTO.getConversionPattern() == null ? SyncopeConstants.DEFAULT_DATE_PATTERN : plainSchemaTO.getConversionPattern();
            if (dataPattern.contains("H")) {
                panel = new AjaxDateTimeFieldPanel(id, valueHeaderName, new Model<>(), dataPattern);
            } else {
                panel = new AjaxDateFieldPanel("panel", valueHeaderName, new Model<>(), dataPattern);
            }
            break;
        case Boolean:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(Arrays.asList("true", "false"));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid(false);
            break;
        case Enum:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(SchemaUtils.getEnumeratedValues(plainSchemaTO));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid("true".equalsIgnoreCase(plainSchemaTO.getMandatoryCondition()));
            break;
        case Long:
            panel = new AjaxSpinnerFieldPanel.Builder<Long>().build(id, valueHeaderName, Long.class, new Model<Long>());
            break;
        case Double:
            panel = new AjaxSpinnerFieldPanel.Builder<Double>().build(id, valueHeaderName, Double.class, new Model<Double>());
            break;
        case Binary:
            panel = new BinaryFieldPanel(id, valueHeaderName, new Model<>(), plainSchemaTO.getMimeType(), schema.getModelObject());
            break;
        case Encrypted:
            panel = new EncryptedFieldPanel(id, valueHeaderName, new Model<>(), true);
            break;
        default:
            panel = new AjaxTextFieldPanel(id, valueHeaderName, new Model<>(), false);
    }
    if (plainSchemaTO.isMultivalue()) {
        return new MultiFieldPanel.Builder<>(new PropertyModel<>(attrTO, "values")).build(id, valueHeaderName, panel);
    } else {
        panel.setNewModel(attrTO.getValues());
    }
    panel.setRequired("true".equalsIgnoreCase(plainSchemaTO.getMandatoryCondition()));
    return panel;
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) PropertyModel(org.apache.wicket.model.PropertyModel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)

Example 3 with BinaryFieldPanel

use of org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel in project syncope by apache.

the class PlainAttrs method getFieldPanel.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected FieldPanel getFieldPanel(final PlainSchemaTO schemaTO) {
    final boolean required;
    final boolean readOnly;
    final AttrSchemaType type;
    final boolean jexlHelp;
    if (mode == AjaxWizard.Mode.TEMPLATE) {
        required = false;
        readOnly = false;
        type = AttrSchemaType.String;
        jexlHelp = true;
    } else {
        required = schemaTO.getMandatoryCondition().equalsIgnoreCase("true");
        readOnly = schemaTO.isReadonly();
        type = schemaTO.getType();
        jexlHelp = false;
    }
    FieldPanel panel;
    switch(type) {
        case Boolean:
            panel = new AjaxCheckBoxPanel("panel", schemaTO.getKey(), new Model<>(), true);
            panel.setRequired(required);
            break;
        case Date:
            String dataPattern = schemaTO.getConversionPattern() == null ? SyncopeConstants.DEFAULT_DATE_PATTERN : schemaTO.getConversionPattern();
            if (dataPattern.contains("H")) {
                panel = new AjaxDateTimeFieldPanel("panel", schemaTO.getKey(), new Model<>(), dataPattern);
            } else {
                panel = new AjaxDateFieldPanel("panel", schemaTO.getKey(), new Model<>(), dataPattern);
            }
            if (required) {
                panel.addRequiredLabel();
            }
            break;
        case Enum:
            panel = new AjaxDropDownChoicePanel<>("panel", schemaTO.getKey(), new Model<>(), true);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(SchemaUtils.getEnumeratedValues(schemaTO));
            if (StringUtils.isNotBlank(schemaTO.getEnumerationKeys())) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    private final Map<String, String> valueMap = SchemaUtils.getEnumeratedKeyValues(schemaTO);

                    @Override
                    public String getDisplayValue(final String value) {
                        return valueMap.get(value) == null ? value : valueMap.get(value);
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            if (required) {
                panel.addRequiredLabel();
            }
            break;
        case Long:
            panel = new AjaxSpinnerFieldPanel.Builder<Long>().enableOnChange().build("panel", schemaTO.getKey(), Long.class, new Model<Long>());
            if (required) {
                panel.addRequiredLabel();
            }
            break;
        case Double:
            panel = new AjaxSpinnerFieldPanel.Builder<Double>().enableOnChange().step(0.1).build("panel", schemaTO.getKey(), Double.class, new Model<Double>());
            if (required) {
                panel.addRequiredLabel();
            }
            break;
        case Binary:
            final PageReference pageReference = getPageReference();
            panel = new BinaryFieldPanel("panel", schemaTO.getKey(), new Model<>(), schemaTO.getMimeType(), fileKey) {

                private static final long serialVersionUID = -3268213909514986831L;

                @Override
                protected PageReference getPageReference() {
                    return pageReference;
                }
            };
            if (required) {
                panel.addRequiredLabel();
            }
            break;
        case Encrypted:
            panel = new EncryptedFieldPanel("panel", schemaTO.getKey(), new Model<>(), true);
            if (required) {
                panel.addRequiredLabel();
            }
            break;
        default:
            panel = new AjaxTextFieldPanel("panel", schemaTO.getKey(), new Model<>(), true);
            if (jexlHelp) {
                AjaxTextFieldPanel.class.cast(panel).enableJexlHelp();
            }
            if (required) {
                panel.addRequiredLabel();
            }
    }
    panel.setReadOnly(readOnly);
    return panel;
}
Also used : AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) AjaxCheckBoxPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) PageReference(org.apache.wicket.PageReference) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AbstractFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AbstractFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AttrSchemaType(org.apache.syncope.common.lib.types.AttrSchemaType) StringResourceModel(org.apache.wicket.model.StringResourceModel) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) ResourceModel(org.apache.wicket.model.ResourceModel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)

Aggregations

AjaxDateFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel)3 AjaxDateTimeFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)3 AjaxDropDownChoicePanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel)3 AjaxSpinnerFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel)3 AjaxTextFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel)3 BinaryFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel)3 EncryptedFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel)3 FieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel)3 MultiFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel)3 IModel (org.apache.wicket.model.IModel)3 Model (org.apache.wicket.model.Model)3 PropertyModel (org.apache.wicket.model.PropertyModel)3 AbstractFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AbstractFieldPanel)1 AjaxCheckBoxPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel)1 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)1 AttrSchemaType (org.apache.syncope.common.lib.types.AttrSchemaType)1 PageReference (org.apache.wicket.PageReference)1 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)1 LoadableDetachableModel (org.apache.wicket.model.LoadableDetachableModel)1 ResourceModel (org.apache.wicket.model.ResourceModel)1