Sidebar-PowerComponent.js
6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
(function () {
// Adds Atlassian shapes
// power label
Sidebar.prototype.addThingsKitPowerPalette = function () {
const gn = 'mxgraph.power';
const dt = 'power';
const label = mxResources.get('powerSupply')
const width = 66;
const height = 74;
const prefix = `image;image=${window?.PROJECT_ENV.base}/webapp/images/thingskit/libs/`
const defaultStyle = ';imageAspect=0;'
this.setCurrentSearchEntryLibrary(dt);
const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum
function createUserObject(attribute) {
attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');
Object.keys(attribute).forEach(key => {
xmlElement.setAttribute(key, attribute[key]);
})
return xmlElement
}
// 自定义属性
const cellAttribute = {
[COMPONENT_KEY]: 'Image',
[CATEGORY]: 'DEFAULT'
}
const graphPathLib = [
{ name: mxResources.get('powerSupply1'), path: 'power/三相开关盒.svg' },
{ name: mxResources.get('powerSupply2'), path: 'power/不间断电源.svg' },
{ name: mxResources.get('powerSupply3'), path: 'power/交流驱动.svg' },
{ name: mxResources.get('powerSupply4'), path: 'power/交流驱动2.svg' },
{ name: mxResources.get('powerSupply5'), path: 'power/仪表.svg' },
{ name: mxResources.get('powerSupply6'), path: 'power/供热机组.svg' },
{ name: mxResources.get('powerSupply7'), path: 'power/功率监控器.svg' },
{ name: mxResources.get('powerSupply8'), path: 'power/半导体控制整流器组装.svg' },
{ name: mxResources.get('powerSupply9'), path: 'power/双线电线杆.svg' },
{ name: mxResources.get('powerSupply10'), path: 'power/发电厂.svg' },
{ name: mxResources.get('powerSupply11'), path: 'power/发电机.svg' },
{ name: mxResources.get('powerSupply12'), path: 'power/发电机2.svg' },
{ name: mxResources.get('powerSupply13'), path: 'power/变压器.svg' },
{ name: mxResources.get('powerSupply14'), path: 'power/变压器监控器.svg' },
{ name: mxResources.get('powerSupply15'), path: 'power/变压器组件.svg' },
{ name: mxResources.get('powerSupply16'), path: 'power/变速传动.svg' },
{ name: mxResources.get('powerSupply17'), path: 'power/基座.svg' },
{ name: mxResources.get('powerSupply18'), path: 'power/套管.svg' },
{ name: mxResources.get('powerSupply19'), path: 'power/工业风力发电机 1.svg' },
{ name: mxResources.get('powerSupply20'), path: 'power/工业风力发电机 2.svg' },
{ name: mxResources.get('powerSupply21'), path: 'power/工业风力发电机 3.svg' },
{ name: mxResources.get('powerSupply22'), path: 'power/带电线的电线杆.svg' },
{ name: mxResources.get('powerSupply23'), path: 'power/护具装置.svg' },
{ name: mxResources.get('powerSupply24'), path: 'power/控制系统.svg' },
{ name: mxResources.get('powerSupply25'), path: 'power/插座.svg' },
{ name: mxResources.get('powerSupply26'), path: 'power/整流器 1.svg' },
{ name: mxResources.get('powerSupply27'), path: 'power/整流器 2.svg' },
{ name: mxResources.get('powerSupply28'), path: 'power/断路器.svg' },
{ name: mxResources.get('powerSupply29'), path: 'power/柴油发电机.svg' },
{ name: mxResources.get('powerSupply30'), path: 'power/柴油支持UPS系统.svg' },
{ name: mxResources.get('powerSupply31'), path: 'power/核反应堆.svg' },
{ name: mxResources.get('powerSupply32'), path: 'power/核电站.svg' },
{ name: mxResources.get('powerSupply33'), path: 'power/沼气发电.svg' },
{ name: mxResources.get('powerSupply34'), path: 'power/测温变阻器.svg' },
{ name: mxResources.get('powerSupply35'), path: 'power/燃气轮机.svg' },
{ name: mxResources.get('powerSupply36'), path: 'power/瓷绝缘体.svg' },
{ name: mxResources.get('powerSupply37'), path: 'power/电子仪表.svg' },
{ name: mxResources.get('powerSupply38'), path: 'power/电涌放电器.svg' },
{ name: mxResources.get('powerSupply39'), path: 'power/电源板.svg' },
{ name: mxResources.get('powerSupply40'), path: 'power/电线杆 1.svg' },
{ name: mxResources.get('powerSupply41'), path: 'power/电线杆 2.svg' },
{ name: mxResources.get('powerSupply42'), path: 'power/电线杆 3.svg' },
{ name: mxResources.get('powerSupply43'), path: 'power/电线杆 4.svg' },
{ name: mxResources.get('powerSupply44'), path: 'power/电线杆 5.svg' },
{ name: mxResources.get('powerSupply45'), path: 'power/电缆分线箱.svg' },
{ name: mxResources.get('powerSupply46'), path: 'power/电解器.svg' },
{ name: mxResources.get('powerSupply47'), path: 'power/直流电源.svg' },
{ name: mxResources.get('powerSupply48'), path: 'power/真空开关.svg' },
{ name: mxResources.get('powerSupply49'), path: 'power/简易变电站.svg' },
{ name: mxResources.get('powerSupply50'), path: 'power/绝缘体.svg' },
{ name: mxResources.get('powerSupply51'), path: 'power/起动机.svg' },
{ name: mxResources.get('powerSupply52'), path: 'power/车用蓄电池.svg' },
{ name: mxResources.get('powerSupply53'), path: 'power/输电塔.svg' },
{ name: mxResources.get('powerSupply54'), path: 'power/重合器 2.svg' },
{ name: mxResources.get('powerSupply55'), path: 'power/重合器.svg' },
{ name: mxResources.get('powerSupply56'), path: 'power/集中太阳能发电厂 1.svg' },
{ name: mxResources.get('powerSupply57'), path: 'power/集中太阳能发电厂 2.svg' },
{ name: mxResources.get('powerSupply58'), path: 'power/马达驱动.svg' },
]
const fns = graphPathLib.map(item => {
return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
const cell = new mxCell(createUserObject(cellAttribute), new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
cell.setVertex(true)
return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
}));
})
this.setGalleryLib(dt, label, graphPathLib)
this.addPaletteFunctions(dt, label, false, fns);
this.setCurrentSearchEntryLibrary();
};
})();