读书人

EUML2 PLUGIN运用

发布时间: 2012-11-23 22:54:33 作者: rapoo

EUML2 PLUGIN使用
eUML2是一款基于Eclipse应用程序的UML建模工具。开发者可以在UML开发过程中将模型转化为Java代码:确保软件质量和减少开发时间。

eUML2分为两种版本: eUML2免费版集合了Java开发者所需要的所有基本特性:

类/包图编辑器
序列图编辑器
Ecore图编辑器
实时代码/模型同步
模型导入/导出 包括OMG XMI格式
支持PNG, JPG, 和SVG格式导出图表
视图
颜色参数
模型助手
可以免费使用(甚至可以用于商业目的)。

eUML2商业版是免费版的扩展,增加一些新的和改进的特性。

eUML2可以通过下载安装或通过下面的url直接在Eclipse里更新安装:
http://www.soyatec.com/update
目前只是支持UML Class Diagram 和 UML Sequence Diagram.
以下是我做的一个Sample Of UML Class Diagram:
1.Policy_UML.ucd(UML文件)

<?xml version="1.0" encoding="UTF-8"?><editmodel:ClassDiagramEditModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:editmodel="editmodel.xmi" xmlns:options="options.xmi" name="Policy_Uml" size="977,916" id="com.euml2.uml" metadata="uml2-1.0" initialized="true" tag="1000" key="32303037303533312D3130303020546573745F50726F6A6563742F4A616D736F6E204875616E67">  <children xsi:type="editmodel:ClassEditModel" targetConnections="//@children.1/@sourceConnections.0" name="ContractMstBean" location="120,180" size="150,189" id="com.euml2.Bean/ContractMstBean" runTimeClassModel="getPolicyStatus(),setInsertTime(Ljava.util.Date;),UserId,setUserId(Ljava.lang.String;),PolicyStatus,getInsertTime(),getPolicyCode(),InsertTime,PolicyId,getContractPrdBean(),ContractMstBean(),setPolicyCode(Ljava.lang.String;),getPolicyId(),getPolicyInfo(Ljava.lang.String;Ljava.lang.String;),setPolicyStatus(I),setContractPrdBean(Ljava.util.List;),getUserId(),PolicyCode,setPolicyId(J)">    <children xsi:type="editmodel:CompartmentEditModel" size="106,90">      <children xsi:type="editmodel:AttributeEditModel" name="InsertTime" id="com.euml2.Bean/ContractMstBean#InsertTime"/>      <children xsi:type="editmodel:AttributeEditModel" name="PolicyCode" id="com.euml2.Bean/ContractMstBean#PolicyCode"/>      <children xsi:type="editmodel:AttributeEditModel" name="PolicyId" id="com.euml2.Bean/ContractMstBean#PolicyId"/>      <children xsi:type="editmodel:AttributeEditModel" name="PolicyStatus" id="com.euml2.Bean/ContractMstBean#PolicyStatus"/>      <children xsi:type="editmodel:AttributeEditModel" name="UserId" location="10,82" id="com.euml2.Bean/ContractMstBean#UserId"/>    </children>    <children xsi:type="editmodel:CompartmentEditModel" size="127,36">      <children xsi:type="editmodel:MethodEditModel" name="ContractMstBean" id="com.euml2.Bean/ContractMstBean#ContractMstBean()"/>      <children xsi:type="editmodel:MethodEditModel" name="getContractPrdBean" id="com.euml2.Bean/ContractMstBean#getContractPrdBean()"/>    </children>    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <sourceConnections xsi:type="editmodel:GeneralizationEditModel" autoLocated="true" id="com.euml2.Impl/ContractMstImpl<-com.euml2.Bean/ContractMstBean" source="//@children.0" target="//@children.2" targetEnd="//@children.0/@sourceConnections.0/@children.1" sourceEnd="//@children.0/@sourceConnections.0/@children.0" connectionRouterKind="Manual">      <children xsi:type="editmodel:AssociationEndEditModel" location="77,0" attachSource="true"/>      <children xsi:type="editmodel:AssociationEndEditModel" location="71,57"/>    </sourceConnections>    <classifierPreferences xsi:type="editmodel:UMLClassDiagramClassifierPreference" showStereotype="true" attributeSorter="Natural" methodSorter="Natural" innerClassSorter="Natural" showPrivateAttributes="true" showProtectedAttributes="true" showPublicAttributes="true" showPackageAttributes="true" showPublicMethods="true" showPackageMethods="true" showStaticMethods="true" showProtectedInnerClasses="true" showPublicInnerClasses="true" showPackageInnerClasses="true" packageIndication="3"/>  </children>  <children xsi:type="editmodel:ClassEditModel" name="ContractPrdBean" location="620,165" size="150,171" id="com.euml2.Bean/ContractPrdBean" runTimeClassModel="PolicyId,InsertTime,ProductStatus,getProduct(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;),ProductName,ContractPrdBean(),ProductId">    <children xsi:type="editmodel:CompartmentEditModel" size="121,90">      <children xsi:type="editmodel:AttributeEditModel" name="PolicyId" id="com.euml2.Bean/ContractPrdBean#PolicyId"/>      <children xsi:type="editmodel:AttributeEditModel" name="ProductId" id="com.euml2.Bean/ContractPrdBean#ProductId"/>      <children xsi:type="editmodel:AttributeEditModel" name="ProductName" id="com.euml2.Bean/ContractPrdBean#ProductName"/>      <children xsi:type="editmodel:AttributeEditModel" name="ProductStatus" id="com.euml2.Bean/ContractPrdBean#ProductStatus"/>    </children>    <children xsi:type="editmodel:CompartmentEditModel" size="112,36">      <children xsi:type="editmodel:MethodEditModel" name="ContractPrdBean" id="com.euml2.Bean/ContractPrdBean#ContractPrdBean()"/>      <children xsi:type="editmodel:MethodEditModel" name="getProduct" id="com.euml2.Bean/ContractPrdBean#getProduct(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)"/>    </children>    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <sourceConnections xsi:type="editmodel:AssociationEditModel" name="Policy-Product" autoLocated="true" id="com.euml2.Bean/ContractMstBean@contractMstBean+com.euml2.Bean/ContractPrdBean@contractPrdBean" source="//@children.1" target="//@children.0" targetEnd="//@children.1/@sourceConnections.0/@children.1" label="//@children.1/@sourceConnections.0/@children.2" sourceEnd="//@children.1/@sourceConnections.0/@children.0" connectionRouterKind="Manhattan">      <children xsi:type="editmodel:AssociationEndEditModel" name="contractPrdBean" location="0,92" id="com.euml2.Bean/ContractMstBean@contractMstBean+com.euml2.Bean/ContractPrdBean@contractPrdBean|com.euml2.Bean/ContractPrdBean#contractPrdBean" attachSource="true" multiplicityLabel="//@children.1/@sourceConnections.0/@children.0/@children.1" roleLabel="//@children.1/@sourceConnections.0/@children.0/@children.0" navigable="true" orderingKind="1">        <children xsi:type="editmodel:LabelEditModel" name=" + contractPrdBean" location="528,236" size="93,14" fontInfo="Arial-8-0" anchorKind="FirstPart"/>        <children xsi:type="editmodel:LabelEditModel" name="1..*" location="605,264" size="16,14" fontInfo="Arial-8-0" anchorKind="FirstPart"/>      </children>      <children xsi:type="editmodel:AssociationEndEditModel" name="contractMstBean" location="150,77" id="com.euml2.Bean/ContractMstBean@contractMstBean+com.euml2.Bean/ContractPrdBean@contractPrdBean|com.euml2.Bean/ContractMstBean#contractMstBean" multiplicityLabel="//@children.1/@sourceConnections.0/@children.1/@children.1" roleLabel="//@children.1/@sourceConnections.0/@children.1/@children.0" navigable="true">        <children xsi:type="editmodel:LabelEditModel" name=" - contractMstBean" location="277,236" size="92,14" fontInfo="Arial-8-0" anchorKind="LastPart"/>        <children xsi:type="editmodel:LabelEditModel" name="1" location="277,264" size="6,14" fontInfo="Arial-8-0" anchorKind="LastPart"/>      </children>      <children xsi:type="editmodel:WireLabelEditModel" name="Policy-Product" size="69,14" fontInfo="Arial-8-0" anchorKind="MiddlePart"/>    </sourceConnections>    <sourceConnections xsi:type="editmodel:GeneralizationEditModel" autoLocated="true" id="com.euml2.Impl/ContractPrdImpl<-com.euml2.Bean/ContractPrdBean" source="//@children.1" target="//@children.3" targetEnd="//@children.1/@sourceConnections.1/@children.1" sourceEnd="//@children.1/@sourceConnections.1/@children.0" connectionRouterKind="Manual">      <children xsi:type="editmodel:AssociationEndEditModel" location="72,0" attachSource="true"/>      <children xsi:type="editmodel:AssociationEndEditModel" location="72,57"/>    </sourceConnections>    <classifierPreferences xsi:type="editmodel:UMLClassDiagramClassifierPreference" showStereotype="true" attributeSorter="Natural" methodSorter="Natural" innerClassSorter="Natural" showPublicAttributes="true" showPackageAttributes="true" showStaticAttributes="true" showPublicMethods="true" showPackageMethods="true" showStaticMethods="true" showPublicInnerClasses="true" showPackageInnerClasses="true" showStaticInnerClasses="true" packageIndication="3" showAttributeProperty="true"/>  </children>  <children xsi:type="editmodel:InterfaceEditModel" targetConnections="//@children.0/@sourceConnections.0" name="ContractMstImpl" location="126,15" size="144,57" id="com.euml2.Impl/ContractMstImpl" runTimeClassModel="">    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <classifierPreferences xsi:type="editmodel:UMLClassDiagramClassifierPreference" showStereotype="true" attributeSorter="Natural" methodSorter="Natural" innerClassSorter="Natural" showPublicAttributes="true" showPackageAttributes="true" showStaticAttributes="true" showPublicMethods="true" showPackageMethods="true" showStaticMethods="true" showPublicInnerClasses="true" showPackageInnerClasses="true" showStaticInnerClasses="true" packageIndication="3" showAttributeProperty="true"/>  </children>  <children xsi:type="editmodel:InterfaceEditModel" targetConnections="//@children.1/@sourceConnections.1" name="ContractPrdImpl" location="620,30" size="145,57" id="com.euml2.Impl/ContractPrdImpl" runTimeClassModel="">    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <children xsi:type="editmodel:CompartmentEditModel" size="0,0"/>    <classifierPreferences xsi:type="editmodel:UMLClassDiagramClassifierPreference" showStereotype="true" attributeSorter="Natural" methodSorter="Natural" innerClassSorter="Natural" showPublicAttributes="true" showPackageAttributes="true" showStaticAttributes="true" showPublicMethods="true" showPackageMethods="true" showStaticMethods="true" showPublicInnerClasses="true" showPackageInnerClasses="true" showStaticInnerClasses="true" packageIndication="3" showAttributeProperty="true"/>  </children>  <children xsi:type="editmodel:NotepadEditModel" location="255,180" size="106,26" fontInfo="Arial-8-0" note="保单主类"/>  <children xsi:type="editmodel:NotepadEditModel" location="525,165" size="96,26" fontInfo="Arial-8-0" note="险种主类"/>  <diagramOptions xsi:type="options:ClassDiagramOptions" properties="wireOptions=1;Product=eUML2" autoName="false"/>  <boardSetting snapToGeometry="true" gridEnabled="true" gridSpacing="15,15" gridOrigin="0,0" rulerUnit="pixel" gridVisibility="false">    <leftRuler/>    <topRuler/>  </boardSetting>  <classDiagramPreferences xsi:type="editmodel:UMLClassDiagramPreference" showPopupBars="true" showConnectionHandles="true" attributeSorter="Natural" methodSorter="Natural" showClassStereotype="true" showPackageStereotype="true" showDependencyStereotype="true" showInterfaceStereotype="true" innerClassSorter="Natural" showPublicAttributes="true" showPackageAttributes="true" showStaticAttributes="true" showPublicMethods="true" showPackageMethods="true" showStaticMethods="true" showPublicInnerClasses="true" showPackageInnerClasses="true" showStaticInnerClasses="true" packageIndication="3" showAttributeProperty="true"/></editmodel:ClassDiagramEditModel>

2.对应生成的Java文件:
package com.euml2.Bean;import java.util.Date;import java.util.List;import com.euml2.Impl.ContractMstImpl;/**  * @author Huiwen.Huang */public class ContractMstBean implements ContractMstImpl {/** * get policy info */public String getPolicyInfo(String policyId, String policyCode){return policyId+" "+policyCode;}/** * @uml.property  name="PolicyId" */private long policyId;/**  * Getter of the property <tt>POLICY_ID</tt> * @return  Returns the policy_ids. * @uml.property  name="PolicyId" */public long getPolicyId() {return policyId;}/**  * Setter of the property <tt>POLICY_ID</tt> * @param POLICY_ID  The policy_ids to set. * @uml.property  name="PolicyId" */public void setPolicyId(long policyId) {this.policyId = policyId;}/** * @uml.property  name="PolicyCode" */private String policyCode = "";/**  * Getter of the property <tt>POLICY_CODE</tt> * @return  Returns the policy_codes. * @uml.property  name="PolicyCode" */public String getPolicyCode() {return policyCode;}/**  * Setter of the property <tt>POLICY_CODE</tt> * @param POLICY_CODE  The policy_codes to set. * @uml.property  name="PolicyCode" */public void setPolicyCode(String policyCode) {this.policyCode = policyCode;}/** * @uml.property  name="InsertTime" */private Date insertTime;/**  * Getter of the property <tt>INSERT_TIME</tt> * @return  Returns the insert_time. * @uml.property  name="InsertTime" */public Date getInsertTime() {return insertTime;}/**  * Setter of the property <tt>INSERT_TIME</tt> * @param INSERT_TIME  The insert_time to set. * @uml.property  name="InsertTime" */public void setInsertTime(Date insertTime) {this.insertTime = insertTime;}/** * @uml.property  name="UserId" */private String userId = "";/**  * Getter of the property <tt>User_Id</tt> * @return  Returns the user_Id. * @uml.property  name="UserId" */public String getUserId() {return userId;}/**  * Setter of the property <tt>User_Id</tt> * @param User_Id  The user_Id to set. * @uml.property  name="UserId" */public void setUserId(String userId) {this.userId = userId;}/** */public ContractMstBean(){}/** * @uml.property  name="PolicyStatus" */private int policyStatus;/** * Getter of the property <tt>PolicyStatus</tt> * @return  Returns the policyStatus. * @uml.property  name="PolicyStatus" */public int getPolicyStatus() {return policyStatus;}/** * Setter of the property <tt>PolicyStatus</tt> * @param PolicyStatus  The policyStatus to set. * @uml.property  name="PolicyStatus" */public void setPolicyStatus(int policyStatus) {this.policyStatus = policyStatus;}/**  * @uml.property name="contractPrdBean" * @uml.associationEnd multiplicity="(1 -1)" ordering="true" inverse="contractMstBean:com.euml2.Bean.ContractPrdBean" * @uml.association name="Policy-Product" */private List contractPrdBean;/**  * Getter of the property <tt>contractPrdBean</tt> * @return  Returns the contractPrdBean. * @uml.property  name="contractPrdBean" */public List getContractPrdBean() {return contractPrdBean;}/**  * Setter of the property <tt>contractPrdBean</tt> * @param contractPrdBean  The contractPrdBean to set. * @uml.property  name="contractPrdBean" */public void setContractPrdBean(List contractPrdBean) {this.contractPrdBean = contractPrdBean;}}

附件为Policy_UML.ucd文件。
更多可以查看:http://www.soyatec.cn/euml2/features/eUML2%20Modeler/classdiagrameditor/

读书人网 >Web前端

热点推荐