Search in sources :

Example 1 with IImageConstant

use of org.jowidgets.common.image.IImageConstant in project jo-client-platform by jo-source.

the class BeanRelationTreeImpl method createDeleterAction.

private IAction createDeleterAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel) {
    if (!defaultDeleterAction) {
        return null;
    }
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
        final Object childEntityId = relationNodeModel.getChildEntityId();
        final IBeanServicesProvider beanServices = entityService.getBeanServices(childEntityId);
        if (beanServices != null) {
            final IDeleterService deleterService = beanServices.deleterService();
            if (deleterService != null) {
                IDeleterActionBuilder<Object> builder = actionFactory.deleterActionBuilder(relationNodeModel);
                builder.setDeleterService(deleterService);
                builder.setMultiSelectionPolicy(false);
                if (autoKeyBinding) {
                    builder.setAccelerator(VirtualKey.DELETE, Modifier.ALT);
                } else {
                    builder.setAccelerator(null);
                }
                final IBeanDtoDescriptor descriptor = entityService.getDescriptor(childEntityId);
                if (descriptor != null) {
                    builder.setEntityLabelPlural(descriptor.getLabelPlural().get());
                    builder.setEntityLabelSingular(descriptor.getLabelSingular().get());
                    final Object icon = descriptor.getDeleteIconDescriptor();
                    if (icon != null) {
                        final IImageConstant imageConstant = ImageResolver.resolve(icon);
                        if (imageConstant != null) {
                            builder.setIcon(imageConstant);
                        }
                    }
                }
                if (menuInterceptor != null) {
                    builder = menuInterceptor.deleterActionBuilder(relationNodeModel, builder);
                }
                if (builder != null) {
                    return builder.build();
                }
            }
        }
    }
    return null;
}
Also used : IImageConstant(org.jowidgets.common.image.IImageConstant) IBeanServicesProvider(org.jowidgets.cap.common.api.service.IBeanServicesProvider) IDeleterService(org.jowidgets.cap.common.api.service.IDeleterService) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 2 with IImageConstant

use of org.jowidgets.common.image.IImageConstant in project jo-client-platform by jo-source.

the class BeanRelationGraphImpl method renderIcon.

private void renderIcon(final Node node, final IBeanProxy<Object> bean, final IBeanProxyLabelRenderer<Object> renderer) {
    final IImageConstant icon = renderer.getLabel(bean).getIcon();
    if (icon != null) {
        final IImageHandle imageHandle = Toolkit.getImageRegistry().getImageHandle(icon);
        if (imageHandle != null) {
            final Object image = imageHandle.getImage();
            final IImageDescriptor imageDescriptor = imageHandle.getImageDescriptor();
            if (image instanceof Image) {
                renderIcon(node, (Image) image);
            } else if (imageDescriptor != null) {
                IImageHandle awtImageHandle = SwingImageRegistry.getInstance().getImageHandle(icon);
                if (awtImageHandle == null) {
                    SwingImageRegistry.getInstance().registerImageConstant(icon, imageDescriptor);
                    awtImageHandle = SwingImageRegistry.getInstance().getImageHandle(icon);
                }
                renderIcon(node, (Image) awtImageHandle.getImage());
            }
        }
    }
}
Also used : IImageHandle(org.jowidgets.common.image.IImageHandle) IImageConstant(org.jowidgets.common.image.IImageConstant) IImageDescriptor(org.jowidgets.common.image.IImageDescriptor) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage)

Example 3 with IImageConstant

use of org.jowidgets.common.image.IImageConstant in project jo-client-platform by jo-source.

the class NodeRenderer method initializeIcons.

private Image initializeIcons(final IImageConstant iconImage) {
    final IImageConstant icon = iconImage;
    if (icon != null) {
        final IImageHandle imageHandle = Toolkit.getImageRegistry().getImageHandle(icon);
        if (imageHandle != null) {
            final Object image = imageHandle.getImage();
            final IImageDescriptor imageDescriptor = imageHandle.getImageDescriptor();
            if (image instanceof Image) {
                return (Image) image;
            } else if (imageDescriptor != null) {
                IImageHandle awtImageHandle = SwingImageRegistry.getInstance().getImageHandle(icon);
                if (awtImageHandle == null) {
                    SwingImageRegistry.getInstance().registerImageConstant(icon, imageDescriptor);
                    awtImageHandle = SwingImageRegistry.getInstance().getImageHandle(icon);
                }
                return (Image) awtImageHandle.getImage();
            }
        }
    }
    return null;
}
Also used : IImageHandle(org.jowidgets.common.image.IImageHandle) IImageConstant(org.jowidgets.common.image.IImageConstant) IImageDescriptor(org.jowidgets.common.image.IImageDescriptor) Image(java.awt.Image)

Example 4 with IImageConstant

use of org.jowidgets.common.image.IImageConstant in project jo-client-platform by jo-source.

the class BeanTableDeleterActionBuilderFactory method createBuilder.

static <BEAN_TYPE> IDeleterActionBuilder<BEAN_TYPE> createBuilder(final IBeanTable<BEAN_TYPE> table) {
    final IBeanTableModel<BEAN_TYPE> model = table.getModel();
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IDeleterActionBuilder<BEAN_TYPE> builder = actionFactory.deleterActionBuilder(model);
    builder.setEntityLabelSingular(model.getEntityLabelSingular());
    builder.setEntityLabelPlural(model.getEntityLabelPlural());
    builder.setDeleterService(model.getDeleterService());
    final Object entityId = model.getEntityId();
    if (entityId != null) {
        final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
        if (entityService != null) {
            final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityId);
            if (descriptor != null) {
                final Object icon = descriptor.getDeleteIconDescriptor();
                if (icon != null) {
                    final IImageConstant imageConstant = ImageResolver.resolve(icon);
                    if (imageConstant != null) {
                        builder.setIcon(imageConstant);
                    }
                }
            }
        }
    }
    return builder;
}
Also used : IImageConstant(org.jowidgets.common.image.IImageConstant) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Aggregations

IImageConstant (org.jowidgets.common.image.IImageConstant)4 Image (java.awt.Image)2 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)2 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)2 ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)2 IImageDescriptor (org.jowidgets.common.image.IImageDescriptor)2 IImageHandle (org.jowidgets.common.image.IImageHandle)2 BufferedImage (java.awt.image.BufferedImage)1 IBeanServicesProvider (org.jowidgets.cap.common.api.service.IBeanServicesProvider)1 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1