58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package tree
|
|
|
|
import (
|
|
"errors"
|
|
"sync"
|
|
|
|
"go.wit.com/log"
|
|
"go.wit.com/widget"
|
|
)
|
|
|
|
var muAction sync.Mutex
|
|
|
|
func (me *TreeInfo) catchActionChannel() {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Warn(me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r)
|
|
me.SendToolkitPanic()
|
|
panic(-1)
|
|
}
|
|
}()
|
|
log.Info("catchActionChannel() START")
|
|
for {
|
|
log.Info("catchActionChannel() for loop")
|
|
select {
|
|
case a := <-me.pluginChan:
|
|
log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, 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()
|
|
// send this to the toolkit
|
|
if me.ActionFromChannel == nil {
|
|
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
|
|
} else {
|
|
me.ActionFromChannel(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
|
|
}
|