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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
package gui
import "log"
import "fmt"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew"
// var subdomain *ui.Entry
func AddEntry(box *GuiBox, name string) *GuiEntry {
var ge *GuiEntry
ge = new(GuiEntry)
ue := ui.NewEntry()
ue.SetReadOnly(false)
ue.OnChanged(func(*ui.Entry) {
log.Println("gui.AddEntry() OK. ue.Text() =", ue.Text())
})
box.UiBox.Append(ue, false)
ge.E = ue
box.EntryMap[name] = ge
return ge
}
func AddAccountQuestionBox(wm *GuiWindow) *ui.Box {
var gb *GuiBox
gb = new(GuiBox)
gb.EntryMap = make(map[string]*GuiEntry)
gb.EntryMap["test"] = nil
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
wm.Box1 = vbox
gb.UiBox = vbox
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
vbox.Append(hbox, false)
hbox.Append(ui.NewLabel("Enter your Subdomain or"), false)
button1 := CreateButton(wm, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
button1.Box = gb
hbox.Append(button1.B, false)
AddEntry(gb, "SUBDOMAIN")
// AddEntry(gb, "USERNAME")
vbox.Append(ui.NewHorizontalSeparator(), false)
button2 := CreateButton(wm, nil, nil, "Create Subdomain Account", "ADD", nil)
button2.Box = gb
vbox.Append(button2.B, false)
return vbox
}
func GetText(box *GuiBox, name string) string {
if (box == nil) {
log.Println("gui.GetText() ERROR box == nil")
return ""
}
if (box.EntryMap == nil) {
log.Println("gui.GetText() ERROR b.Box.EntryMap == nil")
return ""
}
spew.Dump(box.EntryMap)
if (box.EntryMap[name] == nil) {
log.Println("gui.GetText() ERROR box.EntryMap[", name, "] == nil ")
return ""
}
e := box.EntryMap[name]
log.Println("gui.GetText() box.EntryMap[", name, "] = ", e.E.Text())
log.Println("gui.GetText() END")
return e.E.Text()
}
func SetText(box *GuiBox, name string, value string) error {
if (box == nil) {
return fmt.Errorf("gui.SetText() ERROR box == nil")
}
if (box.EntryMap == nil) {
return fmt.Errorf("gui.SetText() ERROR b.Box.EntryMap == nil")
}
spew.Dump(box.EntryMap)
if (box.EntryMap[name] == nil) {
return fmt.Errorf("gui.SetText() ERROR box.EntryMap[", name, "] == nil ")
}
e := box.EntryMap[name]
log.Println("gui.SetText() box.EntryMap[", name, "] = ", e.E.Text())
e.E.SetText(value)
log.Println("gui.SetText() box.EntryMap[", name, "] = ", e.E.Text())
log.Println("gui.SetText() END")
return nil
}
func generateSubdomain(b *GuiButton) {
log.Println("generateSubdomain START")
if (b == nil) {
log.Println("generateSubdomain ERROR b == nil")
return
}
// subdomain.SetText("cust00013.wit.dev")
txt := SetText(b.Box, "SUBDOMAIN", "cust001.testing.com.customers.wpord.wit.com")
log.Println("generateSubdomain subdomain = ", txt)
log.Println("generateSubdomain END")
}
func addSubdomain(b *GuiButton) {
log.Println("addSubdomain START")
// sub := subdomain.Text()
// log.Println("generateSubdomain subdomain =", sub)
log.Println("addSubdomain END")
}
func AddAccountBox(wm *GuiWindow) *ui.Box {
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hboxAccount := ui.NewHorizontalBox()
hboxAccount.SetPadded(true)
vbox.Append(hboxAccount, false)
// Start 'Provider' vertical box
vboxC := ui.NewVerticalBox()
vboxC.SetPadded(true)
vboxC.Append(ui.NewLabel("Cloud Provider:"), false)
cbox := ui.NewCombobox()
cbox.Append("WIT")
cbox.Append("Evocative")
vboxC.Append(cbox, false)
cbox.SetSelected(0)
cbox.OnSelected(func(*ui.Combobox) {
log.Println("OK. Selected Cloud Provider =", cbox.Selected())
})
hboxAccount.Append(vboxC, false)
// End 'Cloud Provider' vertical box
// Start 'Region' vertical box
vboxR := ui.NewVerticalBox()
vboxR.SetPadded(true)
vboxR.Append(ui.NewLabel("Region:"), false)
regbox := ui.NewCombobox()
regbox.Append("Any")
regbox.Append("SF")
vboxR.Append(regbox, false)
regbox.SetSelected(0)
regbox.OnSelected(func(*ui.Combobox) {
log.Println("OK. Selected something =", regbox.Selected())
})
hboxAccount.Append(vboxR, false)
// End 'Region' vertical box
// Start 'Nickname' vertical box
vboxN := ui.NewVerticalBox()
vboxN.SetPadded(true)
vboxN.Append(ui.NewLabel("Account Nickname:"), false)
Data.EntryNick = ui.NewEntry()
Data.EntryNick.SetReadOnly(false)
vboxN.Append(Data.EntryNick, false)
Data.EntryNick.OnChanged(func(*ui.Entry) {
log.Println("OK. nickname =", Data.EntryNick.Text())
// Data.AccNick = entryNick.Text()
})
hboxAccount.Append(vboxN, false)
// End 'Nickname' vertical box
// Start 'Username' vertical box
vboxU := ui.NewVerticalBox()
vboxU.SetPadded(true)
vboxU.Append(ui.NewLabel("Account Username:"), false)
Data.EntryUser = ui.NewEntry()
Data.EntryUser.SetReadOnly(false)
vboxU.Append(Data.EntryUser, false)
Data.EntryUser.OnChanged(func(*ui.Entry) {
log.Println("OK. username =", Data.EntryUser.Text())
// Data.AccUser = entryUser.Text()
})
hboxAccount.Append(vboxU, false)
// End 'Username' vertical box
// Start 'Password' vertical box
vboxP := ui.NewVerticalBox()
vboxP.SetPadded(true)
vboxP.Append(ui.NewLabel("Account Password:"), false)
Data.EntryPass = ui.NewEntry()
Data.EntryPass.SetReadOnly(false)
vboxP.Append(Data.EntryPass, false)
Data.EntryPass.OnChanged(func(*ui.Entry) {
log.Println("OK. password =", Data.EntryPass.Text())
// Data.AccPass = entryPass.Text()
})
hboxAccount.Append(vboxP, false)
// End 'Password' vertical box
vbox.Append(ui.NewHorizontalSeparator(), false)
hboxButtons := ui.NewHorizontalBox()
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
okButton := CreateButton(wm, nil, nil, "Add Account", "ADD", nil)
hboxButtons.Append(okButton.B, false)
backButton := CreateButton(wm, nil, nil, "Back", "BACK", nil)
hboxButtons.Append(backButton.B, false)
return vbox
}
|