Sidebar-ProcessCoolingComponent.js
3.56 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
(function () {
// Adds Atlassian shapes
// processCooling label
Sidebar.prototype.addThingsKitProcessCoolingPalette = function () {
const gn = 'mxgraph.processCooling';
const dt = 'processCooling';
const label = mxResources.get('processCooling')
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('cooler') + ' 1', path: 'processCooling/冷却器 1.svg' },
{ name: mxResources.get('cooler') + ' 2', path: 'processCooling/冷却器 2.svg' },
{ name: mxResources.get('cooler') + ' 3', path: 'processCooling/冷却器 3.svg' },
{ name: mxResources.get('cooler') + ' 4', path: 'processCooling/冷却器 4.svg' },
{ name: mxResources.get('cooler') + ' 5', path: 'processCooling/冷却器 5.svg' },
{ name: mxResources.get('cooler') + ' 6', path: 'processCooling/冷却器 6.svg' },
{ name: mxResources.get('coolingTower') + ' 1', path: 'processCooling/冷却塔 1.svg' },
{ name: mxResources.get('coolingTower') + ' 2', path: 'processCooling/冷却塔 2.svg' },
{ name: mxResources.get('coolingTower') + ' 3', path: 'processCooling/冷却塔 3.svg' },
{ name: mxResources.get('coolingTower') + ' 4', path: 'processCooling/冷却塔 4.svg' },
{ name: mxResources.get('coolingGroup'), path: 'processCooling/冷却塔群塔.svg' },
{ name: mxResources.get('coldGenerator'), path: 'processCooling/冷发电机冷却器.svg' },
{ name: mxResources.get('reactionProduct'), path: 'processCooling/反应产品冷却器.svg' },
{ name: mxResources.get('englineDriven'), path: 'processCooling/发动机驱动冷却器.svg' },
{ name: mxResources.get('absorptionCooler'), path: 'processCooling/吸收式冷却器.svg' },
{ name: mxResources.get('largePortableCooler'), path: 'processCooling/大型便携式冷却器.svg' },
{ name: mxResources.get('naturalgas'), path: 'processCooling/天然气制冷系统.svg' },
{ name: mxResources.get('waterCooled'), path: 'processCooling/水冷式冷却器.svg' },
{ name: mxResources.get('temControl'), path: 'processCooling/温度控制装置.svg' },
{ name: mxResources.get('simpleCooling'), path: 'processCooling/简单冷却塔.svg' },
{ name: mxResources.get('comfortCooling'), path: 'processCooling/舒适性冷却塔.svg' },
{ name: mxResources.get('explosionProof'), path: 'processCooling/防爆工业冷藏冷冻箱.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();
};
})();