2024-06-08 01:34:33 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-06-28 00:29:44 +00:00
|
|
|
"errors"
|
|
|
|
|
2024-06-08 01:34:33 +00:00
|
|
|
"github.com/ying32/govcl/vcl"
|
|
|
|
)
|
|
|
|
|
2024-06-28 00:29:44 +00:00
|
|
|
var ErrNavNotExist error = errors.New("The selected item no longer exists")
|
2024-07-06 00:02:58 +00:00
|
|
|
var ErrNotSupported error = errors.New("Unsupported action for this database type")
|
2024-06-28 00:29:44 +00:00
|
|
|
|
2024-06-27 23:34:00 +00:00
|
|
|
type contextAction struct {
|
|
|
|
Name string
|
2024-07-14 03:28:18 +00:00
|
|
|
Callback func(sender vcl.IComponent, ndata *navData) error
|
2024-06-27 23:34:00 +00:00
|
|
|
}
|
|
|
|
|
2024-06-08 01:34:33 +00:00
|
|
|
// loadedDatabase is a DB-agnostic interface for each loaded database.
|
|
|
|
type loadedDatabase interface {
|
|
|
|
DisplayName() string
|
2024-06-14 23:43:24 +00:00
|
|
|
DriverName() string
|
2024-06-08 01:34:33 +00:00
|
|
|
RootElement() *vcl.TTreeNode
|
2024-07-13 06:03:42 +00:00
|
|
|
RenderForNav(f *TMainForm, ndata *navData) error
|
2024-07-05 23:45:41 +00:00
|
|
|
ApplyChanges(f *TMainForm, ndata *navData) error
|
2024-07-05 23:59:55 +00:00
|
|
|
ExecQuery(query string, resultArea *vcl.TStringGrid) error
|
2024-06-08 01:34:33 +00:00
|
|
|
NavChildren(ndata *navData) ([]string, error)
|
2024-06-27 23:34:00 +00:00
|
|
|
NavContext(ndata *navData) ([]contextAction, error)
|
2024-06-08 01:34:33 +00:00
|
|
|
Keepalive(ndata *navData)
|
2024-06-23 03:28:15 +00:00
|
|
|
Close()
|
2024-06-08 01:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// navData is the .Data() pointer for each TTreeNode in the left-hand tree.
|
|
|
|
type navData struct {
|
|
|
|
ld loadedDatabase
|
|
|
|
childrenLoaded bool
|
|
|
|
bucketPath []string
|
|
|
|
}
|