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;
}
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());
}
}
}
}
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;
}
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;
}
Aggregations