+ Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+ if( anObject.IsNull() )
+ continue;
+
+ if ( !anObject->CanRemove() )
+ {
+ anIsCanRemove = false;
+ break;
+ }
+
+ anObjNames.append( anObject->GetName() );
+ }
+
+ if ( !anIsCanRemove )
+ {
+ SUIT_MessageBox::critical( module()->getApp()->desktop(),
+ tr( "DELETE_OBJECTS" ), tr( "DELETE_OBJECTS_IMPOSIBLE" ) );
+ abort();
+ return;
+ }
+
+ anObjNames.removeDuplicates();
+
+ // check the back-references
+ QMap<QString,HYDROData_SequenceOfObjects> aBackObjects =
+ HYDROGUI_Tool::GetObjectsBackReferences( doc(), anObjNames );
+
+ QMap<QString,HYDROData_SequenceOfObjects>::const_iterator anIt = aBackObjects.begin(),
+ aLast = aBackObjects.end();
+ QStringList aRefList;
+ for ( ; anIt != aLast; anIt++ ) {
+ QStringList aSeqList;
+ HYDROData_SequenceOfObjects::Iterator anIter( anIt.value() );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Entity) anEntity = anIter.Value();
+ if ( anEntity.IsNull() )
+ continue;
+ aSeqList.append( QString( tr( "DELETE_OBJECT_NAME" ) ).arg( anEntity->GetName() ) );
+ }
+ aRefList.append( QString( tr( "DELETE_OBJECT_IS_USED_FOR" ) ).arg( anIt.key() )
+ .arg( aSeqList.join( ", " ) ) );
+ }
+
+ //QString aNamesList = anObjNames.join( "\n" );
+ if ( !aBackObjects.isEmpty() )
+ {
+ SUIT_MessageBox::critical( module()->getApp()->desktop(),
+ tr( "DELETE_OBJECTS" ),
+ tr( "DELETED_OBJECTS_HAS_BACKREFERENCES" ).arg( aRefList.join( "\n" ) ) );
+ abort();
+ return;
+ }
+
+ QString aWarningMsg;
+
+ HYDROGUI_DeleteDlg aDeleteDlg( module()->getApp()->desktop() );
+ aDeleteDlg.setObjectsToRemove( anObjNames );
+ bool isLastStricklerRemoved = false;
+ if ( aDeleteDlg.exec() != HYDROGUI_DeleteDlg::Accepted )
+ {
+ abort();
+ return;
+ }
+ else
+ {
+ QStringList aTableNames =
+ HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_STRICKLER_TABLE, false );
+ aTableNames += anObjNames;
+ if ( aTableNames.toSet().size() == anObjNames.size() )
+ {
+ aWarningMsg = tr("DELETE_LAST_TABLE_WRN");
+ isLastStricklerRemoved = true;
+ }
+ }
+
+ if ( !aWarningMsg.isEmpty() ) {
+ int anAnswer = SUIT_MessageBox::warning( module()->getApp()->desktop(),
+ tr("WARNING"), aWarningMsg,