Package org.apache.syncope.console.wicket.markup.html.form

Examples of org.apache.syncope.console.wicket.markup.html.form.FieldPanel


                        Label label = new Label("key", prop.getName() == null
                                ? prop.getId()
                                : prop.getName());
                        item.add(label);

                        FieldPanel field;
                        switch (prop.getType()) {
                            case Boolean:
                                field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(),
                                        new Model(Boolean.valueOf(prop.getValue()))).setChoices(Arrays.asList(
                                                new String[] { "Yes", "No" }));
                                break;

                            case Date:
                                SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern())
                                ? new SimpleDateFormat(prop.getDatePattern())
                                : new SimpleDateFormat();
                                Date parsedDate = null;
                                if (StringUtils.isNotBlank(prop.getValue())) {
                                    try {
                                        parsedDate = df.parse(prop.getValue());
                                    } catch (ParseException e) {
                                        LOG.error("Unparsable date: {}", prop.getValue(), e);
                                    }
                                }

                                field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(),
                                        new Model(parsedDate), df.toLocalizedPattern());
                                break;

                            case Enum:
                                MapChoiceRenderer<String, String> enumCR =
                                new MapChoiceRenderer<String, String>(prop.getEnumValues());

                                field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(),
                                        new Model(prop.getValue())).setChoiceRenderer(enumCR).setChoices(new Model() {

                                    private static final long serialVersionUID = -858521070366432018L;

                                    @Override
                                    public Serializable getObject() {
                                        return new ArrayList(prop.getEnumValues().keySet());
                                    }
                                });
                                break;

                            case Long:
                                field = new AjaxNumberFieldPanel("value", label.getDefaultModelObjectAsString(),
                                        new Model(Long.valueOf(prop.getValue())), Long.class);
                                break;

                            case String:
                            default:
                                field = new AjaxTextFieldPanel("value", PARENT_PATH, new Model(prop.getValue()));
                                break;
                        }

                        field.setReadOnly(!prop.isWritable());
                        if (prop.isRequired()) {
                            field.addRequiredLabel();
                        }

                        item.add(field);
                    }
                };
View Full Code Here


                        target.add(intAttrNames.getField());

                    }
                });

                final FieldPanel extAttrName;

                if (schemaNames.isEmpty()) {
                    extAttrName = new AjaxTextFieldPanel("extAttrName", new ResourceModel("extAttrNames",
                            "extAttrNames").getObject(), new PropertyModel<String>(mappingTO, "extAttrName"));

                } else {
                    extAttrName = new AjaxDropDownChoicePanel<String>("extAttrName", new ResourceModel("extAttrNames",
                            "extAttrNames").getObject(), new PropertyModel(mappingTO, "extAttrName"));
                    ((AjaxDropDownChoicePanel) extAttrName).setChoices(schemaNames);
                }

                boolean required = false;
                if (mappingTO != null && !mappingTO.isAccountid() && !mappingTO.isPassword()) {
                    required = true;
                }


                extAttrName.setRequired(required);
                extAttrName.setEnabled(required);

                extAttrName.setStyleShet(fieldStyle);
                item.add(extAttrName);

                final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel("mandatoryCondition", new ResourceModel(
                        "mandatoryCondition", "mandatoryCondition").getObject(), new PropertyModel(mappingTO,
                        "mandatoryCondition"));

                mandatory.setChoices(Arrays.asList(new String[]{"true", "false"}));

                mandatory.setStyleShet(shortFieldStyle);

                item.add(mandatory);

                final AjaxCheckBoxPanel accountId = new AjaxCheckBoxPanel("accountId", new ResourceModel("accountId",
                        "accountId").getObject(), new PropertyModel(mappingTO, "accountid"));

                accountId.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

                    private static final long serialVersionUID = -1107858522700306810L;

                    @Override
                    protected void onUpdate(final AjaxRequestTarget target) {
                        extAttrName.setEnabled(!accountId.getModelObject() && !mappingTO.isPassword());
                        extAttrName.setModelObject(null);
                        extAttrName.setRequired(!accountId.getModelObject());
                        target.add(extAttrName);
                    }
                });

                item.add(accountId);

                final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel("password", new ResourceModel("password",
                        "password").getObject(), new PropertyModel(mappingTO, "password"));

                password.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

                    private static final long serialVersionUID = -1107858522700306810L;

                    @Override
                    protected void onUpdate(final AjaxRequestTarget target) {
                        extAttrName.setEnabled(!mappingTO.isAccountid() && !password.getModelObject());
                        extAttrName.setModelObject(null);
                        extAttrName.setRequired(!password.getModelObject());
                        target.add(extAttrName);

                        setAccountId((IntMappingType) typesPanel.getModelObject(), accountId, password);
                        target.add(accountId);
                    }
View Full Code Here

                        ? property.getSchema().getName()
                        : property.getSchema().getDisplayName());

                item.add(label);

                final FieldPanel field;

                boolean required = false;

                boolean isArray = false;

                if (GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())
                        || GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {

                    field = new AjaxPasswordFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model());
                    ((PasswordTextField) field.getField()).setResetPassword(false);

                    required = property.getSchema().isRequired();

                } else {
                    Class propertySchemaClass;

                    try {
                        propertySchemaClass = ClassUtils.forName(property.getSchema().getType(), ClassUtils
                                .getDefaultClassLoader());
                    } catch (Exception e) {
                        LOG.error("Error parsing attribute type", e);
                        propertySchemaClass = String.class;
                    }

                    if (NUMBER.contains(propertySchemaClass)) {
                        field = new AjaxNumberFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model(),
                                ClassUtils.resolvePrimitiveIfNecessary(propertySchemaClass));

                        required = property.getSchema().isRequired();
                    } else if (Boolean.class.equals(propertySchemaClass) || boolean.class.equals(propertySchemaClass)) {
                        field = new AjaxCheckBoxPanel("panel", label.getDefaultModelObjectAsString(), new Model());
                    } else {
                        field = new AjaxTextFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model());

                        required = property.getSchema().isRequired();
                    }

                    if (String[].class.equals(propertySchemaClass)) {
                        isArray = true;
                    }
                }

                field.setTitle(property.getSchema().getHelpMessage());

                if (isArray) {
                    field.removeRequiredLabel();

                    if (property.getValues().isEmpty()) {
                        property.getValues().add(null);
                    }

                    final MultiValueSelectorPanel multiFields = new MultiValueSelectorPanel<String>("panel",
                            new PropertyModel<List<String>>(property, "values"), field, true);

                    item.add(multiFields);
                } else {
                    if (required) {
                        field.addRequiredLabel();
                    }

                    field.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") {

                        private static final long serialVersionUID = -1107858522700306810L;

                        @Override
                        protected void onUpdate(final AjaxRequestTarget target) {
                            send(getPage(), Broadcast.BREADTH, new ConnConfModEvent(target, connConfProperties));
                        }
                    });

                    field.setNewModel(property.getValues());
                    item.add(field);
                }

                resourceTO.getConnConfProperties().add(property);
            }
View Full Code Here

                item.add(new Label("name", templateMode
                        ? attributeTO.getSchema() + " (JEXL)"
                        : attributeTO.getSchema()));

                final FieldPanel panel =
                        getFieldPanel(schemas.getObject().get(attributeTO.getSchema()), form, attributeTO);

                if (templateMode || !schemas.getObject().get(attributeTO.getSchema()).isMultivalue()) {
                    item.add(panel);
                } else {
View Full Code Here

        return entityData;
    }

    private FieldPanel getFieldPanel(final SchemaTO schemaTO, final Form form, final AttributeTO attributeTO) {

        final FieldPanel panel;

        final boolean required = templateMode ? false : schemaTO.getMandatoryCondition().equalsIgnoreCase("true");

        final boolean readOnly = templateMode ? false : schemaTO.isReadonly();

        final SchemaType type = templateMode ? SchemaType.String : schemaTO.getType();

        switch (type) {
            case Boolean:
                panel = new AjaxCheckBoxPanel("panel", schemaTO.getName(), new Model());
                panel.setRequired(required);
                break;

            case Date:
                final String dataPattern = schemaTO.getConversionPattern() != null
                        ? schemaTO.getConversionPattern()
                        : SyncopeConstants.DEFAULT_DATE_PATTERN;

                if (!dataPattern.contains("H")) {
                    panel = new DateTextFieldPanel("panel", schemaTO.getName(), new Model(), dataPattern);

                    if (required) {
                        panel.addRequiredLabel();
                    }
                } else {
                    panel = new DateTimeFieldPanel("panel", schemaTO.getName(), new Model(), dataPattern);

                    if (required) {
                        panel.addRequiredLabel();
                        ((DateTimeFieldPanel) panel).setFormValidator(form);
                    }
                    panel.setStyleShet("ui-widget-content ui-corner-all");
                }
                break;

            case Enum:
                panel = new AjaxDropDownChoicePanel<String>("panel", schemaTO.getName(), new Model());
                ((AjaxDropDownChoicePanel) panel).setChoices(getEnumeratedValues(schemaTO));

                if (StringUtils.isNotBlank(schemaTO.getEnumerationKeys())) {
                    ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                        final Map<String, String> valueMap = 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, int i) {
                            return value;
                        }
                    });
                }

                if (required) {
                    panel.addRequiredLabel();
                }

                break;

            default:
                panel = new AjaxTextFieldPanel("panel", schemaTO.getName(), new Model());
                if (required) {
                    panel.addRequiredLabel();
                }
        }

        panel.setReadOnly(readOnly);
        panel.setNewModel(attributeTO.getValues());

        return panel;
    }
View Full Code Here

                        target.add(intAttrNames.getField());

                    }
                });

                final FieldPanel extAttrName;

                if (schemaNames.isEmpty()) {
                    extAttrName = new AjaxTextFieldPanel("extAttrName", new ResourceModel("extAttrNames",
                            "extAttrNames").getObject(), new PropertyModel<String>(mappingTO, "extAttrName"));

                } else {
                    extAttrName = new AjaxDropDownChoicePanel<String>("extAttrName", new ResourceModel("extAttrNames",
                            "extAttrNames").getObject(), new PropertyModel(mappingTO, "extAttrName"));
                    ((AjaxDropDownChoicePanel) extAttrName).setChoices(schemaNames);
                }

                boolean required = false;
                if (mappingTO != null && !mappingTO.isAccountid() && !mappingTO.isPassword()) {
                    required = true;
                }
               

                extAttrName.setRequired(required);
                extAttrName.setEnabled(required);

                extAttrName.setStyleShet(fieldStyle);
                item.add(extAttrName);

                final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel("mandatoryCondition", new ResourceModel(
                        "mandatoryCondition", "mandatoryCondition").getObject(), new PropertyModel(mappingTO,
                        "mandatoryCondition"));

                mandatory.setChoices(Arrays.asList(new String[]{"true", "false"}));

                mandatory.setStyleShet(shortFieldStyle);

                item.add(mandatory);

                final AjaxCheckBoxPanel accountId = new AjaxCheckBoxPanel("accountId", new ResourceModel("accountId",
                        "accountId").getObject(), new PropertyModel(mappingTO, "accountid"));

                accountId.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

                    private static final long serialVersionUID = -1107858522700306810L;

                    @Override
                    protected void onUpdate(final AjaxRequestTarget target) {
                        extAttrName.setEnabled(!accountId.getModelObject() && !mappingTO.isPassword());
                        extAttrName.setModelObject(null);
                        extAttrName.setRequired(!accountId.getModelObject());
                        target.add(extAttrName);
                    }
                });

                item.add(accountId);

                final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel("password", new ResourceModel("password",
                        "password").getObject(), new PropertyModel(mappingTO, "password"));

                password.getField().add(new AjaxFormComponentUpdatingBehavior(onchange) {

                    private static final long serialVersionUID = -1107858522700306810L;

                    @Override
                    protected void onUpdate(final AjaxRequestTarget target) {
                        extAttrName.setEnabled(!mappingTO.isAccountid() && !password.getModelObject());
                        extAttrName.setModelObject(null);
                        extAttrName.setRequired(!password.getModelObject());
                        target.add(extAttrName);

                        setAccountId((IntMappingType) typesPanel.getModelObject(), accountId, password);
                        target.add(accountId);
                    }
View Full Code Here

        super(id);

        // ------------------------
        // Username
        // ------------------------
        final FieldPanel username = new AjaxTextFieldPanel("username", "username", new PropertyModel<String>(userTO,
                "username"));
        if (!templateMode) {
            username.addRequiredLabel();
        }
        add(username);
        // ------------------------

        // ------------------------
        // Password
        // ------------------------
        final FieldPanel password;
        final Label confirmPasswordLabel = new Label("confirmPasswordLabel", new ResourceModel("confirmPassword"));
        final FieldPanel confirmPassword;
        if (templateMode) {
            password = new AjaxTextFieldPanel("password", "password", new PropertyModel<String>(userTO, "password"));

            confirmPasswordLabel.setVisible(false);
            confirmPassword = new AjaxTextFieldPanel("confirmPassword", "confirmPassword", new Model<String>());
            confirmPassword.setEnabled(false);
            confirmPassword.setVisible(false);
        } else {
            password = new AjaxPasswordFieldPanel("password", "password", new PropertyModel<String>(userTO, "password"));
            password.setRequired(userTO.getId() == 0);
            ((PasswordTextField) password.getField()).setResetPassword(resetPassword);

            confirmPassword = new AjaxPasswordFieldPanel("confirmPassword", "confirmPassword", new Model<String>());
            if (!resetPassword) {
                confirmPassword.getField().setModelObject(userTO.getPassword());
            }
            confirmPassword.setRequired(userTO.getId() == 0);
            ((PasswordTextField) confirmPassword.getField()).setResetPassword(resetPassword);

            form.add(new EqualPasswordInputValidator(password.getField(), confirmPassword.getField()));
        }
        add(password);
        add(confirmPasswordLabel);
        add(confirmPassword);
View Full Code Here

                Label label = new Label("key", prop.getName() == null
                        ? prop.getId()
                        : prop.getName());
                item.add(label);

                FieldPanel field;
                switch (prop.getType()) {
                    case Boolean:
                        field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(),
                                new Model(Boolean.valueOf(prop.getValue()))).setChoices(Arrays.asList(
                                new String[]{"Yes", "No"}));
                        break;

                    case Date:
                        SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern())
                                ? new SimpleDateFormat(prop.getDatePattern())
                                : new SimpleDateFormat();
                        Date parsedDate = null;
                        if (StringUtils.isNotBlank(prop.getValue())) {
                            try {
                                parsedDate = df.parse(prop.getValue());
                            } catch (ParseException e) {
                                LOG.error("Unparsable date: {}", prop.getValue(), e);
                            }
                        }

                        field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(), new Model(
                                parsedDate), df.toLocalizedPattern());
                        break;

                    case Enum:
                        MapChoiceRenderer<String, String> enumCR =
                                new MapChoiceRenderer<String, String>(prop.getEnumValues());

                        field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(),
                                new Model(prop.getValue())).setChoiceRenderer(enumCR).setChoices(new Model() {

                            private static final long serialVersionUID = -858521070366432018L;

                            @Override
                            public Serializable getObject() {
                                return new ArrayList(prop.getEnumValues().keySet());
                            }
                        });
                        break;

                    case Long:
                        field = new AjaxNumberFieldPanel("value", label.getDefaultModelObjectAsString(),
                                new Model(Long.valueOf(prop.getValue())), Long.class);
                        break;

                    case String:
                    default:
                        field = new AjaxTextFieldPanel("value", PARENT_PATH, new Model(prop.getValue()));
                        break;
                }

                field.setReadOnly(!prop.isWritable());
                if (prop.isRequired()) {
                    field.addRequiredLabel();
                }

                item.add(field);
            }
        };
View Full Code Here

                            item.add(component);

                            item.add(getActivationControl(component, !((List) classMethod.invoke(policy,
                                    new Object[]{})).isEmpty(), new ArrayList<String>(), new ArrayList<String>()));
                        } else {
                            final FieldPanel panel = new AjaxTextFieldPanel("panel", field.getName(), new Model(null));

                            panel.setRequired(true);

                            component = new MultiValueSelectorPanel<String>("field", new PropertyModel(policy, field.
                                    getName()), panel);

                            item.add(component);
View Full Code Here

                        ? property.getSchema().getName()
                        : property.getSchema().getDisplayName());

                item.add(label);

                final FieldPanel field;

                boolean required = false;

                boolean isArray = false;

                if (GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())
                        || GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {

                    field = new AjaxPasswordFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model());

                    ((PasswordTextField) field.getField()).setResetPassword(false);

                    required = property.getSchema().isRequired();

                } else {
                    Class propertySchemaClass;

                    try {
                        propertySchemaClass = ClassUtils.forName(property.getSchema().getType(), ClassUtils
                                .getDefaultClassLoader());
                    } catch (Exception e) {
                        LOG.error("Error parsing attribute type", e);
                        propertySchemaClass = String.class;
                    }

                    if (NUMBER.contains(propertySchemaClass)) {
                        field = new AjaxNumberFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model(),
                                ClassUtils.resolvePrimitiveIfNecessary(propertySchemaClass));

                        required = property.getSchema().isRequired();
                    } else if (Boolean.class.equals(propertySchemaClass) || boolean.class.equals(propertySchemaClass)) {
                        field = new AjaxCheckBoxPanel("panel", label.getDefaultModelObjectAsString(), new Model());
                    } else {
                        field = new AjaxTextFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model());

                        required = property.getSchema().isRequired();
                    }

                    if (String[].class.equals(propertySchemaClass)) {
                        isArray = true;
                    }
                }

                field.setTitle(property.getSchema().getHelpMessage());

                if (isArray) {
                    field.removeRequiredLabel();

                    if (property.getValues().isEmpty()) {
                        property.getValues().add(null);
                    }

                    item.add(new MultiValueSelectorPanel<String>("panel", new PropertyModel<List<String>>(property,
                            "values"), field));
                } else {
                    if (required) {
                        field.addRequiredLabel();
                    }

                    field.setNewModel(property.getValues());
                    item.add(field);
                }

                final AjaxCheckBoxPanel overridable = new AjaxCheckBoxPanel("connPropAttrOverridable",
                        "connPropAttrOverridable", new PropertyModel(property, "overridable"));
View Full Code Here

TOP

Related Classes of org.apache.syncope.console.wicket.markup.html.form.FieldPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.