dynamically add tabs. work around the JSON config file problem

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-07 14:54:08 -07:00
parent e4233a1251
commit dc3f440e47
5 changed files with 60 additions and 13 deletions

View File

@ -95,6 +95,10 @@ func parseConfig() {
log.Println(config.String("map1.key1.jwc1"))
cloud := config.StringMap("cloud")
fmt.Printf("%#v\n",cloud)
for account, _ := range config.StringMap("cloud") {
port := config.String("cloud." + account + ".port")
proto := config.String("cloud." + account + ".proto")
hostname := config.String("cloud." + account + ".hostname")
fmt.Println(hostname, port, proto)
}
}

View File

@ -9,7 +9,13 @@
],
"baseKey": "value2",
"cloud": {
"v000185.testing.com.customers.wprod.wit.com": {
"jcarr": {
"hostname": "fire.lab.wit.com",
"port": 3333,
"proto": "tcp"
},
"v000185": {
"hostname": "v000185.testing.com.customers.wprod.wit.com",
"port": 3333,
"proto": "tcp"
}

View File

@ -8,6 +8,12 @@ cloud:
v000185.testing.com.customers.wprod.wit.com:
port: 3333
proto: tcp
jcarr:
port: 3333
proto: tcp
foo.bar:
port: 3333
proto: tcp
map1:
key1:

35
gui.go
View File

@ -13,6 +13,8 @@ import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
var mainwin *ui.Window
var maintab *ui.Tab
var tabcount int
func hostnameButton(hostname string) ui.Control {
tmpbox := ui.NewHorizontalBox()
@ -242,25 +244,38 @@ func setupUI() {
return true
})
tab := ui.NewTab()
mainwin.SetChild(tab)
maintab = ui.NewTab()
mainwin.SetChild(maintab)
mainwin.SetMargined(true)
name := "v000185.testing.com.customers.wprod.wit.com"
tab.Append(name, makeDemotable(name))
tab.SetMargined(0, true)
maintab.Append(name, makeDemotable(name))
tabcount = 0
maintab.SetMargined(tabcount, true)
name = "jcarrTable"
table, mh, model := makeJcarrtable(name)
log.Println(table, mh, model)
tab.Append(name, table)
tab.SetMargined(1, true)
maintab.Append(name, table)
tabcount += 1
maintab.SetMargined(tabcount, true)
tab.Append("List examples", makeNumbersPage())
tab.SetMargined(2, true)
maintab.Append("List examples", makeNumbersPage())
tabcount += 1
maintab.SetMargined(tabcount, true)
tab.Append("Choosers examples", makeDataChoosersPage())
tab.SetMargined(3, true)
maintab.Append("Choosers examples", makeDataChoosersPage())
tabcount += 1
maintab.SetMargined(tabcount, true)
mainwin.Show()
}
func addTableTab(name string) {
table, mh, model := makeJcarrtable(name)
log.Println(table, mh, model)
tabcount += 1
maintab.Append(name, table)
maintab.SetMargined(tabcount, true)
}

16
main.go
View File

@ -72,6 +72,22 @@ func main() {
go doGUI()
log.Println("Sleep for 2 seconds, then try to add new tabs")
time.Sleep(2 * 1000 * 1000 * 1000)
log.Println("Sleep for 2 seconds, then try to add new tabs")
time.Sleep(2 * 1000 * 1000 * 1000)
log.Println("Sleep for 2 seconds, then try to add new tabs")
time.Sleep(2 * 1000 * 1000 * 1000)
for account, _ := range config.StringMap("cloud") {
port := config.String("cloud." + account + ".port")
proto := config.String("cloud." + account + ".proto")
hostname := config.String("cloud." + account + ".hostname")
fmt.Println(hostname, port, proto)
addTableTab(account)
}
for {
log.Println("Sleep for 10 seconds, then try to establish connection to WIT")