/** * Configures the descriptor of the entities that are to be added by the * action to the underlying model collection. Setting this property serves * multiple objectives : * <ul> * <li>complete the application context with the * {@code AddComponentCollectionToMasterAction.ELEMENT_DESCRIPTOR} key so * that the chained backend action knows what type of entity to create.</li> * <li>customize the name, description and icon used to represent the action * in the UI. All three are derived from the configured element entity * descriptor.</li> * </ul> * * @param elementEntityDescriptor * the elementEntityDescriptor to set. */ public void setElementEntityDescriptor( IComponentDescriptor<IEntity> elementEntityDescriptor) { this.elementEntityDescriptor = elementEntityDescriptor; if (elementEntityDescriptor != null) { setIcon(elementEntityDescriptor.getIcon()); } }
/** * Registers the list of component descriptors to build the enumeration * values/icons from their names and icons. * * @param componentDescriptorList * the componentDescriptorList to set. */ public void setComponentDescriptors( List<IComponentDescriptor<?>> componentDescriptorList) { Map<String, String> componentDescriptorImages = new LinkedHashMap<>(); for (IComponentDescriptor<?> componentDescriptor : componentDescriptorList) { String componentIconImageUrl = null; if (componentDescriptor.getIcon() != null) { componentIconImageUrl = componentDescriptor.getIcon().getIconImageURL(); } componentDescriptorImages.put(componentDescriptor.getName(), componentIconImageUrl); } setValuesAndIconImageUrls(componentDescriptorImages); } }
private Icon computeIcon(Class<?> modelClass) { Icon icon = null; for (IComponentDescriptor<?> componentDescriptor : componentDescriptors) { if (modelClass.equals(componentDescriptor.getComponentContract()) && componentDescriptor.getIcon() != null) { icon = componentDescriptor.getIcon(); } } if (icon == null) { Class<?>[] superInterfaces = modelClass.getInterfaces(); for (int i = superInterfaces.length - 1; i >= 0 && icon == null; i--) { icon = computeIcon(superInterfaces[i]); } if (icon == null && modelClass.getSuperclass() != null) { icon = computeIcon(modelClass.getSuperclass()); } } if (icon != null && icon.getDimension() == null) { icon.setDimension(defaultDimension); } return icon; } }
/** * {@inheritDoc} * * @return the icon */ @Override public Icon getIcon() { Icon icon = super.getIcon(); if (icon == null) { icon = getElementComponentDescriptor().getIcon(); setIcon(icon); } return icon; }
/** * {@inheritDoc} * * @return the icon */ @Override public Icon getIcon() { Icon icon = super.getIcon(); if (icon == null) { if (entityDescriptor != null) { icon = entityDescriptor.getIcon(); } if (icon == null) { icon = new Icon(getDefaultIconImageURL(), null); } } return icon; }
/** * Performs delayed configuration. */ protected void finishConfiguration() { setDescription(getQueriedComponentsDescriptor().getDescription()); setIcon(getQueriedComponentsDescriptor().getIcon()); List<String> qProperties = new ArrayList<>(); for (String queryableProperty : queryComponentsDescriptorProvider.getQueryableProperties()) { IPropertyDescriptor propertyDescriptor = getPropertyDescriptor(queryableProperty); if (propertyDescriptor instanceof ComparableQueryStructureDescriptor) { for (String nestedRenderedProperty : ((ComparableQueryStructureDescriptor) propertyDescriptor) .getRenderedProperties()) { qProperties.add(propertyDescriptor.getName() + "." + nestedRenderedProperty); } } else { qProperties.add(propertyDescriptor.getName()); } } setRenderedProperties(qProperties); setQueryableProperties(queryComponentsDescriptorProvider.getQueryableProperties()); setToStringProperty(getQueriedComponentsDescriptor().getToStringProperty()); setToHtmlProperty(getQueriedComponentsDescriptor().getToHtmlProperty()); setAutoCompleteProperty(getQueriedComponentsDescriptor().getAutoCompleteProperty()); setUnclonedProperties(getQueriedComponentsDescriptor().getUnclonedProperties()); setPageSize(getQueriedComponentsDescriptor().getPageSize()); setOrderingProperties(getQueriedComponentsDescriptor().getOrderingProperties()); }
scrollPane.setViewportView(viewComponent); JLabel iconLabel = new JLabel(); iconLabel.setIcon(getIconFactory().getIcon(rowDescriptor.getIcon(), getIconFactory().getTinyIconSize())); iconLabel.setBorder(BorderFactory.createLoweredBevelBorder()); scrollPane.setCorner(ScrollPaneConstants.UPPER_TRAILING_CORNER, iconLabel);