'/*******************************************************************//
'/ Vincent Richard                                                   //
'/ Associate Technical Support Engineer                              //
'/ Rational Software            Phone:   +31 (0)20 4546 200          //
'/ Beechavenue 30               Fax:     +31 (0)20 4546 201          //
'/ 1119 PV  Schiphol-Rijk       email:   vrichard@rational.com       //
'/ The Netherlands              http://www.rational.com/support      //
'/*******************************************************************//

Dim newStereotype As String	 

Sub DelCategoryStereotypes(currentCategory As Category)
	currentCategory.stereotype = newStereotype

	Dim i As Integer

	Dim allAssociations As AssociationCollection
	Set allAssociations = currentCategory.Associations
	For i=1 To allAssociations.count
		Dim currentAssociation As Association
		Set currentAssociation = allAssociations.GetAt(i)
		currentAssociation.stereotype = newStereotype
	Next i

	Dim allClasses As ClassCollection
	Set allClasses = currentCategory.Classes
	For i=1 To allClasses.count
		Dim currentClass As Class
		Set currentClass = allClasses.GetAt(i)
		currentClass.stereotype = newStereotype

		Dim j As Integer

		Dim allAttributes As AttributeCollection
		Set allAttributes = currentClass.Attributes
		For j=1 To allAttributes.count
			Dim currentAttribute As Attribute
			Set currentAttribute = allAttributes.GetAt(j)
			currentAttribute.stereotype = newStereotype
		Next j

		Dim allOperations As OperationCollection
		Set allOperations = currentClass.Operations
		For j=1 To allOperations.count
			Dim currentOperation As Operation
			Set currentOperation = allOperations.GetAt(j)
			currentOperation.stereotype = newStereotype

			Dim k As Integer
			Dim allParameters As ParameterCollection
			Set allParameters = currentOperation.Parameters
			For k=1 To allParameters.count
				Dim currentParameter As Parameter
				Set currentParameter = allParameters.GetAt(k)
				currentParameter.stereotype = newStereotype
			Next k
		Next j

		Dim allClassParameters As ParameterCollection
		Set allClassParameters = currentClass.Parameters
		For j=1 To allClassParameters.count
			Dim currentClassParameter As Parameter
			Set currentClassParameter = allClassParameters.GetAt(j)
			currentClassParameter.stereotype = newStereotype
		Next j

	Next i

	Dim allUseCases As UseCaseCollection
	Set allUseCases = currentCategory.UseCases
	For i=1 To allUseCases.count
		Dim currentUseCase As UseCase
		Set currentUseCase = allUseCases.GetAt(i)	
		currentUseCase.stereotype = newStereotype

		Dim theStateMachine As StateMachine
		Set theStateMachine = currentUseCase.StateMachine
		If Not theStateMachine Is Nothing Then
			theStateMachine.stereotype = newStereotype
			theStateMachine.LocalizedStereotype = newStereotype
			Dim allStateVertices As StateVertexCollection 
			Set allStateVertices = theStateMachine.StateVertices
			For j=1 To allStateVertices.count
				Dim currentStateVertex As StateVertex
 				Set currentStateVertex = allStateVertices.GetAt(j)
				currentStateVertex.stereotype = newStereotype

				Dim allTransitions As TransitionCollection 
				Set allTransitions = currentStateVertex.Transitions
				For k=1 To allTransitions.count
					Dim currentTransition As Transition
					Set currentTransition = allTransitions.GetAt(k)
					currentTransition.stereotype = newStereotype
				Next k
			Next j
		End If
	Next i

End Sub

Sub DelAllCategoryStereotypes(currentCategory As Category)

	If currentCategory Is Nothing Then Exit Sub

	Call DelCategoryStereotypes(currentCategory)

	Dim allCategories As CategoryCollection
	Set allCategories = currentCategory.Categories

	Dim i As Integer
	For i = 1 To allCategories.Count
		Dim aCategory As Category
		Set aCategory = allCategories.getAt(i)
		
		Call DelAllCategoryStereotypes(aCategory) 
	Next i
End Sub

Sub DelSubSystemStereotypes(currentSubsystem As SubSystem)
On Error Resume Next

	currentSubsystem.stereotype = newStereotype

	Dim i As Integer
	Dim allModules As ModuleCollection
	Set allModules = currentSubsystem.Modules
	For i=1 To allModules.count
		Dim currentModule As Module
		Set currentModule = allModules.GetAt(i)
		currentModule.stereotype = newStereotype
	Next i
End Sub

Sub DelAllSubSystemStereotypes(currentSubsystem As Subsystem)

	If currentSubsystem Is Nothing Then Exit Sub

	Call DelSubSystemStereotypes(currentSubsystem)

	Dim allSubSystems As SubSystemCollection
	Set allSubSystems = currentSubSystem.SubSystems

	Dim i As Integer
	For i = 1 To allSubSystems.Count
		Dim aSubSystem As SubSystem
		Set aSubSystem = allSubSystems.getAt(i)
		
		Call DelAllSubSystemStereotypes(aSubSystem) 
	Next i
End Sub

Sub Main
	newStereotype = ""

	Call DelAllCategoryStereotypes(RoseApp.CurrentModel.RootCategory)
	Call DelAllCategoryStereotypes(RoseApp.CurrentModel.RootUseCaseCategory)
	Call DelAllSubSystemStereotypes(RoseApp.CurrentModel.RootSubsystem)

End Sub