add .xpt template [message #233305] |
Wed, 10 June 2009 10:37  |
Eclipse User |
|
|
|
Originally posted by: aurelien.pupier.esial.net
Hi,
I want to add some template to generate custom files.
I can modify existing, I mean : I modify an existing .xpt, so the
generated class is correctly modified
But when I create a new .xpt file in order to generate a class... it
seems that the .xpt is not used...
The new .xpt files are in the same folder of existing templates.
The most strange is that at the first "generate diagram code", there was
a trace in the log which indicates errors but now there is no more trace
in the log at the "generate diagram code" invocation.
Is there something to do to consider the new .xpt files?
Thanks for any help
One of my new .xpt file(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{
«EXPAND createPropertyDescriptorMethod»
}
«ENDDEFINE»
«DEFINE createPropertyDescriptorMethod FOR gmfgen::GenCustomPropertyTab-»
«EXPAND xpt::Common::generatedMemberComment»
protected IPropertyDescriptor
createPropertyDescriptor(org.eclipse.emf.edit.provider.IItem PropertyDescriptor
itemPropertyDescriptor) {
return new PropertyDescriptorExtended(object,
itemPropertyDescriptor);
}
«ENDDEFINE»
|
|
|
|
|
|
|
|
|
|
|
|
Re: add .xpt template [message #233619 is a reply to message #233525] |
Mon, 15 June 2009 04:08   |
Eclipse User |
|
|
|
Originally posted by: aurelien.pupier.esial.net
Alex Shatalin a écrit :
> Hello Aurelien,
>
>> Will it be supported with the new version of GMF which use QvTo?
> No, it's not planned.
>
>> if you have an example ant task to generate it...
> Here it is (build.xml from org.eclipse.gmf.graphdef.editor plugin):
>
> <project name="graphdef.editor" default="main"
> xmlns:xpt="eclipse.org/gmf/2008/xpand">
>
> <property name="graphdef.plugin"
> value="platform:/resource/org.eclipse.gmf.graphdef.editor"/ >
> <property name="formtk.plugin"
> value="platform:/resource/org.eclipse.gmf.formtk"/>
>
> <target name="main">
> <antcall target="generateSection">
> <param name="section" value="Size"/>
> </antcall>
> <antcall target="generateSection">
> <param name="section" value="Layout"/>
> </antcall>
> <antcall target="generateSection">
> <param name="section" value="LayoutData"/>
> </antcall>
> <antcall target="generateSection">
> <param name="section" value="Figure"/>
> </antcall>
> </target>
>
> <target name="generateSection">
> <xpt:template name="PropSheet::Main"
> inputURI="${graphdef.plugin}/models/${section}Section.xmi#/ "
>
> templateroot=" ${graphdef.plugin}/templates-context,${graphdef.plugin}/temp lates-propsheet,${formtk.plugin}/templates-propsheet,${formt k.plugin}/templates-formpage,${formtk.plugin}/templates-cont ext,${formtk.plugin}/templates-widget "
>
>
> outfile=" ${basedir}/src-extra/org/eclipse/gmf/graphdef/editor/sheet/$ {section}Section.java "/>
>
> </target>
>
> </project>
>
>> I can generate all diagram code using an ant task? or is there
>> limitations? which?
> No, it's not supported now. You can generate diagram code using UI
> action only and you can generate additional classes using modified UI
> action or using ant file.
>
>> calling a doGenerateJavaClass I suppose at first sight?
> Right you can call doGenerateJavaClass() from GeNeratorExt class.
>
I tried this.
I created a custom popup menu which launch :
a CustomExecuteTemplatesAction extends ExecuteTemplatesAction, overriden
the createOperation Method by return CustomExecuteTemplatesOperation
CustomExecuteTemplatesOperation extends ExecuteTemplatesOperation,
overriden the createGenerator which return a CustomGenerator
CustomGenerator extends Generator, here I'm calling the dogenerateClass
I tried with argument :
doGenerateJavaClass(
myEmittersCustom.getPropertySourceEmitter()/*newXpandEmitter ( "xpt::propsheet::PropertySource::Class")*/,
"org.ow2.jasmine.design.model.jonas.diagram.sheet",
"PropertySourceExtended",
myDiagram);
}
This exception is thrown by Eclipse while generating :
Problems while generating code
Exception (No Definition xpt::propsheet::PropertySource::Class for
GenDiagram could be found!) while generating code
No Definition xpt::propsheet::PropertySource::Class for GenDiagram
could be found!
The stack trace in the log is:
!SUBENTRY 1 org.eclipse.gmf.common 4 0 2009-06-15 09:59:40.503
!MESSAGE Exception (No Definition xpt::propsheet::PropertySource::Class
for GenDiagram could be found!) while generating code
!STACK 0
org.eclipse.gmf.internal.xpand.expression.EvaluationExceptio n: No
Definition xpt::propsheet::PropertySource::Class for GenDiagram could be
found!
at org.eclipse.gmf.internal.xpand.XpandFacade.evaluate(XpandFac ade.java:50)
at
org.eclipse.gmf.internal.common.codegen.XpandTextEmitter.gen erate(XpandTextEmitter.java:64)
at
org.eclipse.gmf.internal.common.codegen.GeneratorBase.doGene rateJavaClass(GeneratorBase.java:335)
at
org.ow2.jasmine.design.gmf.codegen.generator.popup.actions.C ustomGenerator.generateCustomDialogCellEditorPropertySheet(C ustomGenerator.java:83)
at
org.ow2.jasmine.design.gmf.codegen.generator.popup.actions.C ustomGenerator.generatePropertySheetSections(CustomGenerator .java:57)
at org.eclipse.gmf.codegen.util.Generator.customRun(Generator.j ava:259)
at
org.eclipse.gmf.internal.common.codegen.GeneratorBase$1.run( GeneratorBase.java:474)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1800)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1782)
at
org.eclipse.gmf.internal.common.codegen.GeneratorBase.doRun( GeneratorBase.java:471)
at
org.eclipse.gmf.internal.common.codegen.GeneratorBase.run(Ge neratorBase.java:90)
at
org.eclipse.gmf.internal.codegen.popup.actions.ExecuteTempla tesOperation.run(ExecuteTemplatesOperation.java:182)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:121)
It may be other thing to do but what? Do I declare the path to the
template? isn't already declare in the XPandEmitter constructor?
> -----------------
> Alex Shatalin
>
>
|
|
|
|
|
|
|
|
|
Re: [SOLVED]Re: add .xpt template [message #233728 is a reply to message #233707] |
Mon, 15 June 2009 10:41  |
Eclipse User |
|
|
|
Hello Aurelien,
> Ok It was that.
>
> Alex, Thanks a LOT for all your help!!!
:-) Nice to see it's solved.
Few words about this problem - it's rather frequent with current state of
EMF meta-model handling. We are trying to load EMF meta-model (gmfgen.emf)
from the workspace-located file to get latest state from there and use it
in xpand, but sometimes same meta-model can be loaded from the platform and
used by EMF then you load model file (yourmodel.gmfgen) in this case same
meta-classes (gmfgen::Diagram) will be loaded twice and will not be properly
matched in an engine.
As I said, this is not so frequent problem and you usually suffer from it
then you are doing some “advanced” GMF development… So, for now the workaround
is to deploy meta-model to the platform, remove it from the workspace and
let it work as you did.
-----------------
Alex Shatalin
|
|
|
Powered by
FUDForum. Page generated in 0.72409 seconds