-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathFamEventArgsFactory.js
More file actions
51 lines (43 loc) · 1.72 KB
/
FamEventArgsFactory.js
File metadata and controls
51 lines (43 loc) · 1.72 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
import FamEventArgs from './events/FamEventArgs';
import { getElementOffset } from './graphics/dom';
import Rect from './graphics/structs/Rect';
export default function FamEventArgsFactory(data, oldTreeItemId, newTreeItemId, name) {
var result = new FamEventArgs(),
combinedContextsTask = data.tasks.getTask("CombinedContextsTask"),
alignDiagramTask = data.tasks.getTask("AlignDiagramTask"),
logicalFamilyTask = data.tasks.getTask("LogicalFamilyTask"),
oldItemConfig = combinedContextsTask.getConfig(oldTreeItemId),
newItemConfig = combinedContextsTask.getConfig(newTreeItemId),
family = logicalFamilyTask.getLogicalFamily(),
itemPosition,
offset,
panelOffset;
if (oldItemConfig && oldItemConfig.id != null) {
result.oldContext = oldItemConfig;
}
if (newItemConfig && newItemConfig.id != null) {
result.context = newItemConfig;
family.loopParents(this, newItemConfig.id, function (itemid, item, levelIndex) {
if (levelIndex > 0) {
return family.BREAK;
}
result.parentItems.push(combinedContextsTask.getConfig(itemid));
});
family.loopChildren(this, newItemConfig.id, function (itemid, item, levelIndex) {
if (levelIndex > 0) {
return family.BREAK;
}
result.childrenItems.push(combinedContextsTask.getConfig(itemid));
});
panelOffset = getElementOffset(data.layout.mousePanel);
offset = getElementOffset(data.layout.element);
itemPosition = alignDiagramTask.getItemPosition(newTreeItemId);
result.position = new Rect(itemPosition.actualPosition)
.translate(panelOffset.left, panelOffset.top)
.translate(-offset.left, -offset.top);
}
if (name != null) {
result.name = name;
}
return result;
};