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

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


        };
        form.add(submit);
    }

    private FieldPanel buildSinglePanel(final Class<?> type, final String fieldName, final String id) {
        FieldPanel result = null;
        PropertyModel model = new PropertyModel(ReportletConfModalPage.this.reportletConf, fieldName);
        if (Boolean.TYPE.equals(type) || Boolean.class.equals(type)) {
            result = new AjaxCheckBoxPanel(id, fieldName, model);
        } else if (Integer.TYPE.equals(type) || Integer.class.equals(type) || Long.TYPE.equals(type)
                || Long.class.equals(type) || Double.TYPE.equals(type) || Double.class.equals(type)) {
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>(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<Date>(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<String>(prop.getEnumValues().keySet());
                                    }
                                });
                                break;

                            case Long:
                                field = new SpinnerFieldPanel<Long>("value", label.getDefaultModelObjectAsString(),
                                        Long.class, new Model<Long>(NumberUtils.toLong(prop.getValue())),
                                        null, null);
                                break;

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

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

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

                            questionMarkJexlHelp.setVisible(false);
                        }

                        item.add(new Label("name", attributeTO.getSchema()));

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

                        if (templateMode || !schemas.get(attributeTO.getSchema()).isMultivalue()) {
                            item.add(panel);
                        } else {
                            item.add(new MultiFieldPanel<String>(
View Full Code Here

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

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

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

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

                if (dataPattern.contains("H")) {
                    panel = new DateTimeFieldPanel("panel", schemaTO.getName(), new Model<Date>(), dataPattern);

                    if (required) {
                        panel.addRequiredLabel();
                        ((DateTimeFieldPanel) panel).setFormValidator(form);
                    }
                    panel.setStyleSheet("ui-widget-content ui-corner-all");
                } else {
                    panel = new DateTextFieldPanel("panel", schemaTO.getName(), new Model<Date>(), dataPattern);

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

            case Enum:
                panel = new AjaxDropDownChoicePanel<String>("panel", schemaTO.getName(), new Model<String>());
                ((AjaxDropDownChoicePanel<String>) panel).setChoices(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 = 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;
                        }
                    });
                }

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

            case Long:
                panel = new SpinnerFieldPanel<Long>("panel", schemaTO.getName(),
                        Long.class, new Model<Long>(), null, null);

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

            case Double:
                panel = new SpinnerFieldPanel<Double>("panel", schemaTO.getName(),
                        Double.class, new Model<Double>(), null, null);

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

            case Binary:
                panel = new BinaryFieldPanel("panel", schemaTO.getName(), new Model<String>(),
                        schemas.containsKey(schemaTO.getName())
                        ? schemas.get(schemaTO.getName()).getMimeType()
                        : null);

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

            default:
                panel = new AjaxTextFieldPanel("panel", schemaTO.getName(), new Model<String>());

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

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

        return panel;
    }
View Full Code Here

                            Collection<?> collection = (Collection) propDesc.getReadMethod().invoke(policy);
                            item.add(getActivationControl(component,
                                    !collection.isEmpty(), new ArrayList<String>(), new ArrayList<String>()));
                        } else {
                            final FieldPanel panel = new AjaxTextFieldPanel("panel", field.getName(),
                                    new Model<String>(null));
                            panel.setRequired(true);

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

                            item.add(component);
View Full Code Here

        form.add(cancel);
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    private FieldPanel buildSinglePanel(final Class<?> type, final String fieldName, final String id) {
        FieldPanel result = null;
        PropertyModel model = new PropertyModel(ReportletConfModalPage.this.reportletConf, fieldName);
        if (ClassUtils.isAssignable(Boolean.class, type)) {
            result = new AjaxCheckBoxPanel(id, fieldName, model);
        } else if (ClassUtils.isAssignable(Number.class, type)) {
            result = new SpinnerFieldPanel<Number>(id, fieldName, (Class<Number>) type, model, null, null);
View Full Code Here

                                StringUtils.isBlank(property.getSchema().getDisplayName())
                                ? property.getSchema().getName()
                                : property.getSchema().getDisplayName());
                        item.add(label);

                        @SuppressWarnings("rawtypes")
                        final FieldPanel field;
                        boolean required = false;
                        boolean isArray = false;
                        if (property.getSchema().isConfidential()
                        || Constants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())
                        || Constants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {

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

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

                            required = property.getSchema().isRequired();
                        } else {
                            Class<?> propertySchemaClass;

                            try {
                                propertySchemaClass =
                                ClassUtils.forName(property.getSchema().getType(), ClassUtils.getDefaultClassLoader());
                                if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) {
                                    propertySchemaClass =
                                    org.apache.commons.lang3.ClassUtils.primitiveToWrapper(propertySchemaClass);
                                }
                            } catch (Exception e) {
                                LOG.error("Error parsing attribute type", e);
                                propertySchemaClass = String.class;
                            }
                            if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) {
                                @SuppressWarnings("unchecked")
                                final Class<Number> numberClass = (Class<Number>) propertySchemaClass;
                                field = new SpinnerFieldPanel<Number>("panel", label.getDefaultModelObjectAsString(),
                                        numberClass, new Model<Number>(), null, null);

                                required = property.getSchema().isRequired();
                            } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) {
                                field = new AjaxCheckBoxPanel("panel",
                                        label.getDefaultModelObjectAsString(), new Model<Boolean>());
                            } else {
                                field = new AjaxTextFieldPanel("panel",
                                        label.getDefaultModelObjectAsString(), new Model<String>());

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

                            if (propertySchemaClass.isArray()) {
                                isArray = true;
                            }
                        }

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

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

                        if (isArray) {
                            if (property.getValues().isEmpty()) {
                                property.getValues().add(null);
View Full Code Here

        };
        form.add(submit);
    }

    private FieldPanel buildSinglePanel(final Class<?> type, final String fieldName, final String id) {
        FieldPanel result = null;
        PropertyModel model = new PropertyModel(ReportletConfModalPage.this.reportletConf, fieldName);
        if (Boolean.TYPE.equals(type) || Boolean.class.equals(type)) {
            result = new AjaxCheckBoxPanel(id, fieldName, model);
        } else if (Integer.TYPE.equals(type) || Integer.class.equals(type) || Long.TYPE.equals(type)
                || Long.class.equals(type) || Double.TYPE.equals(type) || Double.class.equals(type)) {
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.