/** * Constructs a new {@code MandatoryPropertyException} instance. * * @param descriptor * the violated property descriptor. * @param targetComponent * the target component. */ public MandatoryPropertyException(IPropertyDescriptor descriptor, Object targetComponent) { super("Mandatory property [" + descriptor.getName() + "] on component [" + targetComponent + "]."); this.descriptor = descriptor; this.targetComponent = targetComponent; }
private void checkMandatoryProperties(Object proxy) { if (propertyProcessorsEnabled) { for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { if (!propertyDescriptor.isComputed()) { if (propertyDescriptor.isMandatory()) { Object newValue = straightGetProperty(proxy, propertyDescriptor.getName()); if (newValue == null || (isInitialized(newValue) && newValue instanceof Collection<?> && ((Collection<?>) newValue).isEmpty())) { throw new MandatoryPropertyException(propertyDescriptor, proxy); } } if (propertyDescriptor instanceof ICollectionPropertyDescriptor<?> && !((ICollectionPropertyDescriptor<?>) propertyDescriptor).getReferencedDescriptor() .isNullElementAllowed()) { Object newValue = straightGetProperty(proxy, propertyDescriptor.getName()); if (isInitialized(newValue) && newValue instanceof Collection<?>) { for (Object element : ((Collection<?>) newValue)) { if (element == null) { throw new MandatoryPropertyException(propertyDescriptor, proxy); } } } } } } } }
/** * {@inheritDoc} */ @Override protected void decorateWithDescription( IPropertyDescriptor propertyDescriptor, ITranslationProvider translationProvider, Locale locale, IView<SComponent> view) { if (view != null && propertyDescriptor.getDescription() != null) { view.getPeer().setToolTipText( propertyDescriptor.getI18nDescription(translationProvider, locale) + TOOLTIP_ELLIPSIS); } }
private boolean isSortable(IPropertyDescriptor propertyDescriptor) { return propertyDescriptor != null && (!propertyDescriptor.isComputed() || propertyDescriptor.getPersistenceFormula() != null); }
private void checkIntegrity(Object proxy) { checkMandatoryProperties(proxy); if (propertyProcessorsEnabled) { for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { if (!propertyDescriptor.isComputed()) { propertyDescriptor.preprocessSetter(proxy, straightGetProperty(proxy, propertyDescriptor.getName())); } } } }
private JLabel createPropertyLabel(IPropertyDescriptor propertyDescriptor, JComponent propertyComponent, Locale locale) { JLabel propertyLabel = createJLabel(); StringBuffer labelText = new StringBuffer(propertyDescriptor.getI18nName( getTranslationProvider(), locale)); if (propertyDescriptor.isMandatory()) { labelText.append("*"); propertyLabel.setForeground(Color.RED); } propertyLabel.setText(labelText.toString()); propertyLabel.setLabelFor(propertyComponent); return propertyLabel; }
columnClassesByIds.put(columnId, modelDescriptor .getCollectionDescriptor().getElementDescriptor() .getPropertyDescriptor(columnId).getModelType()); columnConnectorKeys.add(columnId); if (columnViewDescriptor.getReadabilityGates() != null) { .getPropertyDescriptor(propertyName); StringBuffer columnName = new StringBuffer(propertyDescriptor .getI18nName(getTranslationProvider(), locale)); if (propertyDescriptor.isMandatory()) { columnName.append("*");
String tempAutoCompleteProperty = null; IPropertyDescriptor lpd = getPropertyDescriptor(getToStringProperty()); if (lpd != null && !lpd.isComputed()) { tempAutoCompleteProperty = lpd.getName(); } else { List<String> rp = getRenderedProperties(); Collection<IPropertyDescriptor> allProps = getPropertyDescriptors(); for (IPropertyDescriptor pd : allProps) { if (pd instanceof IStringPropertyDescriptor && !IEntity.ID.equals(pd.getName())) { tempAutoCompleteProperty = pd.getName(); break;
String propertyName = propertyDescriptor.getName(); if (propertyDescriptor instanceof ICollectionPropertyDescriptor<?>) { component.straightSetProperty(propertyName, componentCollectionFactory.createComponentCollection(propertyDescriptor.getModelType())); } else if (propertyDescriptor instanceof IScalarPropertyDescriptor) { Object defaultValue = ((IScalarPropertyDescriptor) propertyDescriptor).getDefaultValue(); if (defaultValue != null) { defaultValue = propertyDescriptor.interceptSetter(component, defaultValue); propertyDescriptor.preprocessSetter(component, defaultValue); component.straightSetProperty(propertyName, defaultValue); } else if (isReload) { if (!IEntity.ID.equals(propertyName) && !IEntity.VERSION.equals(propertyName) && propertyDescriptor .isModifiable()) { component.straightSetProperty(propertyName, null); } else if (isReload && propertyDescriptor.isModifiable()) { component.straightSetProperty(propertyName, null);
/** * Directly gets all property values out of the property store without any * other operation. * * @param proxy * the proxy to straight get the properties from. * @return The map of properties. */ protected Map<String, Object> straightGetProperties(Object proxy) { Map<String, Object> allProperties = new HashMap<>(); for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { String propertyName = propertyDescriptor.getName(); if (!(propertyDescriptor.isComputed() && propertyDescriptor.getPersistenceFormula() == null)) { allProperties.put(propertyName, straightGetProperty(proxy, propertyName)); } } return allProperties; }
Class<? extends IComponent> componentContract = component.getComponentContract(); for (IPropertyDescriptor propertyDescriptor : entityDescriptor.getPropertyDescriptors()) { if (propertyDescriptor != null && !propertyDescriptor.isComputed()) { String propertyName = propertyDescriptor.getName(); Class<?> propertyType = propertyDescriptor.getModelType(); String convertedPropertyName = getConverter().getMappingContext().getPersistentEntity(componentContract) .getPersistentProperty(PropertyHelper.toJavaBeanPropertyName(
Object proxy, Method method, Object... args) { try { String propertyName = propertyDescriptor.getName(); Object computedPropertyValue = null; if (accessorInfo.isModifier()) { computedPropertyValue = getAccessorFactory().createPropertyAccessor(propertyDescriptor.getName(), getComponentContract()).getValue(proxy); Object interceptedValue = args[args.length - 1]; switch (accessorInfo.getAccessorType()) { case SETTER: interceptedValue = propertyDescriptor.interceptSetter(proxy, interceptedValue); propertyDescriptor.preprocessSetter(proxy, interceptedValue); break; case ADDER: } else if (propertyDescriptor.isCacheable()) { if (computedPropertiesCache != null && computedPropertiesCache.containsKey(propertyName)) { computedPropertyValue = computedPropertiesCache.get(propertyName); Object newComputedPropertyValue = getAccessorFactory().createPropertyAccessor(propertyDescriptor.getName(), getComponentContract()).getValue(proxy); switch (accessorInfo.getAccessorType()) { case SETTER: propertyDescriptor.postprocessSetter(proxy, computedPropertyValue, newComputedPropertyValue); break; case ADDER: } else if (propertyDescriptor.isCacheable()) {
Class<IComponentExtension<IComponent>> extensionClass = (Class<IComponentExtension<IComponent>>) propertyDescriptor .getDelegateClass(); if (extensionClass != null) { return accessComputedProperty(propertyDescriptor, accessorInfo, extensionClass, proxy, method, args); } else if (!propertyDescriptor.isComputed()) { if (accessorInfo.isModifier()) { if (modifierMonitors != null && modifierMonitors.contains(methodName)) { String propertyName = propertyDescriptor.getName(); if (propertyDescriptor.isFilterOnly()) { throw new ComponentException("The '" + propertyName + "' property is meant to be used only on filters for the following component : \n"
private JLabel createFormPropertyLabel(IActionHandler actionHandler, Locale locale, IPropertyViewDescriptor propertyViewDescriptor, IPropertyDescriptor propertyDescriptor, IView<JComponent> propertyView, boolean forbidden) { JLabel propertyLabel = createPropertyLabel(propertyViewDescriptor, propertyView.getPeer(), actionHandler, locale); if (!propertyViewDescriptor.isReadOnly() && propertyDescriptor != null && propertyDescriptor.isMandatory() && !(propertyDescriptor instanceof IBooleanPropertyDescriptor)) { if (propertyViewDescriptor.getLabelForeground() == null) { propertyLabel.setForeground(createColor(getFormLabelMandatoryPropertyColorHex())); } propertyLabel.setText(decorateMandatoryPropertyLabel(propertyLabel.getText())); } if (forbidden) { propertyLabel.setText(" "); propertyLabel.setIcon(null); } return propertyLabel; }
if (propertyDescriptor == null) { for (IPropertyDescriptor pd : baseComponentDescriptor.getPropertyDescriptors()) { if (propertyName.equals(pd.getPersistenceFormula())) { fixedPropertyName = pd.getName();
rowConnectorPrototype.addChildConnector(columnConnector); columnClasses.add(rowDescriptor.getPropertyDescriptor(columnId) .getModelType()); } finally { actionHandler.restoreLastSecurityContextSnapshot(); StringBuffer columnName = new StringBuffer( columnViewDescriptor.getI18nName(actionHandler, locale)); if (propertyDescriptor.isMandatory()) { columnName.append("*");
reversePropertyDescriptor.preprocessSetter(propertyValue, null); } else { getAccessorFactory().createPropertyAccessor(reversePropertyDescriptor.getName(), getComponentContract(((IComponent) propertyValue))).setValue(propertyValue, null); reversePropertyDescriptor.getName(), getComponentContract(((IComponent) propertyValue))) .getValue(propertyValue); ((ICollectionPropertyDescriptor<?>) reversePropertyDescriptor).preprocessRemover( propertyValue, reverseCollection, component); } else { getAccessorFactory().createCollectionPropertyAccessor(reversePropertyDescriptor.getName(), getComponentContract(((IComponent) propertyValue)), componentContract).removeFromValue( propertyValue, component); } else if (propertyDescriptor.isModifiable() && !((Collection<?>) propertyValue).isEmpty()) { if (((ICollectionPropertyDescriptor<?>) propertyDescriptor).getReverseRelationEnd() != null) { IPropertyDescriptor reversePropertyDescriptor = reversePropertyDescriptor.preprocessSetter(collectionElement, null); } else { getAccessorFactory().createPropertyAccessor(reversePropertyDescriptor.getName(), getComponentContract((IComponent) collectionElement)).setValue(collectionElement, null); reversePropertyDescriptor.getName(), getComponentContract((IComponent) collectionElement)).getValue(collectionElement); ((ICollectionPropertyDescriptor<?>) reversePropertyDescriptor).preprocessRemover( collectionElement, reverseCollection, component); } else { getAccessorFactory().createCollectionPropertyAccessor(reversePropertyDescriptor.getName(),
if (propertyView != null) { RComponent peer = propertyView.getPeer(); if (propertyDescriptor != null && propertyDescriptor.getName() != null) { peer.setLabel(propertyDescriptor.getI18nName(actionHandler, locale));
&& !(propertyDescriptor instanceof ITextPropertyDescriptor) && !(propertyDescriptor instanceof IObjectPropertyDescriptor) && !propertyDescriptor.isFilterOnly()) { String propertyName = propertyDescriptor.getName(); if (!propertyName.endsWith(RAW_SUFFIX) && !propertyName.endsWith(NLS_SUFFIX)) { renderedPropertiesSet.add(propertyName);
private void completeWithComputedNlsDescriptors(IPropertyDescriptor rawDescriptor) { String barePropertyName = rawDescriptor.getName(); if (barePropertyName.endsWith(RAW_SUFFIX)) { barePropertyName = barePropertyName.substring(0, barePropertyName.length() - RAW_SUFFIX.length()); } BasicStringPropertyDescriptor nlsDescriptor = (BasicStringPropertyDescriptor) rawDescriptor.clone(); nlsDescriptor.setName(barePropertyName + NLS_SUFFIX); nlsDescriptor.setDelegateWritable(true); nlsDescriptor.setComputed(true); if (!isPurelyAbstract()) { nlsDescriptor.setSqlName("(SELECT T.TRANSLATED_VALUE FROM {tableName}_T T WHERE T." + "T_{tableName}_ID = ID AND T.LANGUAGE = :JspressoSessionGlobals.language AND " + "T.PROPERTY_NAME = '" + barePropertyName + "')"); } BasicStringPropertyDescriptor rawOrNlsDescriptor = (BasicStringPropertyDescriptor) rawDescriptor.clone(); rawOrNlsDescriptor.setName(barePropertyName); rawOrNlsDescriptor.setDelegateWritable(true); rawOrNlsDescriptor.setComputed(true); if (!isPurelyAbstract()) { rawOrNlsDescriptor.setSqlName( "CASE WHEN " + nlsDescriptor.getSqlName() + " IS NULL THEN " + ((BasicPropertyDescriptor) rawDescriptor) .getSqlName() + " ELSE " + nlsDescriptor.getSqlName() + " END"); } propertyDescriptorsMap.put(nlsDescriptor.getName(), nlsDescriptor); propertyDescriptorsMap.put(rawOrNlsDescriptor.getName(), rawOrNlsDescriptor); }