-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodePinOutput.js
84 lines (68 loc) · 1.53 KB
/
NodePinOutput.js
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
class NodePinOutput extends NodePinInput {
static OUTPUT_NODE_TYPE = 'output';
constructor(parentNode) {
super(parentNode);
delete this.sourceOutputVarName;
//this.pythonKernelVariable = null;
this.inputs = [];
}
addInput(input) {
this.inputs.push(input);
}
removeInput(input) {
if (this.inputs.includes(input)) {
this.inputs.splice(this.inputs.indexOf(input), 1);
}
}
makePin() {
return super.makePin().addClass('node-output-pin');
}
makePinDiv() {
var div = $('<div>').addClass('node-output');
div.append(this.getPin());
div.append(this.getField());
this.div = div;
return div;
}
updateWire(transform) {
for (var i of this.inputs) {
i.updateWire(transform);
}
}
getOutput() {
return null;
}
setOutput(o) {
return;
}
getOutputVariable() {
if (!this.name) {
this.setOutputVariable(VarSpace.newName());
}
//return this.pythonKernelVariable;
return this.name
}
setOutputVariable(name) {
this.name = name;
this.inputDiv[0].placeholder = this.name;
}
getType() {
return NodePinOutput.OUTPUT_NODE_TYPE;
}
onSerialize() {
var inputNode = super.onSerialize(this);
var obj = {};
obj.inputNode = inputNode;
obj.name = this.getOutputVariable();
return JSON.stringify(obj);
}
onDeserialize(string) {
var obj = JSON.parse(string);
super.onDeserialize(obj.inputNode);
if (!obj) {
return this;
}
this.setOutputVariable(obj.name);
return this;
}
}