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