func (t *signalGraphType) AddNewObject(tree tr.TreeIf, cursor tr.Cursor, obj tr.TreeElementIf) (newCursor tr.Cursor, err error) { switch obj.(type) { case bh.NodeIf: // TODO: Check if IO node and exists: copy position only and return n := obj.(bh.NodeIf) err = t.AddNode(n) if err != nil { err = fmt.Errorf("signalGraphType.AddNewObject error: %s", err) nt := n.ItsType().(*nodeType) if nt != nil { ok, _ := nt.instances.Find(n) if ok { nt.instances.Remove(n) } } return } newCursor = t.treeAddNewObject(tree, cursor, n) parent := tree.Object(cursor) switch parent.(type) { case bh.SignalGraphIf: case bh.ImplementationIf: // propagate new node to all instances of embracing type pCursor := tree.Parent(cursor) nt := tree.Object(pCursor) for _, nn := range nt.(bh.NodeTypeIf).Instances() { nCursor := tree.Cursor(nn) tCursor := tree.CursorAt(nCursor, parent) tCursor.Position = cursor.Position t.treeAddNewObject(tree, tCursor, n) } default: log.Fatalf("signalGraphType.AddNewObject error: wrong parent type %T: %v\n", parent, parent) } case bh.ConnectionIf: conn := obj.(bh.ConnectionIf) var n bh.NodeIf var p bh.PortIf for _, n = range t.Nodes() { if n.Name() == conn.From().Node().Name() { nCursor := tree.CursorAt(cursor, n) for _, p = range n.OutPorts() { if conn.From().Name() == p.Name() { pCursor := tree.CursorAt(nCursor, p) return p.AddNewObject(tree, pCursor, obj) } } } } default: log.Fatalf("signalGraphType.AddNewObject error: wrong type %t: %v\n", obj, obj) } return }