1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
package gui
import "log"
import "fmt"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew"
import pb "git.wit.com/wit/witProtobuf"
func ShowVM() {
name := Data.CurrentVM
log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM)
VMwin := ui.NewWindow("VM " + name, 500, 300, false)
VMwin.OnClosing(func(*ui.Window) bool {
return true
})
ui.OnShouldQuit(func() bool {
VMwin.Destroy()
VMwin = nil
return true
})
VMtab := ui.NewTab()
VMwin.SetChild(VMtab)
VMwin.SetMargined(true)
createVmBox(VMtab, mouseClick, Data.CurrentPbVM)
VMwin.Show()
}
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
createVmBox(Data.cloudTab, mouseClick, Data.CurrentPbVM)
}
// makeEntryBox(box, "hostname:", "blah.foo.org") {
func makeEntryVbox(hbox *ui.Box, a string, b string, edit bool) {
// Start 'Nickname' vertical box
vboxN := ui.NewVerticalBox()
vboxN.SetPadded(true)
vboxN.Append(ui.NewLabel(a), false)
entryNick := ui.NewEntry()
entryNick.SetText(b)
if (edit == false) {
entryNick.SetReadOnly(true)
}
vboxN.Append(entryNick, false)
entryNick.OnChanged(func(*ui.Entry) {
log.Println("OK. TEXT WAS CHANGED TO =", entryNick.Text())
// Data.AccNick = entryNick.Text()
})
hbox.Append(vboxN, false)
// End 'Nickname' vertical box
}
func makeEntryHbox(hbox *ui.Box, a string, b string, edit bool) {
// Start 'Nickname' vertical box
hboxN := ui.NewHorizontalBox()
hboxN.SetPadded(true)
hboxN.Append(ui.NewLabel(a), false)
entryNick := ui.NewEntry()
entryNick.SetText(b)
if (edit == false) {
entryNick.SetReadOnly(true)
}
hboxN.Append(entryNick, false)
entryNick.OnChanged(func(*ui.Entry) {
log.Println("OK. TEXT WAS CHANGED TO =", entryNick.Text())
// Data.AccNick = entryNick.Text()
})
hbox.Append(hboxN, false)
// End 'Nickname' vertical box
}
func createVmBox(tab *ui.Tab, custom func(*ButtonMap), pbVM *pb.Event_VM) {
log.Println("createVmBox() START")
log.Println("createVmBox() pbVM.Name", pbVM.Name)
spew.Dump(pbVM)
if (Data.Debug) {
spew.Dump(pbVM)
}
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hboxAccount := ui.NewHorizontalBox()
hboxAccount.SetPadded(true)
vbox.Append(hboxAccount, false)
// Add hostname entry box
makeEntryVbox(hboxAccount, "hostname:", pbVM.Hostname, true)
makeEntryVbox(hboxAccount, "IPv6:", pbVM.IPv6, true)
makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",pbVM.Memory), true)
makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",pbVM.Cpus), true)
makeEntryVbox(hboxAccount, "Disk (GB):", fmt.Sprintf("%d",pbVM.Disk), true)
makeEntryVbox(hboxAccount, "OS Image:", pbVM.BaseImage, true)
vbox.Append(ui.NewHorizontalSeparator(), false)
hboxButtons := ui.NewHorizontalBox()
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
hboxButtons.Append(CreateButton("Power On", "POWERON", custom), false)
hboxButtons.Append(CreateButton("Power Off", "POWEROFF", custom), false)
hboxButtons.Append(CreateButton("Destroy", "DESTROY", custom), false)
hboxButtons.Append(CreateButton("Console", "XTERM", runTestExecClick), false)
hboxButtons.Append(CreateButton("Save", "SAVE", custom), false)
hboxButtons.Append(CreateButton("Done", "DONE", custom), false)
tab.Append(Data.CurrentVM, vbox)
tab.SetMargined(0, true)
}
func createAddVmBox(tab *ui.Tab, name string, custom func(*ButtonMap)) {
log.Println("createAddVmBox() START")
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hboxAccount := ui.NewHorizontalBox()
hboxAccount.SetPadded(true)
vbox.Append(hboxAccount, false)
// Add hostname entry box
makeEntryHbox(hboxAccount, "hostname:", "", true)
vbox.Append(ui.NewHorizontalSeparator(), false)
hboxButtons := ui.NewHorizontalBox()
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
hboxButtons.Append(CreateButton("Add Virtual Machine", "CREATE", custom), false)
hboxButtons.Append(CreateButton("Cancel", "DONE", custom), false)
tab.Append(name, vbox)
tab.SetMargined(0, true)
}
|