Documentation ¶
Overview ¶
Package jsondocument contains the logic for rendering a Fyne tree from a JSON document.
Index ¶
- Variables
- func MakeURIReadCloser(r io.Reader, name string) uriReadCloser
- type JSONDocument
- func (j *JSONDocument) ChildUIDs(uid widget.TreeNodeID) []widget.TreeNodeID
- func (j *JSONDocument) Extract(uid widget.TreeNodeID) ([]byte, error)
- func (j *JSONDocument) IsBranch(uid widget.TreeNodeID) bool
- func (j *JSONDocument) Load(ctx context.Context, reader fyne.URIReadCloser, progressInfo binding.Untyped) error
- func (j *JSONDocument) Parent(uid widget.TreeNodeID) widget.TreeNodeID
- func (j *JSONDocument) Path(uid widget.TreeNodeID) []widget.TreeNodeID
- func (j *JSONDocument) Reset()
- func (j *JSONDocument) Search(ctx context.Context, uid widget.TreeNodeID, search string, typ SearchType) (widget.TreeNodeID, error)
- func (j *JSONDocument) Size() int
- func (j *JSONDocument) Value(uid widget.TreeNodeID) Node
- type JSONTreeSizer
- type JSONType
- type Node
- type ProgressInfo
- type SearchType
Constants ¶
This section is empty.
Variables ¶
var Empty = struct{}{}
This singleton represents an empty value in a Node.
var ErrCallerCanceled = errors.New("process canceled by caller")
var ErrNotFound = errors.New("not found")
Functions ¶
func MakeURIReadCloser ¶
Creates and returns an URIReadCloser from a reader.
Types ¶
type JSONDocument ¶
type JSONDocument struct { // How often progress info is updated ProgressUpdateTick int32 // contains filtered or unexported fields }
JSONDocument represents a JSON document which can be rendered by a Fyne tree widget.
func (*JSONDocument) ChildUIDs ¶
func (j *JSONDocument) ChildUIDs(uid widget.TreeNodeID) []widget.TreeNodeID
ChildUIDs returns the child UIDs for a given node. This can be used directly in the tree widget childUIDs() function.
func (*JSONDocument) Extract ¶
func (j *JSONDocument) Extract(uid widget.TreeNodeID) ([]byte, error)
Extract returns a segment of the JSON document, with the given UID as new root container. Note that only arrays and objects can be extracted
func (*JSONDocument) IsBranch ¶
func (j *JSONDocument) IsBranch(uid widget.TreeNodeID) bool
IsBranch reports wether a node is a branch. This can be used directly in the tree widget isBranch() function.
func (*JSONDocument) Load ¶
func (j *JSONDocument) Load(ctx context.Context, reader fyne.URIReadCloser, progressInfo binding.Untyped) error
Load loads JSON data from a reader and builds a new JSON document from it. It reports it's current progress to the caller via updates to progressInfo. Closes the reader.
func (*JSONDocument) Parent ¶
func (j *JSONDocument) Parent(uid widget.TreeNodeID) widget.TreeNodeID
Parent returns the UID of the parent node.
func (*JSONDocument) Path ¶
func (j *JSONDocument) Path(uid widget.TreeNodeID) []widget.TreeNodeID
Path returns the path of a node in the tree.
func (*JSONDocument) Search ¶
func (j *JSONDocument) Search(ctx context.Context, uid widget.TreeNodeID, search string, typ SearchType) (widget.TreeNodeID, error)
Search returns the next node with a matching key or an error if not found or canceled. The starting node will be ignored, so that is is possible to find successive nodes with the same key. The search direction is from top to bottom.
func (*JSONDocument) Value ¶
func (j *JSONDocument) Value(uid widget.TreeNodeID) Node
Value returns the value of a node
type JSONTreeSizer ¶
type JSONTreeSizer struct {
// contains filtered or unexported fields
}
JSONTreeSizer is an object for calculating the number of nodes in a tree structure. It is specialized for data produced by un-marshalling a JSON document.
type ProgressInfo ¶
ProgressInfo represents the current progress while loading a document and is used to communicate the the UI.
type SearchType ¶
type SearchType uint
SearchType represents the type of search to perform.
const ( SearchKey SearchType = iota SearchString SearchNumber SearchKeyword )