need proper locking
This commit is contained in:
parent
5e1ec700fd
commit
860908c82f
|
@ -134,7 +134,7 @@ func (me *TreeInfo) doAction(a widget.Action) {
|
|||
me.Hide(n)
|
||||
}
|
||||
log.Info("tree: todo: remove child from parent")
|
||||
n.DeleteNode()
|
||||
me.DeleteNode(n)
|
||||
// now remove the child from the parent
|
||||
default:
|
||||
log.Log(TREEWARN, "tree.Action() unknown action", a.ActionType, "on wId", a.WidgetId)
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
)
|
||||
|
||||
func (me *TreeInfo) AddNode(a *widget.Action) *Node {
|
||||
// me.Lock()
|
||||
// defer me.Unlock()
|
||||
return AddNode(a)
|
||||
}
|
||||
|
||||
|
@ -54,7 +56,9 @@ func AddNode(a *widget.Action) *Node {
|
|||
return n
|
||||
}
|
||||
|
||||
func (n *Node) DeleteNode() {
|
||||
func (me *TreeInfo) DeleteNode(n *Node) {
|
||||
me.Lock()
|
||||
defer me.Unlock()
|
||||
p := n.Parent
|
||||
for i, child := range p.children {
|
||||
log.Log(TREE, "parent has child:", i, child.WidgetId, child.GetProgName())
|
||||
|
|
51
table.go
51
table.go
|
@ -47,12 +47,29 @@ func (me *TreeInfo) doTable(a widget.Action) {
|
|||
// log.Info("TREE already has UUID", i, ot.Uuid)
|
||||
if t.Uuid == ot.Uuid {
|
||||
log.Info("TREE found UUID! update table here", i, ot.Uuid)
|
||||
if ot.Grid == nil {
|
||||
log.Info("TREE found UUID! ot.grid.Id = nil. need to find grid id here")
|
||||
return
|
||||
} else {
|
||||
log.Info("TREE found UUID! grid.Id =", ot.Grid.Id)
|
||||
t.Grid = ot.Grid
|
||||
}
|
||||
if t.Grid == nil {
|
||||
log.Info("TREE found UUID! grid.Id = nil. need to find grid id here")
|
||||
return
|
||||
}
|
||||
log.Info("TREE found UUID! update table here", i, ot.Uuid, "grid.Id =", t.Grid.Id)
|
||||
me.updateTable(t)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
me.currentTables = append(me.currentTables, t)
|
||||
if t.Grid == nil {
|
||||
log.Info("NEW TREE ERROR: grid.Id = nil need to set grid id here")
|
||||
} else {
|
||||
log.Info("NEW TREE: grid.Id =", t.Grid.Id)
|
||||
}
|
||||
me.makeTable(t)
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +90,27 @@ func (grid *Node) makeGridLabel(pb *guipb.Widget, w int, h int) *Node {
|
|||
}
|
||||
|
||||
func (me *TreeInfo) updateTable(t *guipb.Table) {
|
||||
// log.Info("todo: compare table here...")
|
||||
grid := FindWidgetId(int(t.Grid.Id))
|
||||
if grid == nil {
|
||||
log.Info("tree: updateTable() failed to make grid")
|
||||
return
|
||||
}
|
||||
// delete the existing table
|
||||
me.DeleteNode(grid)
|
||||
|
||||
// remake the table
|
||||
me.Add(grid)
|
||||
var h int = 0
|
||||
var w int = 0
|
||||
for _, name := range t.Order {
|
||||
me.updateRow(t, name)
|
||||
// log.Info("got order:", t.Title, name)
|
||||
if me.addTableRow(t, grid, name, w) {
|
||||
// log.Info("tree:row() COLUMN GOOD", t.Title, name, w, h)
|
||||
} else {
|
||||
log.Info("tree:row() COLOMN FAIL", t.Title, name, w, h)
|
||||
}
|
||||
|
||||
w += 1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,18 +204,6 @@ func (me *TreeInfo) makeTable(t *guipb.Table) {
|
|||
|
||||
w += 1
|
||||
}
|
||||
|
||||
/*
|
||||
for i, r := range t.StringRows {
|
||||
log.Info("got string row:", t.Title, i, r.Header, r.Vals)
|
||||
for _, v := range r.Widgets {
|
||||
log.Info("tree: add to grid here", v.Id, v.Name)
|
||||
lab := grid.makeGridLabel(v, w, h)
|
||||
me.Add(lab)
|
||||
h += 1
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (me *TreeInfo) addTableRow(t *guipb.Table, grid *Node, name string, w int) bool {
|
||||
|
|
Loading…
Reference in New Issue