'***Patrick Rutledge, Rational Support, 10/98 'This script sets the language of all classes to that selected by the user. It's 'for people who created their classes with Analysis as their default language 'and now want to get a language tab on their class specs without using components. 'It won't work on classes that already have a language (I don't know why). It works 'by assigning a component of whatever language to the classes and then deleting it. ' ***** Keng Lim ***** ' ' Modified 13 December 1998 - Use the RemovedAssignModule method prior to setting the ' Language. Works now for classes with a language already assigned ' Added "Oracle8" and "Analysis" as options ' If the class has a module (hence Language assigned) the the assignment is removed ' The new language assigned to the module and the module reassigned back to the class. ' This allows existing class/component structure to be maintained. ' For classes without components, the language is assigned via a dummy component ' and the component deleted, as original version. Begin Dialog SelectLangDialog 81,64, 150, 170,"Select a Language" OKButton 10,140,40,14 CancelButton 60,140,40,14 Text 4,8, 80, 12, "Select a Language" GroupBox 4, 20, 110, 110, "Languages" OptionGroup .LangGroup OptionButton 10, 30, 60, 12, "C++", .CPPOpt OptionButton 10, 45, 60, 12, "Java", .JavaOpt OptionButton 10, 60, 60, 12, "VB", .VBOpt OptionButton 10, 75, 60, 12, "Oracle8", .OracleOpt OptionButton 10, 90, 60, 12, "CORBA", .CorbaOpt OptionButton 10, 105, 60, 12, "Analysis", .AnalysisOpt End Dialog Sub Main Dim aClass As Class Dim Dummy As Class Dim allClasses As ClassCollection Dim dummyMod As Module Dim oldMod As Module Dim oldModules As ModuleCollection Dim langDlog As SelectLangDialog r% = Dialog(langDlog) If r% = 0 Then Exit Sub 'cancel End If Select Case langDlog.LangGroup Case 0 lang$ = "C++" Case 1 lang$ = "Java" Case 2 lang$ = "Visual Basic" Case 3 lang$ = "Oracle8" Case 4 lang$ = "CORBA" Case 5 lang$ = "Analysis" End Select ' Get all classes in the model ' Use the second statement if you want to change selected classes only ' Tip : Place classes in a diagram then select them. Set allClasses = RoseApp.CurrentModel.GetAllClasses() ' Set allClasses = RoseApp.CurrentModel.GetSelectedClasses () Set dummyMod = RoseApp.CurrentModel.RootSubsystem.AddModule("Dummy") dummyMod.AssignedLanguage = lang$ For i% = 1 To allClasses.Count Set aClass = allClasses.GetAt(i%) Set oldModules = aClass.GetAssignedModules ' Remove language assigned components, If it exists ' Assign new Language and reassign to classes If oldModules.Count > 0 Then For j = 1 To oldModules.Count Set oldMod = oldModules.GetAt(j) aClass.RemoveAssignedModule oldMod oldMod.AssignedLanguage = lang$ aClass.AddAssignedModule oldMod Next j Else aClass.AddAssignedModule dummyMod End If Next i% worked = RoseApp.CurrentModel.RootSubsystem.DeleteModule(dummyMod) MsgBox lang$ + " Successfully Assigned to Classses" End Sub