-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_source_format_editor.go
62 lines (52 loc) · 1.62 KB
/
data_source_format_editor.go
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
package simplemap
import (
"github.com/gazercloud/gazerui/uicontrols"
"github.com/gazercloud/gazerui/uievents"
"github.com/gazercloud/gazerui/uiinterfaces"
)
type DataSourceFormatEditor struct {
uicontrols.Dialog
text string
txtFilePath *uicontrols.TextBox
textInit string
panelDetails *uicontrols.Panel
}
func NewDataSourceFormatEditor(parent uiinterfaces.Widget, textInit string) *DataSourceFormatEditor {
var c DataSourceFormatEditor
c.InitControl(parent, &c)
c.SetTitle("Select file")
c.Resize(600, 400)
c.textInit = textInit
c.text = textInit
pContent := c.ContentPanel().AddPanelOnGrid(0, 0)
c.txtFilePath = pContent.AddTextBoxOnGrid(0, 0)
c.txtFilePath.SetText(c.text)
c.txtFilePath.OnTextChanged = func(txtBox *uicontrols.TextBox, oldValue string, newValue string) {
c.text = newValue
}
pContent.AddTextBlockOnGrid(0, 1, "Format: \r\n{v} = value \r\n{uom} = unit of measure \r\n{d} = date \r\n{t} = time")
pContent.AddVSpacerOnGrid(0, 5)
pButtons := c.ContentPanel().AddPanelOnGrid(0, 1)
pButtons.AddHSpacerOnGrid(0, 0)
btnOK := pButtons.AddButtonOnGrid(1, 0, "OK", nil)
c.TryAccept = func() bool {
return true
}
btnOK.SetMinWidth(70)
btnCancel := pButtons.AddButtonOnGrid(2, 0, "Cancel", func(event *uievents.Event) {
c.Reject()
})
btnCancel.SetMinWidth(70)
c.SetAcceptButton(btnOK)
c.SetRejectButton(btnCancel)
return &c
}
func EditDataSourceFormat(parent uiinterfaces.Widget, initText string, selected func(filePath string)) {
dialog := NewDataSourceFormatEditor(parent, initText)
dialog.ShowDialog()
dialog.OnAccept = func() {
if selected != nil {
selected(dialog.text)
}
}
}