successfully add 2 tabs dynamically
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
dc3f440e47
commit
369a8941a8
4
gui.go
4
gui.go
|
@ -271,8 +271,8 @@ func setupUI() {
|
|||
mainwin.Show()
|
||||
}
|
||||
|
||||
func addTableTab(name string) {
|
||||
table, mh, model := makeJcarrtable(name)
|
||||
func addTableTab(name string, rows int, row1name string) {
|
||||
table, mh, model := makeTable(name, rows, row1name)
|
||||
log.Println(table, mh, model)
|
||||
|
||||
tabcount += 1
|
||||
|
|
2
main.go
2
main.go
|
@ -86,7 +86,7 @@ func main() {
|
|||
proto := config.String("cloud." + account + ".proto")
|
||||
hostname := config.String("cloud." + account + ".hostname")
|
||||
fmt.Println(hostname, port, proto)
|
||||
addTableTab(account)
|
||||
addTableTab(account, 4, hostname)
|
||||
}
|
||||
|
||||
for {
|
||||
|
|
50
table.go
50
table.go
|
@ -46,7 +46,7 @@ func newDefaultModelHandler() *modelHandler {
|
|||
mh.vms[8].hostname = "fire"
|
||||
mh.vms[9].hostname = "librem15.this.is.a.really.long.string.test"
|
||||
mh.yellowRow = -1
|
||||
log.Println("Called newModelhandler() with mh=", mh)
|
||||
log.Println("Called newDefaultModelhandler() with mh=", mh)
|
||||
spew.Dump(mh)
|
||||
return mh
|
||||
}
|
||||
|
@ -60,21 +60,25 @@ func newJcarrModelHandler() *modelHandler {
|
|||
mh.vms[8].hostname = "jcarr"
|
||||
mh.vms[9].hostname = "jcarr2"
|
||||
mh.yellowRow = -1
|
||||
log.Println("Called newModelhandler() with mh=", mh)
|
||||
log.Println("Called newJcarrModelhandler() with mh=", mh)
|
||||
spew.Dump(mh)
|
||||
return mh
|
||||
}
|
||||
|
||||
func standardColumnTypes() []ui.TableValue {
|
||||
return []ui.TableValue{
|
||||
ui.TableColor{}, // row background color
|
||||
ui.TableString(""), // column 0 text
|
||||
ui.TableColor{}, // column 0 text color
|
||||
ui.TableString("test"), // column 1 button text
|
||||
}
|
||||
}
|
||||
|
||||
func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue {
|
||||
// log.Println("ColumnTypes() with m=", m, "mh=", mh)
|
||||
if (mh.name == "jcarrTable") {
|
||||
// log.Println("ColumnTypes() with m=", m, "mh=", mh)
|
||||
return []ui.TableValue{
|
||||
ui.TableColor{}, // row background color
|
||||
ui.TableString(""), // column 0 text
|
||||
ui.TableColor{}, // column 0 text color
|
||||
ui.TableString("test"), // column 1 button text
|
||||
}
|
||||
return standardColumnTypes()
|
||||
}
|
||||
return []ui.TableValue{
|
||||
ui.TableString(""), // column 0 text
|
||||
|
@ -229,3 +233,33 @@ func makeJcarrtable(name string) (*ui.Table, *modelHandler, *ui.TableModel) {
|
|||
|
||||
return table, mh, model
|
||||
}
|
||||
|
||||
func newModelHandler(rows int) *modelHandler {
|
||||
mh := new(modelHandler)
|
||||
mh.rows = rows
|
||||
mh.bgcolorColumn = 0
|
||||
mh.checkStates = make([]int, mh.rows)
|
||||
mh.vms = make([]vmRowData, mh.rows)
|
||||
mh.vms[1].hostname = "jcarr"
|
||||
mh.yellowRow = -1
|
||||
log.Println("Called newModelhandler() with mh=", mh)
|
||||
spew.Dump(mh)
|
||||
return mh
|
||||
}
|
||||
|
||||
func makeTable(name string, rows int, row1Name string) (*ui.Table, *modelHandler, *ui.TableModel) {
|
||||
mh := newModelHandler(rows)
|
||||
mh.name = name
|
||||
model := ui.NewTableModel(mh)
|
||||
|
||||
table := ui.NewTable(
|
||||
&ui.TableParams{
|
||||
Model: model,
|
||||
RowBackgroundColorModelColumn: mh.bgcolorColumn,
|
||||
})
|
||||
|
||||
table.AppendTextColumn(row1Name, 1, ui.TableModelColumnNeverEditable, nil)
|
||||
table.AppendButtonColumn("Details", 3, ui.TableModelColumnAlwaysEditable)
|
||||
|
||||
return table, mh, model
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue