gui: toggle edit buttons as well
This commit is contained in:
parent
eca27dcd4f
commit
223d13be58
58
main.go
58
main.go
@ -37,6 +37,9 @@ type TMainForm struct {
|
||||
Tabs *vcl.TPageControl
|
||||
propertiesBox *vcl.TMemo
|
||||
contentBox *vcl.TStringGrid
|
||||
dataInsertBtn *vcl.TToolButton
|
||||
dataDelRowBtn *vcl.TToolButton
|
||||
dataCommitBtn *vcl.TToolButton
|
||||
isEditing bool
|
||||
insertRows map[int32]struct{} // Rows in the StringGrid that are to-be-inserted
|
||||
deleteRows map[int32]struct{}
|
||||
@ -237,26 +240,26 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
|
||||
dataRefreshBtn.SetImageIndex(imgArrowRefresh)
|
||||
dataRefreshBtn.SetOnClick(func(sender vcl.IObject) { f.RefreshCurrentItem() })
|
||||
|
||||
dataInsertBtn := vcl.NewToolButton(dataButtonBar)
|
||||
dataInsertBtn.SetParent(dataButtonBar)
|
||||
dataInsertBtn.SetImageIndex(imgAdd)
|
||||
dataInsertBtn.SetHint("Insert")
|
||||
dataInsertBtn.SetShowHint(true)
|
||||
dataInsertBtn.SetOnClick(f.OnDataInsertClick)
|
||||
f.dataInsertBtn = vcl.NewToolButton(dataButtonBar)
|
||||
f.dataInsertBtn.SetParent(dataButtonBar)
|
||||
f.dataInsertBtn.SetImageIndex(imgAdd)
|
||||
f.dataInsertBtn.SetHint("Insert")
|
||||
f.dataInsertBtn.SetShowHint(true)
|
||||
f.dataInsertBtn.SetOnClick(f.OnDataInsertClick)
|
||||
|
||||
dataDelRowBtn := vcl.NewToolButton(dataButtonBar)
|
||||
dataDelRowBtn.SetParent(dataButtonBar)
|
||||
dataDelRowBtn.SetImageIndex(imgDelete)
|
||||
dataDelRowBtn.SetHint("Delete Row")
|
||||
dataDelRowBtn.SetShowHint(true)
|
||||
dataDelRowBtn.SetOnClick(f.OnDataDeleteRowClick)
|
||||
f.dataDelRowBtn = vcl.NewToolButton(dataButtonBar)
|
||||
f.dataDelRowBtn.SetParent(dataButtonBar)
|
||||
f.dataDelRowBtn.SetImageIndex(imgDelete)
|
||||
f.dataDelRowBtn.SetHint("Delete Row")
|
||||
f.dataDelRowBtn.SetShowHint(true)
|
||||
f.dataDelRowBtn.SetOnClick(f.OnDataDeleteRowClick)
|
||||
|
||||
dataCommitBtn := vcl.NewToolButton(dataButtonBar)
|
||||
dataCommitBtn.SetParent(dataButtonBar)
|
||||
dataCommitBtn.SetImageIndex(imgPencilGo)
|
||||
dataCommitBtn.SetHint("Commit")
|
||||
dataCommitBtn.SetShowHint(true)
|
||||
dataCommitBtn.SetOnClick(f.OnDataCommitClick)
|
||||
f.dataCommitBtn = vcl.NewToolButton(dataButtonBar)
|
||||
f.dataCommitBtn.SetParent(dataButtonBar)
|
||||
f.dataCommitBtn.SetImageIndex(imgPencilGo)
|
||||
f.dataCommitBtn.SetHint("Commit")
|
||||
f.dataCommitBtn.SetShowHint(true)
|
||||
f.dataCommitBtn.SetOnClick(f.OnDataCommitClick)
|
||||
|
||||
f.contentBox = vcl.NewStringGrid(dataTab)
|
||||
f.contentBox.SetParent(dataTab)
|
||||
@ -809,16 +812,17 @@ func (f *TMainForm) OnNavChange(sender vcl.IObject, node *vcl.TTreeNode) {
|
||||
f.contentBox.SetEnabled(false)
|
||||
}
|
||||
|
||||
// Toggle the Edit functionality
|
||||
_, ok := ld.(editableLoadedDatabase)
|
||||
f.dataCommitBtn.SetEnabled(ok)
|
||||
f.dataDelRowBtn.SetEnabled(ok)
|
||||
f.dataInsertBtn.SetEnabled(ok)
|
||||
|
||||
// Toggle the Query functionality
|
||||
if _, ok := ld.(queryableLoadedDatabase); ok {
|
||||
f.queryInput.SetEnabled(true)
|
||||
f.queryResult.SetEnabled(true)
|
||||
f.queryExecBtn.SetEnabled(true)
|
||||
} else {
|
||||
f.queryInput.SetEnabled(false)
|
||||
f.queryResult.SetEnabled(false)
|
||||
f.queryExecBtn.SetEnabled(false)
|
||||
}
|
||||
_, ok = ld.(queryableLoadedDatabase)
|
||||
f.queryInput.SetEnabled(ok)
|
||||
f.queryResult.SetEnabled(ok)
|
||||
f.queryExecBtn.SetEnabled(ok)
|
||||
|
||||
// We're in charge of common status bar text updates
|
||||
f.StatusBar.SetSimpleText(ld.DisplayName() + " | " + ld.DriverName())
|
||||
|
Loading…
Reference in New Issue
Block a user