Package org.openengsb.core.api.descriptor.AttributeDefinition

Examples of org.openengsb.core.api.descriptor.AttributeDefinition.Builder


        when(mock2.getKey()).thenReturn("123");
        when(mock3.getString(Locale.getDefault())).thenReturn("TWO");
        when(mock.getString("ONE")).thenReturn(mock2);
        when(mock.getString("TWO")).thenReturn(mock2);

        Builder builder = AttributeDefinition.builder(mock);
        builder.name("ONE").id("123");
        MethodUtil.addEnumValues(TestEnum.class, builder);
        AttributeDefinition build = builder.build();
        List<Option> options = build.getOptions();
        Option option0 = options.get(0);
        assertThat(option0.getLabel().getString(Locale.getDefault()), equalTo(TestEnum.ONE.toString()));
        assertThat(option0.getValue().toString(), equalTo(TestEnum.ONE.toString()));
        Option option1 = options.get(1);
View Full Code Here


    public MethodArgumentPanel(String id, final Argument arg) {
        super(id);
        add(new Label("index", String.format("Argument #%d", arg.getIndex())));
        Class<?> type = arg.getType();
        if (type.isPrimitive() || type.isEnum() || hasStringOnlyConstructor(type)) {
            Builder builder = AttributeDefinition.builder(new PassThroughStringLocalizer());
            MethodUtil.addEnumValues(type, builder);
            builder.id("value").name("value");
            if (type.equals(boolean.class) || type.equals(Boolean.class)) {
                builder.asBoolean();
            }
            AbstractField<?> field = AttributeEditorUtil.createEditorField("valueEditor", new IModel<String>() {
                @Override
                public void detach() {
                    // not required
                }

                @Override
                public void setObject(String object) {
                    arg.setValue(object);
                }

                @Override
                public String getObject() {
                    return arg.getValue() != null ? arg.getValue().toString() : null;
                }
            }, builder.build());
            add(field);
        } else {
            Map<String, String> beanAttrs = new HashMap<String, String>();
            arg.setValue(beanAttrs);
            arg.setBean(true);
View Full Code Here

                if (propertyDescriptor.getWriteMethod() == null
                        || !Modifier.isPublic(propertyDescriptor.getWriteMethod().getModifiers())
                        || propertyDescriptor.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
                    continue;
                }
                Builder builder =
                    AttributeDefinition.builder(new PassThroughStringLocalizer()).id(propertyDescriptor.getName())
                        .name(propertyDescriptor.getDisplayName())
                        .description(propertyDescriptor.getShortDescription());
                addEnumValues(propertyDescriptor.getPropertyType(), builder);
                AttributeDefinition a = builder.build();
                attributes.add(a);
            }
        } catch (IntrospectionException ex) {
            LOGGER.error("building attribute list failed", ex);
        }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.descriptor.AttributeDefinition.Builder

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.