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) toolkit(a widget.Action) {
|
|
|
|
if me.ActionFromChannel == nil {
|
|
|
|
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
me.ActionFromChannel(a)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (me *TreeInfo) catchActionChannel() {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
log.Warn("nocui YAHOOOO Recovered in simpleStdin()", r)
|
|
|
|
me.DoToolkitPanic()
|
|
|
|
panic(-1)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
log.Info("catchActionChannel() START")
|
|
|
|
for {
|
|
|
|
log.Info("catchActionChannel() for loop")
|
2024-01-18 04:08:11 -06:00
|
|
|
select {
|
2024-01-18 00:05:54 -06:00
|
|
|
case a := <-me.pluginChan:
|
|
|
|
log.Info("catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName)
|
|
|
|
log.Warn("catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
|
|
|
|
if a.WidgetType == widget.Dropdown {
|
|
|
|
log.Warn("Found dropdown", a.WidgetId, a.ActionType, a.WidgetType)
|
|
|
|
for i, s := range a.State.Strings {
|
|
|
|
log.Warn("a.State.Strings =", i, s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
muAction.Lock()
|
|
|
|
me.toolkit(a)
|
|
|
|
muAction.Unlock()
|
|
|
|
log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func New() *TreeInfo {
|
|
|
|
me := new(TreeInfo)
|
|
|
|
me.pluginChan = make(chan widget.Action, 1)
|
|
|
|
|
|
|
|
log.Info("Init() start channel reciever")
|
|
|
|
go me.catchActionChannel()
|
|
|
|
log.Info("Init() END")
|
|
|
|
return me
|
|
|
|
}
|