Fix pins retrieval

This commit is contained in:
barsdeveloper
2022-03-19 19:04:39 +01:00
parent 42615b93f8
commit b4ee181eb5
7 changed files with 46 additions and 123 deletions

View File

@@ -7,7 +7,6 @@ import KeyboardSelectAll from "./input/keybaord/KeyboardSelectAll"
import LinkElement from "./element/LinkElement"
import MouseScrollGraph from "./input/mouse/MouseScrollGraph"
import MouseTracking from "./input/mouse/MouseTracking"
import MultiKeyWeakMap from "./MultiKeyMap"
import NodeElement from "./element/NodeElement"
import Paste from "./input/common/Paste"
import Select from "./input/mouse/Select"
@@ -15,30 +14,15 @@ import SelectorElement from "./element/SelectorElement"
import Unfocus from "./input/mouse/Unfocus"
import Utility from "./Utility"
import Zoom from "./input/mouse/Zoom"
import PinReferenceEntity from "./entity/PinReferenceEntity"
/**
* @typedef {import("./entity/GuidEntity").default} GuidEntity
* @typedef {import("./element/PinElement").default} PinElement
* @typedef {import("./entity/GuidEntity").default} GuidEntity
* @typedef {import("./entity/PinReferenceEntity").default} PinReferenceEntity
*/
export default class Blueprint extends IElement {
static tagName = "ueb-blueprint"
/** @type {MultiKeyWeakMap<String, PinElement>} */
#pinGuidMap = new Proxy(new MultiKeyWeakMap(), {
get(target, p, receiver) {
if (p instanceof PinReferenceEntity) {
p = [p.objectName, p.pinGuid]
}
return Reflect.get(target, p)
},
set(target, p, value) {
if (p instanceof PinReferenceEntity) {
p = [p.objectName, p.pinGuid]
}
return Reflect.set(target, p, value)
}
})
/** @type {number} */
gridSize = Configuration.gridSize
/** @type {NodeElement[]}" */
@@ -323,7 +307,7 @@ export default class Blueprint extends IElement {
* @param {PinReferenceEntity} pinReference
*/
getPin(pinReference) {
return this.#pinGuidMap[pinReference]
return this.template.getPin(this, pinReference)
}
/**
@@ -364,14 +348,6 @@ export default class Blueprint extends IElement {
const intoArray = element => {
if (element instanceof NodeElement) {
this.nodes.push(element)
element.getPinElements().forEach(
pinElement => this.#pinGuidMap[
new PinReferenceEntity({
objectName: pinElement.getNodeElement().getNodeName(),
pinGuid: pinElement.GetPinId(),
})
] = pinElement
)
} else if (element instanceof LinkElement) {
this.links.push(element)
}