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)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
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:
|
2024-01-18 21:26:36 -06:00
|
|
|
log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName)
|
|
|
|
// log.Warn("catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
|
|
|
|
/*
|
2024-01-18 00:05:54 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2024-01-18 21:26:36 -06:00
|
|
|
*/
|
2024-01-18 00:05:54 -06:00
|
|
|
muAction.Lock()
|
2024-01-18 21:26:36 -06:00
|
|
|
// send this to the toolkit
|
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 {
|
|
|
|
me.ActionFromChannel(a)
|
|
|
|
}
|
2024-01-18 00:05:54 -06:00
|
|
|
muAction.Unlock()
|
2024-01-18 21:26:36 -06:00
|
|
|
// log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
2024-01-18 00:05:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|