Development with Code Generation: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
m (1 revision)
 
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Tools ==
= Tools =
* In csharp/ICT/PetraTools
* In csharp/ICT/PetraTools
* uses CSParser to parse existing C# files
* uses NRefactory to parse existing C# files (used to be done with CSParser)
* write code:
* write code:
** can comment generated code
** can comment generated code
Line 8: Line 8:
* TODO: write into Templates
* TODO: write into Templates
* Plugin writers for different output (Winforms, GTK, ASP.net)
* Plugin writers for different output (Winforms, GTK, ASP.net)
=== YML ===
* See detailed documentation for developers: [[Developing the Forms generator]]
* general definition: YML is shorter and easier to write and read than XML, but you can get the same structure than XML. This is achieved for example by not having opening and closing tags, but by using identation to define the hierarchy of elements.
* specification: http://yaml.org/spec/1.2/
* see a parser for YAML: http://yaml-net-parser.sourceforge.net/default.html
* we have our own converter from yaml to xml: project Ict.Tools.CodeGeneration, Yml2Xml.cs, Ict.Tools.CodeGeneration.Yml2Xml
** advantage: we can write short yaml code, but can use the comfort of the XML parser in .net to walk through the hierarchy
** yml2xml maps the YAML into XML


=== XAML ===
== YAML ==
* TODO: XAML idea
YAML is a text file format that is shorter and easier to write and read than XML, but you can get the same structure than XML. This is achieved by not having opening and closing tags, but by using identation to define the hierarchy of elements. It is more friedly to read than XML, since it is less technical (no markup!).


== Documentation YML for OpenPetra Forms ==
* [http://en.wikipedia.org/wiki/YAML Overview]
* generally the yml files inherit from each other ('''BaseYaml''')
* [http://yaml.org/spec/1.2/ Official specification]
** this allows us to only define the default menu items once, in PetraForm.yaml, and they will be included in all derived forms
* Parsers
* '''FormType''':
** see a parser for YAML: http://yaml-net-parser.sourceforge.net/default.html
** ''abstract'': if this is just used as a base form for other real forms
** For openPETRA we have developed our own converter from yaml to xml: project Ict.Tools.CodeGeneration, Yml2Xml.cs, Ict.Tools.CodeGeneration.Yml2Xml
** ''navigation'': the main window, the module windows
*** Advantage: we can write short yaml code, but can use the comfort of the XML parser in .Net to walk through the hierarchy
** ''edit'': edit screens
*** yml2xml maps the YAML into XML
** ''crud'': CRUD screens (Create, Read, Update, Delete)
 
** ''find'': find screens
The idea for generating forms from yaml files has been taken eg. from this page: http://www.symfony-project.org/book/1_0/14-Generators
* '''Events''': here you can link form events to methods in your code
 
** eg. <code>Activated: {class=System.EventHandler,method=FTheObject.TFrmPetra_Activated}</code>
===YAML Syntax Highlighting in Notepad++ Editor===
* '''Actions''': actions can be used by menuitems, toolbarbuttons, and other controls; this is useful to be able to enable/disable an action on the whole screen, and to only define a certain action once, and refer to it from all controls that trigger the same action
The Notepad++ Editor has built-in support for syntax highlighting of YAML files. However, it switches this feature on only if a YAML file has the file extension '.yml', but in openPETRA we use the file extension '.yaml' and so the syntax highlighting is not on by default for openPETRA YAML files.
** eg. <code>actClose: {Label=&Close, ActionId=eClose, Tooltip=Closes this window, Image=Close.ico}</code>
 
** eg. <code>actMainMenu: {Label=Petra &Main Menu, ActionClick=FTheObject.OpenMainScreen}</code>
See [[Setup of Development Environment for Windows#Optional_Software|this wiki page section]] for instructions to turn syntax highlighting for openPETRA YAML files on.
* '''Controls''': TODO
 
* '''Menu''': TODO
 
* '''Toolbar''': TODO
==openPETRA YAML syntax==
* '''Layout''': TODO
Specific syntax is used in openPETRA for
* defining the navigation menu hierarchy
(csharp\ICT\Petra\Definitions\UINavigation.yml)
* defining the cached datatables
** csharp\ICT\Petra\Definitions\CacheableTablesAndLists.yaml
** see also [[Documentation Cacheable Tables]]
* screen definition files (see [[Documentation_YAML_for_OpenPetra_Forms]])
nant generateORMCachedTables

Latest revision as of 20:45, 11 Mayıs 2022

Tools

  • In csharp/ICT/PetraTools
  • uses NRefactory to parse existing C# files (used to be done with CSParser)
  • write code:
    • can comment generated code
    • can insert regions with name ManualCode (need endregion ManualCode as well)
  • TODO: write into Templates
  • Plugin writers for different output (Winforms, GTK, ASP.net)
  • See detailed documentation for developers: Developing the Forms generator

YAML

YAML is a text file format that is shorter and easier to write and read than XML, but you can get the same structure than XML. This is achieved by not having opening and closing tags, but by using identation to define the hierarchy of elements. It is more friedly to read than XML, since it is less technical (no markup!).

  • Overview
  • Official specification
  • Parsers
    • see a parser for YAML: http://yaml-net-parser.sourceforge.net/default.html
    • For openPETRA we have developed our own converter from yaml to xml: project Ict.Tools.CodeGeneration, Yml2Xml.cs, Ict.Tools.CodeGeneration.Yml2Xml
      • Advantage: we can write short yaml code, but can use the comfort of the XML parser in .Net to walk through the hierarchy
      • yml2xml maps the YAML into XML

The idea for generating forms from yaml files has been taken eg. from this page: http://www.symfony-project.org/book/1_0/14-Generators

YAML Syntax Highlighting in Notepad++ Editor

The Notepad++ Editor has built-in support for syntax highlighting of YAML files. However, it switches this feature on only if a YAML file has the file extension '.yml', but in openPETRA we use the file extension '.yaml' and so the syntax highlighting is not on by default for openPETRA YAML files.

See this wiki page section for instructions to turn syntax highlighting for openPETRA YAML files on.


openPETRA YAML syntax

Specific syntax is used in openPETRA for

  • defining the navigation menu hierarchy
(csharp\ICT\Petra\Definitions\UINavigation.yml)
nant generateORMCachedTables