-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
bool CollectionPlugin_FieldValidator::isValid(const FeaturePtr& theFeature,
- const std::list<std::string>& theArguments,
+ const std::list<std::string>& /*theArguments*/,
Events_InfoMessage& theError) const
{
AttributeSelectionListPtr aSelList =
}
return true;
}
+
+bool CollectionPlugin_GroupSelectionValidator::isValid(
+ const AttributePtr& theAttribute,
+ const std::list<std::string>& /*theArguments*/,
+ Events_InfoMessage& theError) const
+{
+ AttributeSelectionListPtr aSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if (!aSelList) {
+ theError = "Error: This validator can only work with selection list of attributes";
+ return false;
+ }
+
+ for (int anIndex = 0; anIndex < aSelList->size(); ++anIndex) {
+ AttributeSelectionPtr aCurSelection = aSelList->value(anIndex);
+ FeaturePtr aCurFeature = aCurSelection->contextFeature();
+ ResultPtr aGroupResult = aCurFeature.get() ? aCurFeature->lastResult()
+ : aCurSelection->context();
+ if (!aGroupResult.get() || aGroupResult->groupName() == ModelAPI_ResultGroup::group()) {
+ theError = "Error: Whole group mustn't be selected.";
+ return false;
+ }
+ }
+
+ return true;
+}