@startuml sd_function_wizard.png
skinparam handwritten false
skinparam monochrome true
skinparam packageStyle rect
skinparam defaultFontName FG Virgil
skinparam shadowing false

actor User 
participant "<<presentation>>\nFunctionWizardAction" as Action
participant "<<presentation>>\nFunctionWizardUI" as UI
participant "<<application>>\nFunctionWizardController" as CRTL
participant "<<domain>>\nFunctionUtils" as func

User -> Action : selects the "Function Wizard" option
activate Action
create UI

Action -> UI : create
deactivate Action
activate UI
create CRTL
UI --> CRTL : create
UI -> CRTL : getFunctions()
activate CRTL
CRTL -> func : getFunctions()
activate func
func -> Language : getFunctions()
func -> Language : getOperators()
CRTL --> UI : 
deactivate func
deactivate CRTL
UI --> User : displays a new window that contains a list of functions/operators 
deactivate UI

User -> UI : select a function/operator
activate UI
UI -> CRTL : getDescription(String identifier)
activate CRTL
participant "<<Interface>>\nFunction" as Function
CRTL -> Language : getFunction(String identifier)
activate Language
Language -> Function : getParameters()
deactivate Language
activate Function
Function -> FunctionParameter : getParameters()
deactivate Function
CRTL --> UI :
deactivate CRTL
UI -> CRTL : getSyntax(String identifier)
activate CRTL
CRTL -> func : getSyntax()
activate func
func -> Language : getFunction(String identifier)
deactivate func
activate Language
Language -> Function : getParameters()
deactivate Language
activate Function
Function -> FunctionParameter : getName()
deactivate Function
CRTL --> UI :
deactivate CRTL
UI --> User : display the syntax and description of selected function/operator \n & asks for parameters
deactivate UI

note right of User
    Up to here, the design is the same as / similar to the previous iteration.
    The new steps will be detailed in the next diagram.
end note

User -> UI : chooses the "Apply" option
activate UI
UI -> CRTL : insertSyntaxFormulaBar(String syntax)

activate CRTL
deactivate CRTL

UI --> User : closes the window
deactivate UI


@enduml