The Template Tree Window
s
Templates
The function templates define the
structure of the functions and are used to build functions. Function templates don't belong to
projects, but to the machine: every machine, local in the Matrex desktop
or remote in a Matrex server, has a set of templates.
You can add or change function templates
(also remove them). You can build your own library of templates and, if you
like, share it with others.
Templates are composed by:
- The template definition, a structure defining which
input matrices, output matrices and parameters the function needs to
work. We say that a template contains the input matrices, the output
matrices and the parameter
definitions: how they are called
in the template, the types of them and if they are mandatory or optional.
In other words definitions are used to show which matrices or parameters
are expected when a function is built from a template and to verify that
matrices and parameters are correct.
- The code that has to be executed to produce the output matrices
when the function is recalculated. This can either be written:
- in Java and compiled as a class. In this case, the class or
the jar library that contains the code need to be added to the
plugins class path of s Matrex.
- using a script language.
Matrex already allows to write template code using Jython. In
this case you can load the script file in the application and
associate it directly with the template.
It is only possible to add, update or delete templates on the local machine
(in the Matrex desktop). The template tree window on remote machines is
read-only and does not have a context menu. The reasons for this are:
- It is easier to test and fix templates and the underlying code on the local machine.
- There is a certain period of time from the time the template is
created and the time it is ready to be used. During this period is
better that the template is not visible to anyone else than its creator.
- Templates can depend by jar libraries. There is not a good and safe way to move libraries among Matrex clients and servers.
When a template is complete and tested it can be copied to a server, together with the underlying code. If the code consists of a jar file, it has to be copied manually.
The locations (directories and jar files) for templates definitions, code
and script languages can be defined using the files locations dialog.
The template tree window contains:
- on the left side, a tree
showing all the available templates.
- on the right side, the complete description of the currently selected
template.
As with the other trees, if you know at least a part of the name-package of
the template, just write it on the search
bar on the top of the templates tree and either press�enter or click
on the green arrow button. The first template matching the text in the search
bar gets visualized and selected. Pressing again enter or clicking on the
green arrow button selects the next matching template, and so on.
The tree's popup menu
Clicking with the right mouse button on an item in the Function
templates tree, the popup menu to add, edit or delete templates appears.
In general the templates that are located under the sys root package are considered system template and cannot be edited or deleted, so for these templates some of the menu entries are disabled.
From this menu you can:
Add a template
The menu item New template opens the template editor, used to add templates.
Edit a template
Edit the selected item with the Edit Template menu. The template editor opens, with the entered input
and output matrices definitions and parameter definitions in place. You can
change them and save the template again. Disabled for system templates.
Remove a template
Remove the selected item with the Remove Template menu.
This is a very risky operation, because there can be functions in some
projects that are built on that template and will not work again when the
template is removed. Therefore it is requested to confirm.
Disabled for system templates.
Rename a template
Rename the selected item with the Rename Template menu. This is a very
risky operation, because there can be functions in some projects that are
built on that template and will not work again when the template changes its
name. Therefore a confirmation is requested.
After you confirmed the choice, you can rename the template using the name-package dialog. The template is
renamed, both in the template tree view and as file.
There is no view menu, because it does not make sense to view a template.
Disabled for system templates.
Add a template with the content of the selected template
Add a template that has initially the content of the selected template with the New Template From menu. This is useful if the template you want to create is very similar to an existing template. It opens the template editor , populating its fields with the content of the selected template.
The template tree top menu
The menu on the top of the template tree has the expand and collapse choices like the other trees, but
it has two more choices:
Search a template
You can do a full text search on the
templates descriptions. In the top
menu select the Search menu and search the template with the template search dialog that appears.
Build an HTML page listing all templates
In the top menu select the Build HTML Page menu.
This will save an HTML page with all the templates, their description,
matrices and parameter definitions in the file that you choose.