StarUML添加自定义approach和profile
来源:fasiondog
添加Approch
StarUML中的Approch也就是创建项目时的模板,其中预定义了所使用方法的模型和视图。StarUML默认Approach如下:
StarUML的Approach使用XML定义,在其安装路径如“\Program Files (x86)\StarUML\modules\staruml-standard\approaches”下。每个Approach一个子目录,包含和Approach目录同名的.ico和.apr文件,其中.ico就是显示的图标,.apr其实就是个XML文件。用文本编辑器打开.apr文件照着修改即可,如:
<?xml version=“1.0″ encoding=“UTF-8″ ?>
<APPROACH version=“1.0″>
<HEADER>
<NAME>Default</NAME>
<DISPLAYNAME>FJNX Approach</DISPLAYNAME>
<DESCRIPTION>FJNX Apporach for StarUML</DESCRIPTION>
</HEADER>
<BODY>
<IMPORTPROFILES>
<PROFILE>UMLStandard</PROFILE>
</IMPORTPROFILES>
<MODELSTRUCTURE>
<MODEL name=“Use Case Model” stereotypeProfile=“UMLStandard” stereotypeName=“useCaseModel”>
<DIAGRAM type=“UseCase” name=“Main”/>
</MODEL>
<MODEL name=“Analysis Model” stereotypeProfile=“UMLStandard” stereotypeName=“analysisModel”>
<DIAGRAM type=“Class” diagramTypeProfile=“UMLStandard” diagramTypeName=“RobustnessDiagram” name=“Main” defaultDiagram=“True”/>
</MODEL>
<MODEL name=“Design Model” stereotypeProfile=“UMLStandard” stereotypeName=“designModel”>
<DIAGRAM type=“Class” name=“Main” defaultDiagram=“True”/>
</MODEL>
<MODEL name=“Implementation Model” stereotypeProfile=“UMLStandard” stereotypeName=“implementationModel”>
<DIAGRAM type=“Component” name=“Main”/>
</MODEL>
<MODEL name=“Deployment Model” stereotypeProfile=“UMLStandard” stereotypeName=“deploymentModel”>
<DIAGRAM type=“Deployment” name=“Main”/>
</MODEL>
</MODELSTRUCTURE>
</BODY>
</APPROACH>
<APPROACH version=“1.0″>
<HEADER>
<NAME>Default</NAME>
<DISPLAYNAME>FJNX Approach</DISPLAYNAME>
<DESCRIPTION>FJNX Apporach for StarUML</DESCRIPTION>
</HEADER>
<BODY>
<IMPORTPROFILES>
<PROFILE>UMLStandard</PROFILE>
</IMPORTPROFILES>
<MODELSTRUCTURE>
<MODEL name=“Use Case Model” stereotypeProfile=“UMLStandard” stereotypeName=“useCaseModel”>
<DIAGRAM type=“UseCase” name=“Main”/>
</MODEL>
<MODEL name=“Analysis Model” stereotypeProfile=“UMLStandard” stereotypeName=“analysisModel”>
<DIAGRAM type=“Class” diagramTypeProfile=“UMLStandard” diagramTypeName=“RobustnessDiagram” name=“Main” defaultDiagram=“True”/>
</MODEL>
<MODEL name=“Design Model” stereotypeProfile=“UMLStandard” stereotypeName=“designModel”>
<DIAGRAM type=“Class” name=“Main” defaultDiagram=“True”/>
</MODEL>
<MODEL name=“Implementation Model” stereotypeProfile=“UMLStandard” stereotypeName=“implementationModel”>
<DIAGRAM type=“Component” name=“Main”/>
</MODEL>
<MODEL name=“Deployment Model” stereotypeProfile=“UMLStandard” stereotypeName=“deploymentModel”>
<DIAGRAM type=“Deployment” name=“Main”/>
</MODEL>
</MODELSTRUCTURE>
</BODY>
</APPROACH>
添加profile
Profile用于定义Stereotype和TagValue,Stereotype为UML类型原型,可以指定特定的图形,如Actor。TagValue主要用于为每个UML类型独有的属性设定一个标识,可利用该标识进行文档导出操作,如优先级、ID等。和Approach一样,也在安装路径“\Program Files (x86)\StarUML\modules\staruml-standard\”下的profiles子目录中。默认有一个umlstandard的profile,可以直接在其中增加自己的stereo和tag,也可以复制一份换个名称后再自定义。其定义也是用XML格式,用文本编辑器即可编辑,其文件后缀为.prf。如为UseCaseSpecification添加优先级和编号两个Tag:
<TAGDEFINITIONSET>
<NAME>UseCaseSpecification</NAME>
<BASECLASSES>
<BASECLASS>UMLUseCase</BASECLASS>
</BASECLASSES>
<TAGDEFINITIONLIST><TAGDEFINITION>
<NAME>Priority</NAME>
<TAGTYPE>String</TAGTYPE>
</TAGDEFINITION><TAGDEFINITION>
<NAME>ID</NAME>
<TAGTYPE>String</TAGTYPE>
</TAGDEFINITION></TAGDEFINITIONLIST>
</TAGDEFINITIONSET>
<NAME>UseCaseSpecification</NAME>
<BASECLASSES>
<BASECLASS>UMLUseCase</BASECLASS>
</BASECLASSES>
<TAGDEFINITIONLIST><TAGDEFINITION>
<NAME>Priority</NAME>
<TAGTYPE>String</TAGTYPE>
</TAGDEFINITION><TAGDEFINITION>
<NAME>ID</NAME>
<TAGTYPE>String</TAGTYPE>
</TAGDEFINITION></TAGDEFINITIONLIST>
</TAGDEFINITIONSET>