-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifml-view-component-list.js
More file actions
88 lines (67 loc) · 2.28 KB
/
ifml-view-component-list.js
File metadata and controls
88 lines (67 loc) · 2.28 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
import { ModelShapeRect } from 'direwolf-modeler/model-shape-rect.js';
import './ifml-parameter.js';
export class IFMLViewComponentList extends ModelShapeRect {
constructor(id, createdLocally, title = 'View Component', width = 200) {
super(id, createdLocally);
this._title = title;
this._minWidth = 150;
this._width = width;
this._height = 80;
}
createSVGElement(viewport) {
let group = super.createSVGElement(viewport);
this.rect.fill('lightgray').stroke({ width: 1, color: 'black' }).radius(15);
this.titleNode = group.plain('«List» ' + this._title).font({family: 'monospace', color: 'gray'}).attr({y: 20, 'text-anchor': 'middle'}).cx(this._width / 2);
return group;
}
showPortOnHover() {
return true;
}
acceptsChild(modelElementType) {
return (modelElementType === 'ifml-parameter');
}
modelElementDragOver(modelElementType) {
return this.acceptsChild(modelElementType);
}
getChildrenArray() {
let childrenArray = super.getChildrenArray();
if (this._createdLocally) {
let modelId = this.direwolfSpace.getFreshId();
let sharedState = this.direwolfSpace.sharedStates.set(modelId, Y.Map);
sharedState.set('x', (this._width - 150) / 2);
sharedState.set('y', this._height / 2);
sharedState.set('width', 150);
sharedState.set('height', 23);
sharedState.set('typename', 'DataBinding');
sharedState.set('title', 'none');
let syncedModelNode = {};
syncedModelNode.dataType = 'ifml-parameter';
syncedModelNode.id = modelId;
syncedModelNode.parentId = this.id;
childrenArray.push(syncedModelNode);
}
return childrenArray;
}
appendModelChild(modelElement) {
//this.parameter.element.remove();
this.parameter = modelElement;
modelElement.createSVGElement(this.element);
}
/**
* Direwolf-specific methods
*/
sharedStateAvailable(sharedState) {
super.sharedStateAvailable(sharedState);
}
handleSharedStateChanged(event) {
super.handleSharedStateChanged(event);
if (event.type === 'update') {
if (event.name === 'width') {
this.titleNode.attr({x: event.value / 2});
if (this.parameter) {
this.parameter.element.cx((event.value - this.parameter.width) / 2);
}
}
}
}
}