[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: add .xpt template

Alex Shatalin a Ãcrit :
Hello Aurelien,

Where do I start the path? (my??)
In .gmfgen model there are two properties:
- GenEditorGenerator.Dynamic Templates (boolean)
- GenEditorGenerator.Template Directory (string) - see http://wiki.eclipse.org/GMF_GenModel_Hints#GenEditorGenerator


So, you can:
- create new template in a file: /project1/customTemplates/folder1/TemplateFile.xpt

I create here : \org.ow2.jasmine.design.gmf.codegen\templates\xpt\propsheet\PropertySourceExtended.xpt


- set Template Directory to "/project1/customTemplates"
set to : /org.ow2.jasmine.design.gmf.codegen/templates

- use ÂEXPAND folder1::TemplateFile::definitionName FOR myModelElementÂ
to execute definition "definitionName" from this file.

in \org.ow2.jasmine.design.gmf.codegen\templates\xpt\propsheet\PropertySourceExtended.xpt :


ÂIMPORT "http://www.eclipse.org/gmf/2008/GenModel"Â;
ÂIMPORT "http://www.eclipse.org/emf/2002/Ecore"Â;

ÂDEFINE Class FOR gmfgen::GenCustomPropertyTabÂ
    ÂEXPAND xpt::Common::copyright FOR sheet.editorGen-Â
    package Âsheet.packageNameÂ;

ÂEXPAND xpt::Common::generatedClassCommentÂ
public class PropertySourceExtended extends org.eclipse.emf.edit.ui.provider.PropertySource implements org.eclipse.ui.views.properties.IPropertySource{

}
ÂENDDEFINEÂ


and in org.ow2.jasmine.design.gmf.codegen\templates\xpt\propsheet\PropertySection.xpt
(which already exists) :
ÂIMPORT "http://www.eclipse.org/gmf/2008/GenModel"Â;
ÂIMPORT "http://www.eclipse.org/emf/2002/Ecore"Â;



ÂDEFINE Class FOR gmfgen::GenCustomPropertyTabÂ


ÂEXPAND xpt::propsheet::PropertySourceExtended::Class FOR self.customPropertyTab [1]




	ÂEXPAND xpt::Common::copyright FOR sheet.editorGen-Â
package Âsheet.packageNameÂ;

ÂEXPAND xpt::Common::generatedClassCommentÂ
public class ÂclassName extends ÂEXPAND extendsList ÂEXPAND implementsClauseÂ{


ÂEXPAND getPropertySourceMethodÂ
ÂIF sheet.readOnlyÂ
ÂEXPAND createReadonlyControlsMethodÂ
ÂENDIFÂ
ÂEXPAND getPropertySourceProviderMethodÂ
ÂEXPAND transfromSelectionMethodÂ
ÂEXPAND setInputMethodÂ
ÂEXPAND getAdapterFactoryMethodÂ

ÂEXPAND additionsÂ


} ÂENDDEFINEÂ

[...]the definition of EXPANDs





What is the myModelElement? (gmfgen::GenCustomPropertyTab??)
myModelElement is a name of variable or reference/attribute. It's type can be gmfgen::GenCustomPropertyTab. Here is an example from GMF templates:

ÂDEFINE Class FOR gmfgen::GenCustomPropertyTabÂ
............
public class ÂclassName extends ÂEXPAND extendsList ÂEXPAND implementsClauseÂ{
............
ÂENDDEFINEÂ


ÂEXPAND extendsList is a way to call another definition with name "extendsList" (defined in this file). This call is equivalent to: ÂEXPAND extendsList FOR self where "self" is a contextual parameter name (instanceof gmfgen::GenCustomPropertyTab). If you need to call a definition using any feature of contextual parameter you can use constructions like:

ÂEXPAND myDefinition FOR self.classNameÂ

the the following definition will be called:
ÂDEFINE myDefinition FOR StringÂ
............
ÂENDDEFINEÂ

where "String" is a type of gmfgen::GenCustomPropertyTab::className attribute in the model. Instead of shortname of a definition located in same file you can use full name like: myFolder::MyTemplate::myDefinition

[1]
[...]
ÂEXPAND xpt::propsheet::newTemplate::Class
FOR gmfgen::GenCustomPropertyTabÂ
It should be something like:
ÂEXPAND xpt::propsheet::newTemplate::Class FOR self.customPropertyTabÂ


I've got this error : Unknown GenCustomPropertyTab property, variable, type or enumeration literal 'self' on line [1]


-----------------
Alex Shatalin