diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings index 7faaf1e7907161eeb6e886641b6d3be7f6f886fa..bcac6180bcd446d94f2c62e64cb2581b53846a22 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings @@ -1,2 +1,2 @@ -DerivedAnnotationBaseStaticImpl.java 0b5a8e36f66c937b1659f0b73a0cf0428337e364 GREEN +DerivedAnnotationBaseStaticImpl.java 25b4a0b00fe68a1027ee81e52697e03988862373 GREEN LibraryElementBaseStaticImpl.java 13222726153d5159994866795b059a4cc3522434 GREEN diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java index 0b5a8e36f66c937b1659f0b73a0cf0428337e364..25b4a0b00fe68a1027ee81e52697e03988862373 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java @@ -37,21 +37,20 @@ public class DerivedAnnotationBaseStaticImpl { * @return See above. */ public static <T> T getValue(IDerivedAnnotation<T> annotation) { - T derivedValue = null; - if(annotation.getUserAnnotatedValue() != null) { - if(annotation.isUserAnnotatedValuePreferred()) { - // User annotated value is available and preferred -> return it - return annotation.getUserAnnotatedValue(); - } - derivedValue = annotation.getDerivedValue(); - if(derivedValue == null) { - // Derived value would be preferred, but it is not available -> return user - // annotated value - return annotation.getUserAnnotatedValue(); - } + T userAnnotatedValue = annotation.getUserAnnotatedValue(); + if(annotation.isUserAnnotatedValuePreferred() && userAnnotatedValue != null) { + // User annotated value is preferred and exists. + return userAnnotatedValue; } - // Use cached result of derived value if it is available - return derivedValue != null ? derivedValue : annotation.getDerivedValue(); + T derivedValue = annotation.getDerivedValue(); + if(derivedValue != null) { + // User annotated value is not preferred: use the derived value. + return derivedValue; + } + + // Derived value does not exist: return the user annotated value, even if it is not + // preferred. If neither the derived or the user annotated values exist, we return null. + return userAnnotatedValue; } } diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings index 5c28ee082a0462d3d2912ac7f6cc919c8032b41f..0dc4ea3d0c7cc3b78179d5bf38f965a7c79702a3 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings @@ -10,7 +10,7 @@ ModelEditorBindingBase.java 4c5ac569c0b6e7678fc8191096b26dfd09fdcb98 GREEN ModelElementHandlerBase.java 384727748f125c9d43f19d9c0eba4ba1be5a7a26 GREEN MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN NamedCommentedModelElementHandlerBase.java 681b98b50b362f01abb7a36f108f4f11b9e51829 GREEN -PropertySectionBase.java 7b893ca28d86a415d9fc7a818e65c04ed244e896 GREEN +PropertySectionBase.java 20fb1daea544123ea941743aafeb9ac59daf5356 GREEN TutorialStepUIAtomicBase.java cea2a158158b476de2108d2309afcf47f217b6d9 GREEN TutorialStepUIAtomicWithWhitelistBase.java a9788ae514f62d27169c737ef59fb583234b5d43 GREEN TutorialStepUICompositeBase.java 8225210eacb5b88de47d78280c5819f572f00ffa GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java index 7b893ca28d86a415d9fc7a818e65c04ed244e896..20fb1daea544123ea941743aafeb9ac59daf5356 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java @@ -25,6 +25,7 @@ import static org.eclipse.core.databinding.conversion.StringToNumberConverter.to import static org.fortiss.tooling.kernel.ui.databinding.FloatValidator.FLOAT_VALIDATOR; import static org.fortiss.tooling.kernel.ui.databinding.IntValidator.INT_VALIDATOR; import static org.fortiss.tooling.kernel.ui.databinding.NumberPositiveValidator.NUMBER_POSITIVE_VALIDATOR; +import static org.fortiss.tooling.kernel.ui.databinding.NumberPositiveZeroValidator.NUMBER_POSITIVE_ZERO_VALIDATOR; import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.DECORATION_KEY; import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performComplexTextBinding; import static org.fortiss.tooling.kernel.ui.util.WidgetsFactory.createTextWithUndo; @@ -448,6 +449,11 @@ public abstract class PropertySectionBase extends AbstractPropertySection { bindIntegerValue(text, observedValue, NUMBER_POSITIVE_VALIDATOR); } + /** Binds a positive or zero integer value. */ + protected void bindPositiveOrZeroIntegerValue(Control text, IObservableValue<?> observedValue) { + bindIntegerValue(text, observedValue, NUMBER_POSITIVE_ZERO_VALIDATOR); + } + /** Binds a integer value. */ protected void bindIntegerValue(Control text, IObservableValue<?> observedValue, IValidator numberValidator) {