- if ( !CORBA::is_nil( objAfter ) ) {
- useCaseBuilder->InsertBefore( SO, objAfter ); // insert at given tag
- } else if ( !useCaseBuilder->IsUseCaseNode( SO ) ) {
- useCaseBuilder->AppendTo( theFatherObject, SO ); // append to the end of list
+ if ( isNewSO || !isInUseCaseTree )
+ {
+ // define the next tag after given one in the data tree to insert SObject
+ SALOMEDS::SObject_wrap curObj, objAfter;
+ if ( theFatherObject->GetLastChildTag() > theTag && theTag > 0 )
+ {
+ SALOMEDS::UseCaseIterator_wrap
+ anUseCaseIter = useCaseBuilder->GetUseCaseIterator(theFatherObject);
+ for ( ; anUseCaseIter->More(); anUseCaseIter->Next() ) {
+ curObj = anUseCaseIter->Value();
+ if ( curObj->Tag() > theTag ) {
+ objAfter = curObj;
+ break;
+ }
+ }
+ }
+ if ( !CORBA::is_nil( objAfter ))
+ useCaseBuilder->InsertBefore( SO, objAfter ); // insert at given tag
+ else if ( !isInUseCaseTree )
+ useCaseBuilder->AppendTo( theFatherObject, SO ); // append to the end of list