Search in sources :

Example 6 with IAttribute

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

the class SingleBeanModelImpl 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)

Example 7 with IAttribute

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

the class BeanTableSetToAllActionBuilder method build.

@Override
public ICommandAction build() {
    final ICommandAction result = super.build();
    table.addCellMenuListener(new IPopupMenuListener<ITableCellPopupEvent>() {

        @Override
        public void beforeMenuShow(final ITableCellPopupEvent event) {
            final int columnIndex = event.getColumnIndex();
            final int rowIndex = event.getRowIndex();
            final IBeanTableModel<?> model = table.getModel();
            final String entityLabelPlural = model.getEntityLabelPlural();
            final Object cellValue = model.getValue(rowIndex, columnIndex);
            final String cellText;
            if (cellValue != null) {
                cellText = StringUtils.truncateToLength(model.getTableModel().getCell(rowIndex, columnIndex).getText(), 30);
            } else {
                cellText = NOT_SET.get();
            }
            final IAttribute<Object> attribute = model.getAttribute(columnIndex);
            final String columnLabel = attribute.getLabel().get();
            final ArrayList<Integer> selection = model.getSelection();
            if (selection.size() > 1) {
                // set to selection
                result.setText(MessageReplacer.replace(SET_TO_SELECTION.get(), columnLabel, cellText, entityLabelPlural));
            } else if (selection.size() <= 1) {
                // set to all
                result.setText(MessageReplacer.replace(SET_TO_ALL.get(), columnLabel, cellText, entityLabelPlural));
            }
        }
    });
    return result;
}
Also used : ICommandAction(org.jowidgets.api.command.ICommandAction) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) ArrayList(java.util.ArrayList) ITableCellPopupEvent(org.jowidgets.common.widgets.controller.ITableCellPopupEvent) IBeanTableModel(org.jowidgets.cap.ui.api.table.IBeanTableModel)

Example 8 with IAttribute

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

the class BeanProxyFactoryBuilderImpl method configureFromEntityService.

@Override
public IBeanProxyFactoryBuilder<BEAN_TYPE> configureFromEntityService(final Object entityId) {
    final IBeanDtoDescriptor dtoDescriptor = EntityServiceHelper.getDtoDescriptor(entityId);
    final List<IAttribute<Object>> entityAttributes = EntityServiceHelper.createAttributes(entityId);
    if (dtoDescriptor != null && entityAttributes != null) {
        final Class<?> descritporBeanType = dtoDescriptor.getBeanType();
        if (descritporBeanType == null || !descritporBeanType.isAssignableFrom(beanType)) {
            throw new IllegalArgumentException("The entity id '" + entityId + "' has a bean type '" + descritporBeanType + "' that is not compatible with the bean type '" + beanType + "' of this builder");
        }
        setBeanTypeId(dtoDescriptor.getBeanTypeId());
        final IAttributeSet attributeSet = AttributeSet.create(entityAttributes);
        setAttributes(attributeSet);
        addValidators(dtoDescriptor, attributeSet);
        setDefaultValuesForTransientBeans(attributeSet);
    } else {
        throw new IllegalArgumentException("TFor the entity id '" + entityId + "' no descriptor or attributes was found");
    }
    return this;
}
Also used : IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) IAttributeSet(org.jowidgets.cap.ui.api.attribute.IAttributeSet)

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