Skip to main content

jellyflow_runtime/runtime/lookups/apply/
mod.rs

1mod edges;
2mod groups;
3mod nodes;
4mod ports;
5
6use super::NodeGraphLookups;
7use jellyflow_core::core::Graph;
8use jellyflow_core::ops::{GraphOp, GraphTransaction};
9
10impl NodeGraphLookups {
11    pub fn apply_transaction(&mut self, graph: &Graph, tx: &GraphTransaction) {
12        for op in tx.ops() {
13            if !self.apply_op(graph, op) {
14                self.rebuild_from(graph);
15                return;
16            }
17        }
18    }
19
20    fn apply_op(&mut self, graph: &Graph, op: &GraphOp) -> bool {
21        match op {
22            GraphOp::AddNode { id, node } => self.apply_add_node(*id, node),
23            GraphOp::RemoveNode { id, edges, .. } => self.apply_remove_node(*id, edges),
24            GraphOp::SetNodePos { id, to, .. } => self.apply_set_node_pos(graph, *id, *to),
25            GraphOp::SetNodeOrigin { id, to, .. } => self.apply_set_node_origin(*id, *to),
26            GraphOp::SetNodeKind { id, to, .. } => self.apply_set_node_kind(graph, *id, to),
27            GraphOp::SetNodeKindVersion { id, to, .. } => {
28                self.apply_set_node_kind_version(graph, *id, *to)
29            }
30            GraphOp::SetNodeParent { id, to, .. } => self.apply_set_node_parent(*id, *to),
31            GraphOp::SetNodeSize { id, to, .. } => self.apply_set_node_size(*id, *to),
32            GraphOp::SetNodeHidden { id, to, .. } => self.apply_set_node_hidden(*id, *to),
33            GraphOp::SetNodeCollapsed { id, to, .. } => self.apply_set_node_collapsed(*id, *to),
34            GraphOp::SetNodePorts { id, to, .. } => self.apply_set_node_ports(graph, *id, to),
35            GraphOp::SetNodeData { id, .. } => self.apply_set_node_data(*id),
36            GraphOp::RemovePort {
37                id, port, edges, ..
38            } => self.apply_remove_port(*id, port, edges),
39            GraphOp::AddPort { id, .. }
40            | GraphOp::SetPortType { id, .. }
41            | GraphOp::SetPortData { id, .. }
42            | GraphOp::SetPortConnectable { id, .. }
43            | GraphOp::SetPortConnectableStart { id, .. }
44            | GraphOp::SetPortConnectableEnd { id, .. } => {
45                self.apply_port_node_internals_change(graph, *id)
46            }
47            GraphOp::AddEdge { id, .. } => self.apply_add_edge(graph, *id),
48            GraphOp::RemoveEdge { id, .. } => self.apply_remove_edge(*id),
49            GraphOp::SetEdgeKind { id, to, .. } => self.apply_set_edge_kind(graph, *id, *to),
50            GraphOp::SetEdgeReconnectable { id, to, .. } => {
51                self.apply_set_edge_reconnectable(graph, *id, *to)
52            }
53            GraphOp::SetEdgeEndpoints { id, from, to } => {
54                self.apply_set_edge_endpoints(graph, *id, *from, *to)
55            }
56            GraphOp::RemoveGroup { detached, .. } => self.apply_remove_group(detached),
57
58            GraphOp::SetNodeSelectable { .. }
59            | GraphOp::SetNodeFocusable { .. }
60            | GraphOp::SetNodeDraggable { .. }
61            | GraphOp::SetNodeConnectable { .. }
62            | GraphOp::SetNodeDeletable { .. }
63            | GraphOp::SetNodeExtent { .. }
64            | GraphOp::SetNodeExpandParent { .. }
65            | GraphOp::SetEdgeSelectable { .. }
66            | GraphOp::SetEdgeFocusable { .. }
67            | GraphOp::SetEdgeHidden { .. }
68            | GraphOp::SetEdgeInteractionWidth { .. }
69            | GraphOp::SetEdgeDeletable { .. }
70            | GraphOp::SetEdgeData { .. }
71            | GraphOp::SetEdgeView { .. }
72            | GraphOp::AddImport { .. }
73            | GraphOp::RemoveImport { .. }
74            | GraphOp::SetImportAlias { .. }
75            | GraphOp::AddSymbol { .. }
76            | GraphOp::RemoveSymbol { .. }
77            | GraphOp::SetSymbolName { .. }
78            | GraphOp::SetSymbolType { .. }
79            | GraphOp::SetSymbolDefaultValue { .. }
80            | GraphOp::SetSymbolMeta { .. }
81            | GraphOp::AddGroup { .. }
82            | GraphOp::SetGroupRect { .. }
83            | GraphOp::SetGroupTitle { .. }
84            | GraphOp::SetGroupColor { .. }
85            | GraphOp::AddStickyNote { .. }
86            | GraphOp::RemoveStickyNote { .. }
87            | GraphOp::SetStickyNoteText { .. }
88            | GraphOp::SetStickyNoteRect { .. }
89            | GraphOp::SetStickyNoteColor { .. }
90            | GraphOp::AddBinding { .. }
91            | GraphOp::RemoveBinding { .. }
92            | GraphOp::SetBindingSubject { .. }
93            | GraphOp::SetBindingTarget { .. }
94            | GraphOp::SetBindingKind { .. }
95            | GraphOp::SetBindingMeta { .. } => true,
96        }
97    }
98}