2024-01-18 00:05:54 -06:00
|
|
|
package tree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2024-01-18 04:08:11 -06:00
|
|
|
"sync"
|
2024-01-18 00:05:54 -06:00
|
|
|
|
|
|
|
"go.wit.com/log"
|
2024-01-18 04:08:11 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:05:54 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var muAction sync.Mutex
|
|
|
|
|
|
|
|
func (me *TreeInfo) catchActionChannel() {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
2024-01-18 14:58:48 -06:00
|
|
|
log.Warn(me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r)
|
2024-01-19 12:08:21 -06:00
|
|
|
me.SendToolkitPanic()
|
2024-01-18 00:05:54 -06:00
|
|
|
panic(-1)
|
|
|
|
}
|
|
|
|
}()
|
2024-01-21 10:25:41 -06:00
|
|
|
log.Log(TREE, "catchActionChannel() START")
|
2024-01-18 00:05:54 -06:00
|
|
|
for {
|
2024-01-21 10:25:41 -06:00
|
|
|
log.Log(TREE, "catchActionChannel() for loop")
|
2024-01-18 04:08:11 -06:00
|
|
|
select {
|
2024-01-18 00:05:54 -06:00
|
|
|
case a := <-me.pluginChan:
|
2024-01-18 21:26:36 -06:00
|
|
|
log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName)
|
2024-01-18 00:05:54 -06:00
|
|
|
muAction.Lock()
|
2024-01-19 12:08:21 -06:00
|
|
|
if me.ActionFromChannel == nil {
|
|
|
|
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
|
|
|
|
} else {
|
2024-01-21 14:43:46 -06:00
|
|
|
// send this to the toolkit
|
2024-01-19 12:08:21 -06:00
|
|
|
me.ActionFromChannel(a)
|
|
|
|
}
|
2024-01-18 00:05:54 -06:00
|
|
|
muAction.Unlock()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func New() *TreeInfo {
|
|
|
|
me := new(TreeInfo)
|
|
|
|
me.pluginChan = make(chan widget.Action, 1)
|
|
|
|
|
2024-01-21 10:25:41 -06:00
|
|
|
/*
|
2024-01-21 14:43:46 -06:00
|
|
|
full := "go.wit.com/gui"
|
|
|
|
short := "gui"
|
|
|
|
TREE = log.NewFlag("TREE", true, full, short, "treeRoot info")
|
2024-01-21 10:25:41 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
log.Log(TREE, "Init() start channel reciever")
|
2024-01-18 00:05:54 -06:00
|
|
|
go me.catchActionChannel()
|
2024-01-21 10:25:41 -06:00
|
|
|
log.Log(TREE, "Init() END")
|
2024-01-18 00:05:54 -06:00
|
|
|
return me
|
|
|
|
}
|