Sidebar-FactoryFacilitiesComponent.js 4.96 KB

(function () {
	// Adds Atlassian shapes
	// factoryFacilities label
	Sidebar.prototype.addThingsKitfactoryFacilitiesPalette = function () {

		const gn = 'mxgraph.factoryFacilities';
		const dt = 'factoryFacilities';
		const label = mxResources.get('factoryFacilities')
		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('pulpFactory'), path: 'factoryFacilities/制浆厂.svg' },
			{ name: mxResources.get('processingFactory'), path: 'factoryFacilities/加工工厂.svg' },
			{ name: mxResources.get('crane'), path: 'factoryFacilities/吊车.svg' },
			{ name: mxResources.get('refinery'), path: 'factoryFacilities/提炼厂.svg' },
			{ name: mxResources.get('barbedWireMesh'), path: 'factoryFacilities/有刺铁丝网.svg' },
			{ name: mxResources.get('ladder') + '1', path: 'factoryFacilities/梯子 1.svg' },
			{ name: mxResources.get('ladder') + '2', path: 'factoryFacilities/梯子 2.svg' },
			{ name: mxResources.get('floorOffice'), path: 'factoryFacilities/楼层办公室.svg' },
			{ name: mxResources.get('floorPlywood'), path: 'factoryFacilities/楼层夹板.svg' },
			{ name: mxResources.get('staircase')+'2', path: 'factoryFacilities/楼梯 2.svg' },
			{ name: mxResources.get('staircase')+'3', path: 'factoryFacilities/楼梯 3.svg' },
			{ name: mxResources.get('staircase')+'4', path: 'factoryFacilities/楼梯 4.svg' },
			{ name: mxResources.get('staircase')+'5', path: 'factoryFacilities/楼梯 5.svg' },
			{ name: mxResources.get('staircase'), path: 'factoryFacilities/楼梯.svg' },
			{ name: mxResources.get('lightSmoke'), path: 'factoryFacilities/淡烟.svg' },
			{ name: mxResources.get('chimney') + '2', path: 'factoryFacilities/烟囱 2.svg' },
			{ name: mxResources.get('chimney') + '2', path: 'factoryFacilities/烟囱 3.svg' },
			{ name: mxResources.get('chimney') , path: 'factoryFacilities/烟囱.svg' },
			{ name: mxResources.get('productionPLatform')+'1', path: 'factoryFacilities/生产平台 1.svg' },
			{ name: mxResources.get('productionPLatform')+'2', path: 'factoryFacilities/生产平台 2.svg' },
			{ name: mxResources.get('productionPLatform')+'3', path: 'factoryFacilities/生产平台 3.svg' },
			{ name: mxResources.get('productionEquipment'), path: 'factoryFacilities/生产设备.svg' },
			{ name: mxResources.get('oilDrilling'), path: 'factoryFacilities/石油钻塔.svg' },
			{ name: mxResources.get('BrickChimney'), path: 'factoryFacilities/砖烟囱.svg' },
			{ name: mxResources.get('BrickChimneyWith'), path: 'factoryFacilities/砖烟囱带架.svg' },
			{ name: mxResources.get('emergencyDevice'), path: 'factoryFacilities/紧急喷淋装置.svg' },
			{ name: mxResources.get('redAndWhite'), path: 'factoryFacilities/红白条烟囱.svg' },
			{ name: mxResources.get('greenBarbed'), path: 'factoryFacilities/绿色有刺铁丝网.svg' },
			{ name: mxResources.get('greenWireMesh'), path: 'factoryFacilities/绿色铁丝网.svg' },
			{ name: mxResources.get('channelLadder'), path: 'factoryFacilities/通道梯.svg' },
			{ name: mxResources.get('pyramidCOmmunication'), path: 'factoryFacilities/金字塔型通信塔.svg' },
			{ name: mxResources.get('steelGrating') + '1', path: 'factoryFacilities/钢格板 1.svg' },
			{ name: mxResources.get('steelGrating') + '2', path: 'factoryFacilities/钢格板 2.svg' },
			{ name: mxResources.get('drillingEquipment'), path: 'factoryFacilities/钻探设备.svg' },
			{ name: mxResources.get('wireMesh'), path: 'factoryFacilities/铁丝网.svg' },
			{ name: mxResources.get('protectiveScreen'), path: 'factoryFacilities/防护筛.svg' },
			{ name: mxResources.get('protectiveScreen') +'2', path: 'factoryFacilities/防护筛2.svg' },
			{ name: mxResources.get('blackSmoke'), path: 'factoryFacilities/黑色烟雾.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();
	};
})();