diagrammer

package
v0.0.0-...-6648e19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

diagrammer is a package that manages

A model that contains elements of different categories A portfolio that contains diagrams with shapes. Each shape is related to one element, one kind of shape for each kind of element

Two trees:

- a "model" tree displays all elements of the models - a "portfolio" tree displays all diagrams in the folder

the "diagrams" tree allows for the selection of a diagram within the diagram package the "model" tree allows for the addition/suppression of shapes in the diagram

the "model" tree is construed by getting informations from the model

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexOf

func IndexOf(slice []PortfolioNode, value PortfolioNode) int

Types

type ButtonType

type ButtonType int
const (
	DUPLICATE ButtonType = iota
	EDIT_CANCEL
	EDIT
	REMOVE
	RENAME_CANCEL
	RENAME
	SAVE
)

type Diagrammer

type Diagrammer struct {
	// contains filtered or unexported fields
}

func NewDiagrammer

func NewDiagrammer(
	model Model,
	portfolio Portfolio,
	treeStage *gongtree_models.StageStruct,

) (diagrammer *Diagrammer)

func (*Diagrammer) AddPortfiolioNodeTreeNodeEntry

func (diagrammer *Diagrammer) AddPortfiolioNodeTreeNodeEntry(portfolioNode PortfolioNode, treeNode *gongtree_models.Node)

func (*Diagrammer) CommitTreeStage

func (diagrammer *Diagrammer) CommitTreeStage()

func (*Diagrammer) FillUpModelTree

func (diagrammer *Diagrammer) FillUpModelTree(modelTree *gongtree_models.Tree)

FillUpModelTree ranges over Model Root Nodes and recursively fill up the Model Tree

func (*Diagrammer) FillUpPortfolioUITree

func (diagrammer *Diagrammer) FillUpPortfolioUITree(portfolioUITree *gongtree_models.Tree)

FillUpPortfolioUITree ranges over Portfolio Root Nodes and recursively fill up the Tree UI from the Portfolio tree

func (*Diagrammer) GetElementNodeDisplayed

func (diagrammer *Diagrammer) GetElementNodeDisplayed(modelElementNode ModelElementNode) (shape Shape, ok bool)

func (*Diagrammer) GetMap_elementNode_treeNode

func (diagrammer *Diagrammer) GetMap_elementNode_treeNode() map[ModelElementNode]*gongtree_models.Node

func (*Diagrammer) GetPortfiolioNodeFromTreeNode

func (diagrammer *Diagrammer) GetPortfiolioNodeFromTreeNode(portfolioNode PortfolioNode) (treeNode *gongtree_models.Node)

func (*Diagrammer) IsElementDisplayed

func (diagrammer *Diagrammer) IsElementDisplayed(modelElement any) (ok bool)

func (*Diagrammer) IsElementNodeDisplayed

func (diagrammer *Diagrammer) IsElementNodeDisplayed(modelElementNode ModelElementNode) (ok bool)

func (*Diagrammer) RemovePortfiolioNodeTreeNodeEntry

func (diagrammer *Diagrammer) RemovePortfiolioNodeTreeNodeEntry(portfolioNode PortfolioNode)

type Model

type Model interface {
	GenerateProgeny() []ModelNode
	GetChildren() []ModelNode
}

type ModelElementNode

type ModelElementNode interface {
	ModelNode

	GetElement() any

	// CanBeAddedToDiagram returns true if the model element can be displayed
	CanBeAddedToDiagram() bool
	AddToDiagram()
	RemoveFromDiagram()
}

type ModelNode

type ModelNode interface {
	GenerateProgeny() []ModelNode
	GetChildren() []ModelNode
	// GetParent returns the node above
	GetParent() ModelNode

	GetName() string
	IsNameEditable() bool

	IsExpanded() bool
	SetIsExpanded(isExpanded bool)
}

type ModelNodeImpl

type ModelNodeImpl struct {
	// contains filtered or unexported fields
}

func (*ModelNodeImpl) OnAfterUpdate

func (modelNodeImpl *ModelNodeImpl) OnAfterUpdate(stage *gongtree_models.StageStruct, stagedNode *gongtree_models.Node, frontNode *gongtree_models.Node)

OnAfterUpdate implements models.NodeImplInterface

type Portfolio

type Portfolio interface {

	// GeneratesProgeny generates and returns the root nodes of the tree for navigating the portfolio
	// root nodes themselves generate their progreny
	GeneratesProgeny() []PortfolioNode

	// GetChildren return the root nodes
	GetChildren() []PortfolioNode

	// IsInSelectionMode is true is at least one diagram has been selected
	IsInSelectionMode() bool // the end user can select a diagram to display
	GetSelectedPortfolioDiagramNode() PortfolioDiagramNode

	IsInDrawingMode() bool
	AddElementToDiagram(ModelElementNode) map[ModelElementNode]Shape
	RemoveElementFromDiagram(ModelElementNode) map[ModelElementNode]Shape
}

Portfolio interface to be implemented by the Portfolio adapter

type PortfolioCategoryNode

type PortfolioCategoryNode interface {
	PortfolioNode

	// HasAddDiagramButton is true if a "Add" button has to be displayed
	// when the add button is pressed, it calls AddDiagram()
	HasAddDiagramButton() bool

	// AddDiagram allows the end user to request the creation a new Diagram/PortfolioNode
	AddDiagram() PortfolioDiagramNode
}

type PortfolioCategoryNodeButtonAddImpl

type PortfolioCategoryNodeButtonAddImpl struct {
	// contains filtered or unexported fields
}

func NewDiagramButtonAddImpl

func NewDiagramButtonAddImpl(
	portfolioCategoryNode PortfolioCategoryNode,
	diagrammer *Diagrammer,
	treeNode *gongtree_models.Node,
	treeStage *gongtree_models.StageStruct,
) (portfolioCategoryNodeButtonAddImpl *PortfolioCategoryNodeButtonAddImpl)

func (*PortfolioCategoryNodeButtonAddImpl) ButtonUpdated

func (buttonImpl *PortfolioCategoryNodeButtonAddImpl) ButtonUpdated(
	gongtreeStage *gongtree_models.StageStruct,
	stageButton, front *gongtree_models.Button)

type PortfolioDiagramNode

type PortfolioDiagramNode interface {
	PortfolioNode

	// DisplayDiagram request the portfolio to display the diagram
	DisplayDiagram() map[ModelElementNode]Shape

	HasDrawButton() bool
	DrawDiagram() map[ModelElementNode]Shape
	CancelEdit() map[ModelElementNode]Shape
	SaveDiagram() map[ModelElementNode]Shape
	IsInDrawingMode() bool

	HasDiagramRenameButton() bool
	RenameDiagram(newName string) error
	IsInRenameMode() bool
	SetIsInRenameMode(isInRenameMode bool)

	HasDuplicateButton() bool
	DuplicateDiagram() PortfolioDiagramNode // returns the new diagram

	HasDeleteButton() bool
	DeleteDiagram()
}

type PortfolioDiagramNodeButtonImpl

type PortfolioDiagramNodeButtonImpl struct {
	ButtonType
	// contains filtered or unexported fields
}

func NewPortfolioDiagramNodeButtonImpl

func NewPortfolioDiagramNodeButtonImpl(
	portfolioDiagramNode PortfolioDiagramNode,
	diagrammer *Diagrammer,
	treeNode *gongtree_models.Node,
	treeStage *gongtree_models.StageStruct,
	buttonType ButtonType,
) (buttonImpl *PortfolioDiagramNodeButtonImpl)

func (*PortfolioDiagramNodeButtonImpl) ButtonUpdated

func (buttonImpl *PortfolioDiagramNodeButtonImpl) ButtonUpdated(
	gongtreeStage *gongtree_models.StageStruct,
	stageButton, front *gongtree_models.Button)

type PortfolioDiagramNodeImpl

type PortfolioDiagramNodeImpl struct {
	// contains filtered or unexported fields
}

func (*PortfolioDiagramNodeImpl) OnAfterUpdate

func (portfolioDiagramNodeImpl *PortfolioDiagramNodeImpl) OnAfterUpdate(stage *gongtree_models.StageStruct, stagedNode *gongtree_models.Node, frontNode *gongtree_models.Node)

OnAfterUpdate implements models.NodeImplInterface

type PortfolioNode

type PortfolioNode interface {

	// GetName() returns the Name that is displayed on the node
	GetName() string

	// GetParent returns the node above
	GetParent() PortfolioNode

	// GeneratesProgeny generates and returns the nodes below the node
	// it recursively
	GeneratesProgeny() []PortfolioNode
	GetChildren() []PortfolioNode

	// AppendChildren allows for dynmicaly adding a node below the node
	AppendChildren(PortfolioNode)

	// RemoveChildren allows for dynmicaly adding a node below the node
	RemoveChildren(PortfolioNode)

	// IsExpanded is true if the the node is visualy expanded
	IsExpanded() bool
}

PortfolioNode has to be implemented by the Adapter Nodes

func Remove

func Remove(slice []PortfolioNode, index int) []PortfolioNode

type Shape

type Shape interface {
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL