private IValueConnector createColumnConnector(String columnId, IComponentDescriptor<?> descriptor) { IPropertyDescriptor propertyDescriptor = descriptor .getPropertyDescriptor(columnId); if (propertyDescriptor == null) { throw new ViewException("No property " + columnId + " defined for " + descriptor.getComponentContract()); } if (propertyDescriptor instanceof IReferencePropertyDescriptor) { return connectorFactory.createCompositeValueConnector(columnId, ((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor().getToStringProperty()); } return connectorFactory.createValueConnector(propertyDescriptor.getName()); }
/** * {@inheritDoc} */ @Override public String getI18nDescription(ITranslationProvider translationProvider, Locale locale) { if (elementEntityDescriptor != null) { return translationProvider.getTranslation("add.element.description", new String[] {elementEntityDescriptor.getI18nName( translationProvider, locale)}, locale); } return super.getI18nDescription(translationProvider, locale); }
/** * Sets the elementEntityDescriptor. Entities of this type (which must be a * subclass of the collection element) are created and added to the detail * collection. * * @param elementEntityDescriptor * the elementEntityDescriptor to set. */ public void setElementEntityDescriptor( IComponentDescriptor<IEntity> elementEntityDescriptor) { this.elementEntityDescriptor = elementEntityDescriptor; if (elementEntityDescriptor != null) { setIconImageURL(elementEntityDescriptor.getIconImageURL()); } }
private long getLastUpdated(IComponentDescriptor<?> componentDescriptor) { long lastUpdated = componentDescriptor.getLastUpdated(); for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { long propertyLastUpdated = propertyDescriptor.getLastUpdated(); if (propertyLastUpdated > lastUpdated) { lastUpdated = propertyLastUpdated; } } return lastUpdated; }
/** * 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); } }
@SuppressWarnings("rawtypes") private Map<String, IComponentDescriptor<?>> buildContractNameIdMap() { Map<String, IComponentDescriptor<?>> map = new HashMap<>(); Map<String, IComponentDescriptor> idToComponentDescriptors = componentApplicationContext.getBeansOfType( IComponentDescriptor.class, false, false); for (Map.Entry<String, IComponentDescriptor> descriptorEntry : idToComponentDescriptors.entrySet()) { IComponentDescriptor componentDescriptor = descriptorEntry.getValue(); if (componentDescriptor.getComponentContract() != null) { map.put(componentDescriptor.getComponentContract().getName(), componentDescriptor); if (componentDescriptor.isTranslatable()) { ICollectionPropertyDescriptor<?> collectionPropertyDescriptor = (ICollectionPropertyDescriptor<?>) componentDescriptor .getPropertyDescriptor(AbstractComponentDescriptor.getComponentTranslationsDescriptorTemplate().getName()); if (collectionPropertyDescriptor != null) { IComponentDescriptor<?> translationComponentDescriptor = collectionPropertyDescriptor .getReferencedDescriptor().getElementDescriptor(); if (translationComponentDescriptor.getComponentContract() != null) { map.put(translationComponentDescriptor.getComponentContract().getName(), translationComponentDescriptor); } } } } } map.put(BasicDescriptorDescriptor.INSTANCE.getName(), BasicDescriptorDescriptor.INSTANCE); return map; } }
private Object getTemplateValue(IPropertyDescriptor propertyDescriptor) { if (propertyDescriptor instanceof IDatePropertyDescriptor) { return getDateTemplateValue((IDatePropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof ITimePropertyDescriptor) { return getTimeTemplateValue((ITimePropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof IDurationPropertyDescriptor) { return getDurationTemplateValue((IDurationPropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof IStringPropertyDescriptor) { return getStringTemplateValue((IStringPropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof IDecimalPropertyDescriptor) { return getDecimalTemplateValue((IDecimalPropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof IPercentPropertyDescriptor) { return getPercentTemplateValue((IPercentPropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof IIntegerPropertyDescriptor) { return getIntegerTemplateValue((IIntegerPropertyDescriptor) propertyDescriptor); } else if (propertyDescriptor instanceof IReferencePropertyDescriptor) { return getTemplateValue(((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor().getPropertyDescriptor( ((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor().getToStringProperty())); } return null; }
@Override public void propertyChange(PropertyChangeEvent evt) { Object source = evt.getSource(); if (source instanceof IEntity) { IComponentDescriptor<?> componentDescriptor = getBackendController().getEntityFactory() .getComponentDescriptor(((IEntity) source) .getComponentContract()); IPropertyDescriptor propertyDescriptor = componentDescriptor.getPropertyDescriptor(evt.getPropertyName()); if (propertyDescriptor != null && !propertyDescriptor.isComputed()) { lifecycledEntities.remove(source); } } } };
.createCompositeValueConnector(modelDescriptor.getName() + "Element", modelDescriptor.getCollectionDescriptor().getElementDescriptor() .getToStringProperty()); ICollectionConnector connector = connectorFactory .createCollectionConnector(modelDescriptor.getName(), mvcBinder, JLabel iconLabel = createJLabel(); iconLabel.setIcon(iconFactory.getIcon(modelDescriptor .getCollectionDescriptor().getElementDescriptor().getIconImageURL(), IIconFactory.TINY_ICON_SIZE)); iconLabel.setBorder(BorderFactory.createLoweredBevelBorder()); columnClassesByIds.put(columnId, modelDescriptor .getCollectionDescriptor().getElementDescriptor() .getPropertyDescriptor(columnId).getModelType()); columnConnectorKeys.add(columnId); if (columnViewDescriptor.getReadabilityGates() != null) { IPropertyDescriptor propertyDescriptor = modelDescriptor .getCollectionDescriptor().getElementDescriptor() .getPropertyDescriptor(propertyName); StringBuffer columnName = new StringBuffer(propertyDescriptor .getI18nName(getTranslationProvider(), locale));
private IView<SComponent> createReferencePropertyView( IReferencePropertyDescriptor<?> propertyDescriptor, IActionHandler actionHandler, Locale locale) { SActionField viewComponent = createSActionField(true); SReferenceFieldConnector connector = new SReferenceFieldConnector( propertyDescriptor.getName(), viewComponent); connector.setToStringPropertyConnector(new BasicValueConnector( propertyDescriptor.getComponentDescriptor().getToStringProperty())); connector.setExceptionHandler(actionHandler); Action fieldAction = actionFactory.createAction(lovAction, actionHandler, viewComponent, propertyDescriptor, connector, locale); fieldAction.putValue(Action.NAME, getTranslationProvider().getTranslation( "lov.element.name", new Object[] {propertyDescriptor.getReferencedDescriptor().getI18nName( translationProvider, locale)}, locale)); fieldAction.putValue(Action.SHORT_DESCRIPTION, getTranslationProvider() .getTranslation( "lov.element.description", new Object[] {propertyDescriptor.getReferencedDescriptor() .getI18nName(translationProvider, locale)}, locale) + TOOLTIP_ELLIPSIS); if (propertyDescriptor.getReferencedDescriptor().getIconImageURL() != null) { fieldAction.putValue(Action.SMALL_ICON, iconFactory.getIcon( propertyDescriptor.getReferencedDescriptor().getIconImageURL(), IIconFactory.TINY_ICON_SIZE)); } viewComponent.setActions(Collections.singletonList(fieldAction)); adjustSizes(viewComponent, null, null); return constructView(viewComponent, null, connector); }
String translationsPath = AbstractComponentDescriptor.getComponentTranslationsDescriptorTemplate().getName(); String translationsAlias = currentCriteria.getAlias() + "__" + componentDescriptor.getComponentContract().getSimpleName() + "__" + translationsPath; if (componentDescriptor.isTranslatable()) { rootCriteria.getSubCriteriaFor(currentCriteria, translationsPath, translationsAlias, JoinType.LEFT_OUTER_JOIN); String propertyName = property.getKey(); Object propertyValue = property.getValue(); IPropertyDescriptor propertyDescriptor = componentDescriptor.getPropertyDescriptor(propertyName); if (propertyDescriptor != null) { boolean isEntityRef = false; if (componentDescriptor.isEntity() && aQueryComponent.containsKey(IEntity.ID)) { isEntityRef = true; String autoCompleteProperty = joinedComponent.getQueryDescriptor().getAutoCompleteProperty(); if (autoCompleteProperty != null) { String val = (String) joinedComponent.get(autoCompleteProperty);
IPropertyDescriptor propertyDescriptor = componentDescriptor.getPropertyDescriptor(key); if (propertyDescriptor instanceof IReferencePropertyDescriptor<?>) { IComponentDescriptor<?> referencedDescriptor = ((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor(); if (referencedDescriptor.isEntity()) { if (!(value instanceof IQueryComponent) && !IQueryComponent.NULL_VAL.equals(value)) { String tsProp = referencedDescriptor.getToStringProperty(); String acProp = referencedDescriptor.getAutoCompleteProperty(); return buildNestedQueryComponent(key, value, tsProp, Collections.singletonList(acProp));
/** * Gets the interface class being the contract of this component. * * @return the component interface contract. */ public Class<?> getComponentContract() { return componentDescriptor.getComponentContract(); }
protected IPropertyDescriptor refinePropertyDescriptor(IPropertyDescriptor propertyDescriptor) { if (propertyDescriptor == null || getQueriedComponentsDescriptor().getPropertyDescriptor( propertyDescriptor.getName()) == null) { return propertyDescriptor; Class<? extends IComponent> referencedType; try { referencedType = referencedDescriptor.getComponentContract(); } catch (RuntimeException ex) { LOG.debug("An exception occurred while trying to load the class {}. This might be normal during compilation.", referencedDescriptor.getName(), ex); referencedType = null;
queryDescriptor = componentDescriptor; if (!ComparableQueryStructure.class.isAssignableFrom(queryDescriptor.getComponentContract())) { for (IPropertyDescriptor propertyDescriptor : getComponentDescriptor().getPropertyDescriptors()) { if (propertyDescriptor instanceof EnumQueryStructureDescriptor) { EnumQueryStructure enumQueryStructure = new EnumQueryStructure( (IEnumerationPropertyDescriptor) getQueryDescriptor().getPropertyDescriptor( propertyDescriptor.getName())); put(propertyDescriptor.getName(), enumQueryStructure); .getReferencedDescriptor(); ComparableQueryStructure comparableQueryStructure = new ComparableQueryStructure(referencedDescriptor, getComponentFactory(), getQueryDescriptor().getPropertyDescriptor(propertyDescriptor.getName())); put(propertyDescriptor.getName(), comparableQueryStructure);
/** * 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()); }
String propertyName = property.getKey(); Object propertyValue = property.getValue(); IPropertyDescriptor propertyDescriptor = componentDescriptor.getPropertyDescriptor(propertyName); if (propertyDescriptor != null) { boolean isEntityRef = false; if (componentDescriptor.isEntity() && aQueryComponent.containsKey(IEntity.ID)) { isEntityRef = true; String autoCompleteProperty = joinedComponent.getQueryDescriptor().getAutoCompleteProperty(); if (autoCompleteProperty != null) { String val = (String) joinedComponent.get(autoCompleteProperty);
/** * {@inheritDoc} */ public List<String> getRenderedChildProperties(String propertyName) { List<String> childProperties = null; if (renderedChildProperties != null) { childProperties = renderedChildProperties.get(propertyName); } if (childProperties == null) { IPropertyDescriptor childPropertyDescriptor = ((IComponentDescriptorProvider<?>) getModelDescriptor()) .getComponentDescriptor().getPropertyDescriptor(propertyName); if (childPropertyDescriptor instanceof ICollectionPropertyDescriptor) { return ((ICollectionDescriptor<?>) ((ICollectionPropertyDescriptor<?>) childPropertyDescriptor) .getCollectionDescriptor()).getElementDescriptor() .getRenderedProperties(); } else if (childPropertyDescriptor instanceof IReferencePropertyDescriptor) { return ((IReferencePropertyDescriptor<?>) childPropertyDescriptor) .getReferencedDescriptor().getRenderedProperties(); } } return childProperties; }
/** * To string. * * @param proxy * the proxy * @return the to string */ protected String toString(Object proxy) { try { String toStringPropertyName = componentDescriptor.getToStringProperty(); Object toStringValue = accessorFactory.createPropertyAccessor(toStringPropertyName, componentDescriptor.getComponentContract()).getValue(proxy); if (toStringValue == null) { return ""; } return toStringValue.toString(); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ComponentException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ComponentException(ex.getCause()); } }
IComponentDescriptor<?> baseComponentDescriptor = descriptorRegistry.getComponentDescriptor(entityContract); for (String propertyName : propertyPath.split("\\.")) { IPropertyDescriptor propertyDescriptor = baseComponentDescriptor.getPropertyDescriptor(propertyName); String fixedPropertyName = propertyName; if (propertyDescriptor == null) { for (IPropertyDescriptor pd : baseComponentDescriptor.getPropertyDescriptors()) { if (propertyName.equals(pd.getPersistenceFormula())) { fixedPropertyName = pd.getName();