Search in sources :

Example 1 with IAttribute

use of org.jowidgets.cap.ui.api.attribute.IAttribute in project jo-client-platform by jo-source.

the class AttributesFactory method createAttributes.

List<IAttribute<Object>> createAttributes(final Collection<? extends IProperty> properties, final IAttributeCollectionModifier attributeCollectionModifier) {
    Assert.paramNotNull(properties, "properties");
    final List<IAttribute<Object>> result = new LinkedList<IAttribute<Object>>();
    for (final IProperty property : properties) {
        final AttributeBuilderImpl<Object> attributeBuilder = new AttributeBuilderImpl<Object>(property);
        if (attributeCollectionModifier != null) {
            final IAttribute<Object> attribute = applyCollectionModifier(property, attributeBuilder, attributeCollectionModifier);
            if (attribute != null) {
                result.add(attribute);
            }
        } else {
            result.add(attributeBuilder.build());
        }
    }
    return result;
}
Also used : IProperty(org.jowidgets.cap.common.api.bean.IProperty) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) LinkedList(java.util.LinkedList)

Example 2 with IAttribute

use of org.jowidgets.cap.ui.api.attribute.IAttribute in project jo-client-platform by jo-source.

the class BeanTableModelImpl method createModifiedByPluginsAttributes.

private List<IAttribute<Object>> createModifiedByPluginsAttributes(final Object entityId, final Class<BEAN_TYPE> beanType, final List<IAttribute<Object>> attributes) {
    List<IAttribute<Object>> result = attributes;
    IPluginPropertiesBuilder propBuilder = PluginToolkit.pluginPropertiesBuilder();
    propBuilder.add(IAttributePlugin.ENTITIY_ID_PROPERTY_KEY, entityId);
    propBuilder.add(IAttributePlugin.BEAN_TYPE_PROPERTY_KEY, beanType);
    IPluginProperties properties = propBuilder.build();
    for (final IAttributePlugin plugin : PluginProvider.getPlugins(IAttributePlugin.ID, properties)) {
        result = plugin.modifyAttributes(properties, result);
    }
    propBuilder = PluginToolkit.pluginPropertiesBuilder();
    propBuilder.add(IBeanTableModelPlugin.ENTITIY_ID_PROPERTY_KEY, entityId);
    propBuilder.add(IBeanTableModelPlugin.BEAN_TYPE_PROPERTY_KEY, beanType);
    properties = propBuilder.build();
    for (final IBeanTableModelPlugin plugin : PluginProvider.getPlugins(IBeanTableModelPlugin.ID, properties)) {
        result = plugin.modifyTableAttributes(properties, result);
    }
    return result;
}
Also used : IPluginProperties(org.jowidgets.plugin.api.IPluginProperties) IPluginPropertiesBuilder(org.jowidgets.plugin.api.IPluginPropertiesBuilder) IAttributePlugin(org.jowidgets.cap.ui.api.plugin.IAttributePlugin) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) IBeanTableModelPlugin(org.jowidgets.cap.ui.api.plugin.IBeanTableModelPlugin)

Example 3 with IAttribute

use of org.jowidgets.cap.ui.api.attribute.IAttribute in project jo-client-platform by jo-source.

the class CreatorActionBuilderImpl method buildAction.

private IAction buildAction() {
    final IBeanFormBluePrint<BEAN_TYPE> formBp = getBeanFormBp();
    Collection<IAttribute<?>> attr = attributes;
    if (attr == null && formBp != null) {
        attr = formBp.getCreateModeAttributes();
    }
    final BeanCreatorCommand<BEAN_TYPE> command = new BeanCreatorCommand<BEAN_TYPE>(beanTypeId, beanType, beanPropertyValidators, model, attr, formBp, enabledCheckers, anySelection, creatorService, parentBeanKeysProvider, getDefaultValueProvider(attr), exceptionConverter, executionInterceptors, creatorInterceptors);
    final IActionBuilder builder = getBuilder();
    if (model instanceof IDataModelContextProvider) {
        builder.setCommand(new DataModelContextCommandWrapper((IDataModelContextProvider) model, DataModelChangeType.SELECTION_CHANGE, command));
    } else {
        builder.setCommand((ICommand) command);
    }
    return builder.build();
}
Also used : IDataModelContextProvider(org.jowidgets.cap.ui.api.model.IDataModelContextProvider) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) DataModelContextCommandWrapper(org.jowidgets.cap.ui.tools.command.DataModelContextCommandWrapper) IActionBuilder(org.jowidgets.api.command.IActionBuilder)

Example 4 with IAttribute

use of org.jowidgets.cap.ui.api.attribute.IAttribute in project jo-client-platform by jo-source.

the class BeanLinkCreatorCommand method createDefaultBean.

private <BEAN_TYPE> IBeanProxy<BEAN_TYPE> createDefaultBean(final IBeanFormBluePrint<BEAN_TYPE> formBp, final Object beanTypeId, final Class<? extends BEAN_TYPE> beanType, final List<IBeanPropertyValidator<BEAN_TYPE>> validators) {
    if (formBp != null) {
        final HashMap<String, Object> defaultValues = new HashMap<String, Object>();
        final LinkedList<String> properties = new LinkedList<String>();
        final Collection<IAttribute<?>> attributes = formBp.getCreateModeAttributes();
        final IAttributeSet attributeSet = AttributeSet.create(attributes);
        for (final IAttribute<?> attribute : attributes) {
            final String propertyName = attribute.getPropertyName();
            properties.add(propertyName);
            final Object defaultValue = attribute.getDefaultValue();
            if (defaultValue != null) {
                defaultValues.put(propertyName, defaultValue);
            }
        }
        final List<IBeanPropertyValidator<BEAN_TYPE>> propertyValidators = createBeanPropertyValidators(attributes);
        if (!EmptyCheck.isEmpty(validators)) {
            propertyValidators.addAll(validators);
        }
        @SuppressWarnings("unchecked") final IBeanProxyFactory<BEAN_TYPE> proxyFactory = BeanProxyFactory.builder((Class<BEAN_TYPE>) beanType).setBeanTypeId(beanTypeId).setAttributes(attributeSet).setBeanPropertyValidators(propertyValidators).build();
        return proxyFactory.createTransientProxy(defaultValues);
    } else {
        return null;
    }
}
Also used : HashMap(java.util.HashMap) IBeanPropertyValidator(org.jowidgets.cap.ui.api.bean.IBeanPropertyValidator) LinkedList(java.util.LinkedList) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) IAttributeSet(org.jowidgets.cap.ui.api.attribute.IAttributeSet)

Example 5 with IAttribute

use of org.jowidgets.cap.ui.api.attribute.IAttribute in project jo-client-platform by jo-source.

the class BeanTabFolderModelImpl method createModifiedByPluginsAttributes.

private List<IAttribute<Object>> createModifiedByPluginsAttributes(final Object entityId, final Class<BEAN_TYPE> beanType, final List<IAttribute<Object>> attributes) {
    List<IAttribute<Object>> result = attributes;
    final IPluginPropertiesBuilder propBuilder = PluginToolkit.pluginPropertiesBuilder();
    propBuilder.add(IAttributePlugin.ENTITIY_ID_PROPERTY_KEY, entityId);
    propBuilder.add(IAttributePlugin.BEAN_TYPE_PROPERTY_KEY, beanType);
    final IPluginProperties properties = propBuilder.build();
    for (final IAttributePlugin plugin : PluginProvider.getPlugins(IAttributePlugin.ID, properties)) {
        result = plugin.modifyAttributes(properties, result);
    }
    return result;
}
Also used : IPluginProperties(org.jowidgets.plugin.api.IPluginProperties) IPluginPropertiesBuilder(org.jowidgets.plugin.api.IPluginPropertiesBuilder) IAttributePlugin(org.jowidgets.cap.ui.api.plugin.IAttributePlugin) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute)

Aggregations

IAttribute (org.jowidgets.cap.ui.api.attribute.IAttribute)8 IAttributePlugin (org.jowidgets.cap.ui.api.plugin.IAttributePlugin)3 IPluginProperties (org.jowidgets.plugin.api.IPluginProperties)3 IPluginPropertiesBuilder (org.jowidgets.plugin.api.IPluginPropertiesBuilder)3 LinkedList (java.util.LinkedList)2 IAttributeSet (org.jowidgets.cap.ui.api.attribute.IAttributeSet)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IActionBuilder (org.jowidgets.api.command.IActionBuilder)1 ICommandAction (org.jowidgets.api.command.ICommandAction)1 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)1 IProperty (org.jowidgets.cap.common.api.bean.IProperty)1 IBeanPropertyValidator (org.jowidgets.cap.ui.api.bean.IBeanPropertyValidator)1 IDataModelContextProvider (org.jowidgets.cap.ui.api.model.IDataModelContextProvider)1 IBeanTableModelPlugin (org.jowidgets.cap.ui.api.plugin.IBeanTableModelPlugin)1 IBeanTableModel (org.jowidgets.cap.ui.api.table.IBeanTableModel)1 DataModelContextCommandWrapper (org.jowidgets.cap.ui.tools.command.DataModelContextCommandWrapper)1 ITableCellPopupEvent (org.jowidgets.common.widgets.controller.ITableCellPopupEvent)1