我们可以使用xml保存mxEditor的自定义图元的自定义业务数据,这可以通过在自定义图元的节点中增加属性来完成,比如,在wfeditor-commons文件中的templates中,我们可以增加如下模板:
<add as="mysubprocess">
<MySubprocess label="" statename="Subprocess" description="子流程" mode="p" subflowname="" href="">
<InParameterRelations></InParameterRelations>
<OutParameterRelations></OutParameterRelations>
<mxCell vertex="1" style="rounded">
<mxGeometry as="geometry" width="72" height="32"/>
</mxCell>
</MySubprocess>
</add>
在添加图元后,可以使用自定义的编辑页面修改自定义的属性,修改完成后,我们希望图元的标签使用业务数据显示,比如上面的图元,我们希望标签显示的内容是statename(description)。这时,可以使用如下代码,更新标签:
if (atts['label'] != null) {
var lab = namecontent;
if (desccontent) lab = lab + "(" + desccontent + ")";
var edit = new mxCellAttributeChange(
this.cell, 'label',
lab);
model.execute(edit);
}