Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Error in generated code: package name used wrongly
Error in generated code: package name used wrongly [message #663838] Wed, 06 April 2011 15:32 Go to next message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 186
Registered: July 2009
Location: Torino
Senior Member

The code generated from GMF refers to classes from the metamodel in this way:
<EPackageName>.<EClassName>

i.e. Navigation.Page instead of Page

it try also to import the whole package:

import it.polito.softeng.momaapp.metamodels.Navigation;

while that package contains the actual classes generated for the metamodel (I set the "Base Package" option in the genmodel).

I don't know if the problem is related to the fact that the metamodel refer to another metamodel.

I report the gmfgen file:


<?xml version="1.0" encoding="UTF-8"?>
<gmfgen:GenEditorGenerator xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:gmfgen="http://www.eclipse.org/gmf/2009/GenModel" copyrightText="">
  <diagram
      visualID="1000"
      editPartClassName="ApplicationEditPart"
      itemSemanticEditPolicyClassName="ApplicationItemSemanticEditPolicy"
      canonicalEditPolicyClassName="ApplicationCanonicalEditPolicy"
      iconProviderPriority="Low"
      validationProviderPriority="Low">
    <diagramRunTimeClass
        href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Diagram"/>
    <elementType
        xsi:type="gmfgen:MetamodelType"
        editHelperClassName="ApplicationEditHelper"/>
    <viewmap
        xsi:type="gmfgen:FigureViewmap"
        figureQualifiedClassName="org.eclipse.draw2d.FreeformLayer"/>
    <domainDiagramElement
        href="../../it.polito.softeng.momaapp.metamodels/model/Navigation.genmodel#//Navigation/Application"/>
    <topLevelNodes
        visualID="2001"
        editPartClassName="PageEditPart"
        itemSemanticEditPolicyClassName="PageItemSemanticEditPolicy"
        canonicalEditPolicyClassName="PageCanonicalEditPolicy"
        graphicalNodeEditPolicyClassName="PageGraphicalNodeEditPolicy"
        createCommandClassName="PageCreateCommand">
      <diagramRunTimeClass
          href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
      <elementType
          xsi:type="gmfgen:MetamodelType"
          editHelperClassName="PageEditHelper"/>
      <viewmap
          xsi:type="gmfgen:InnerClassViewmap"
          className="PageFigure"
          classBody="&#xA;/**&#xA; * @generated&#xA; */&#xA;public class PageFigure extends org.eclipse.draw2d.RoundedRectangle {&#xA;&#xA;&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel fFigurePageLabelFigure; &#xA;&#xA;&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;public PageFigure() {&#xA;&#x9;&#x9;&#x9;&#x9;this.setCornerDimensions(new org.eclipse.draw2d.geometry.Dimension(getMapMode().DPtoLP(8)&#xA;, getMapMode().DPtoLP(8)&#xA;));&#xA;this.setBorder(new org.eclipse.draw2d.MarginBorder(getMapMode().DPtoLP(5)&#xA;, getMapMode().DPtoLP(5)&#xA;, getMapMode().DPtoLP(5)&#xA;, getMapMode().DPtoLP(5)&#xA;));&#xA;&#x9;&#x9;createContents();&#xA;&#x9;}&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;private void createContents(){&#xA;&#xA;&#xA;fFigurePageLabelFigure = new org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel();&#xA;fFigurePageLabelFigure.setText(&quot;Page&quot;);&#xA;&#xA;this.add(fFigurePageLabelFigure);&#xA;&#xA;&#xA;&#x9;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#x9;/**&#xA;&#x9; * @generated&#xA;&#x9; */&#xA;&#x9;public org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel getFigurePageLabelFigure() {&#xA;&#x9;&#x9;return fFigurePageLabelFigure;&#xA;&#x9;}&#xA;&#xA;&#xA;}&#xA;&#xA;"/>
      <modelFacet>
        <metaClass
            href="../../it.polito.softeng.momaapp.metamodels/model/Navigation.genmodel#//Navigation/Page"/>
        <containmentMetaFeature
            href="../../it.polito.softeng.momaapp.metamodels/model/Navigation.genmodel#//Navigation/Application/nodes"/>
        <childMetaFeature
            href="../../it.polito.softeng.momaapp.metamodels/model/Navigation.genmodel#//Navigation/Application/nodes"/>
      </modelFacet>
      <labels
          visualID="5001"
          editPartClassName="PageTitleEditPart"
          itemSemanticEditPolicyClassName="PageTitleItemSemanticEditPolicy"
          elementIcon="true">
        <diagramRunTimeClass
            href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/>
        <viewmap
            xsi:type="gmfgen:ParentAssignedViewmap"
            getterName="getFigurePageLabelFigure"
            figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"/>
        <modelFacet
            xsi:type="gmfgen:FeatureLabelModelFacet"
            parser="//@labelParsers/@implementations.0">
          <metaFeatures
              href="../../it.polito.softeng.momaapp.metamodels/model/Navigation.genmodel#//Navigation/Page/title"/>
        </modelFacet>
      </labels>
    </topLevelNodes>
    <palette>
      <groups
          title="Objects"
          collapse="true">
        <entries
            xsi:type="gmfgen:ToolEntry"
            title="Page"
            description="Create new Page"
            genNodes="//@diagram/@topLevelNodes.0"/>
      </groups>
    </palette>
    <preferencePages
        xsi:type="gmfgen:GenStandardPreferencePage"
        iD="it.polito.softeng.momaapp.metamodels.diagram.general"
        name="Navigation Diagram">
      <children
          xsi:type="gmfgen:GenStandardPreferencePage"
          iD="it.polito.softeng.momaapp.metamodels.diagram.appearance"
          name="Appearance"
          kind="Appearance"/>
      <children
          xsi:type="gmfgen:GenStandardPreferencePage"
          iD="it.polito.softeng.momaapp.metamodels.diagram.connections"
          name="Connections"
          kind="Connections"/>
      <children
          xsi:type="gmfgen:GenStandardPreferencePage"
          iD="it.polito.softeng.momaapp.metamodels.diagram.printing"
          name="Printing"
          kind="Printing"/>
      <children
          xsi:type="gmfgen:GenStandardPreferencePage"
          iD="it.polito.softeng.momaapp.metamodels.diagram.rulersAndGrid"
          name="Rulers And Grid"
          kind="RulersAndGrid"/>
    </preferencePages>
  </diagram>
  <plugin>
    <requiredPlugins>org.eclipse.draw2d</requiredPlugins>
  </plugin>
  <editor/>
  <navigator>
    <childReferences
        child="//@diagram"/>
    <childReferences
        parent="//@diagram"
        child="//@diagram/@topLevelNodes.0"/>
  </navigator>
  <diagramUpdater/>
  <propertySheet>
    <tabs
        xsi:type="gmfgen:GenStandardPropertyTab"
        iD="appearance"/>
    <tabs
        xsi:type="gmfgen:GenStandardPropertyTab"
        iD="diagram"/>
    <tabs
        xsi:type="gmfgen:GenCustomPropertyTab"
        iD="domain"
        label="Core">
      <filter
          xsi:type="gmfgen:TypeTabFilter">
        <types>org.eclipse.gmf.runtime.notation.View</types>
        <types>org.eclipse.gef.EditPart</types>
        <generatedTypes>abstractNavigatorItem</generatedTypes>
      </filter>
    </tabs>
  </propertySheet>
  <domainGenModel
      href="../../it.polito.softeng.momaapp.metamodels/model/Navigation.genmodel#/"/>
  <labelParsers
      extensibleViaService="true">
    <implementations
        xsi:type="gmfgen:PredefinedParser"
        uses="//@diagram/@topLevelNodes.0/@labels.0/@modelFacet"/>
  </labelParsers>
  <contextMenus
      context="//@diagram">
    <items
        xsi:type="gmfgen:LoadResourceAction"/>
  </contextMenus>
</gmfgen:GenEditorGenerator>


Re: Error in generated code: package name used wrongly [message #663872 is a reply to message #663838] Wed, 06 April 2011 16:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
Federico,

Package names shouldn't be upper case. I'm not sure if that causes a
problem, but I'd try changing it to navigation and see if that helps.



Federico Tomassetti wrote:
> The code generated from GMF refers to classes from the metamodel in
> this way:
> <EPackageName>.<EClassName>
>
> i.e. Navigation.Page instead of Page
>
> it try also to import the whole package:
>
> import it.polito.softeng.momaapp.metamodels.Navigation;
>
> while that package contains the actual classes generated for the
> metamodel (I set the "Base Package" option in the genmodel).
>
> I don't know if the problem is related to the fact that the metamodel
> refer to another metamodel.
>
> I report the gmfgen file:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <gmfgen:GenEditorGenerator xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:gmfgen="http://www.eclipse.org/gmf/2009/GenModel"
> copyrightText="">
> <diagram
> visualID="1000"
> editPartClassName="ApplicationEditPart"
> itemSemanticEditPolicyClassName="ApplicationItemSemanticEditPolicy "
> canonicalEditPolicyClassName="ApplicationCanonicalEditPolicy "
> iconProviderPriority="Low"
> validationProviderPriority="Low">
> <diagramRunTimeClass
>
> href=" ../../../plugin/org.eclipse.gmf.runtime.notation/model/notat ion.genmodel#//notation/Diagram "/>
>
> <elementType
> xsi:type="gmfgen:MetamodelType"
> editHelperClassName="ApplicationEditHelper"/>
> <viewmap
> xsi:type="gmfgen:FigureViewmap"
> figureQualifiedClassName="org.eclipse.draw2d.FreeformLayer"/ >
> <domainDiagramElement
>
> href=" ../../it.polito.softeng.momaapp.metamodels/model/Navigation. genmodel#//Navigation/Application "/>
>
> <topLevelNodes
> visualID="2001"
> editPartClassName="PageEditPart"
> itemSemanticEditPolicyClassName="PageItemSemanticEditPolicy "
> canonicalEditPolicyClassName="PageCanonicalEditPolicy"
> graphicalNodeEditPolicyClassName="PageGraphicalNodeEditPolicy "
> createCommandClassName="PageCreateCommand">
> <diagramRunTimeClass
>
> href=" ../../../plugin/org.eclipse.gmf.runtime.notation/model/notat ion.genmodel#//notation/Node "/>
>
> <elementType
> xsi:type="gmfgen:MetamodelType"
> editHelperClassName="PageEditHelper"/>
> <viewmap
> xsi:type="gmfgen:InnerClassViewmap"
> className="PageFigure"
> classBody="
> /**
> * @generated
> */
> public class PageFigure extends org.eclipse.draw2d.RoundedRectangle {
>
>
> /**
> * @generated
> */
> private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel
> fFigurePageLabelFigure;
>
> /**
> * @generated
> */
> public PageFigure() {
> this.setCornerDimensions(new
> org.eclipse.draw2d.geometry.Dimension(getMapMode().DPtoLP(8)
> , getMapMode().DPtoLP(8)
> ));
> this.setBorder(new org.eclipse.draw2d.MarginBorder(getMapMode().DPtoLP(5)
> , getMapMode().DPtoLP(5)
> , getMapMode().DPtoLP(5)
> , getMapMode().DPtoLP(5)
> ));
> createContents();
> }
> /**
> * @generated
> */
> private void createContents(){
>
>
> fFigurePageLabelFigure = new
> org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel();
> fFigurePageLabelFigure.setText("Page");
>
> this.add(fFigurePageLabelFigure);
>
>
> }
>
>
>
>
>
> /**
> * @generated
> */
> public org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel
> getFigurePageLabelFigure() {
> return fFigurePageLabelFigure;
> }
>
>
> }
>
> "/>
> <modelFacet>
> <metaClass
>
> href=" ../../it.polito.softeng.momaapp.metamodels/model/Navigation. genmodel#//Navigation/Page "/>
>
> <containmentMetaFeature
>
> href=" ../../it.polito.softeng.momaapp.metamodels/model/Navigation. genmodel#//Navigation/Application/nodes "/>
>
> <childMetaFeature
>
> href=" ../../it.polito.softeng.momaapp.metamodels/model/Navigation. genmodel#//Navigation/Application/nodes "/>
>
> </modelFacet>
> <labels
> visualID="5001"
> editPartClassName="PageTitleEditPart"
>
> itemSemanticEditPolicyClassName="PageTitleItemSemanticEditPolicy "
> elementIcon="true">
> <diagramRunTimeClass
>
> href=" ../../../plugin/org.eclipse.gmf.runtime.notation/model/notat ion.genmodel#//notation/Node "/>
>
> <viewmap
> xsi:type="gmfgen:ParentAssignedViewmap"
> getterName="getFigurePageLabelFigure"
>
> figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel "/>
>
> <modelFacet
> xsi:type="gmfgen:FeatureLabelModelFacet"
> parser="//@labelParsers/@implementations.0">
> <metaFeatures
>
> href=" ../../it.polito.softeng.momaapp.metamodels/model/Navigation. genmodel#//Navigation/Page/title "/>
>
> </modelFacet>
> </labels>
> </topLevelNodes>
> <palette>
> <groups
> title="Objects"
> collapse="true">
> <entries
> xsi:type="gmfgen:ToolEntry"
> title="Page"
> description="Create new Page"
> genNodes="//@diagram/@topLevelNodes.0"/>
> </groups>
> </palette>
> <preferencePages
> xsi:type="gmfgen:GenStandardPreferencePage"
> iD="it.polito.softeng.momaapp.metamodels.diagram.general"
> name="Navigation Diagram">
> <children
> xsi:type="gmfgen:GenStandardPreferencePage"
> iD="it.polito.softeng.momaapp.metamodels.diagram.appearance "
> name="Appearance"
> kind="Appearance"/>
> <children
> xsi:type="gmfgen:GenStandardPreferencePage"
> iD="it.polito.softeng.momaapp.metamodels.diagram.connections "
> name="Connections"
> kind="Connections"/>
> <children
> xsi:type="gmfgen:GenStandardPreferencePage"
> iD="it.polito.softeng.momaapp.metamodels.diagram.printing"
> name="Printing"
> kind="Printing"/>
> <children
> xsi:type="gmfgen:GenStandardPreferencePage"
> iD="it.polito.softeng.momaapp.metamodels.diagram.rulersAndGrid "
> name="Rulers And Grid"
> kind="RulersAndGrid"/>
> </preferencePages>
> </diagram>
> <plugin>
> <requiredPlugins>org.eclipse.draw2d</requiredPlugins>
> </plugin>
> <editor/>
> <navigator>
> <childReferences
> child="//@diagram"/>
> <childReferences
> parent="//@diagram"
> child="//@diagram/@topLevelNodes.0"/>
> </navigator>
> <diagramUpdater/>
> <propertySheet>
> <tabs
> xsi:type="gmfgen:GenStandardPropertyTab"
> iD="appearance"/>
> <tabs
> xsi:type="gmfgen:GenStandardPropertyTab"
> iD="diagram"/>
> <tabs
> xsi:type="gmfgen:GenCustomPropertyTab"
> iD="domain"
> label="Core">
> <filter
> xsi:type="gmfgen:TypeTabFilter">
> <types>org.eclipse.gmf.runtime.notation.View</types>
> <types>org.eclipse.gef.EditPart</types>
> <generatedTypes>abstractNavigatorItem</generatedTypes>
> </filter>
> </tabs>
> </propertySheet>
> <domainGenModel
>
> href=" ../../it.polito.softeng.momaapp.metamodels/model/Navigation. genmodel#/ "/>
>
> <labelParsers
> extensibleViaService="true">
> <implementations
> xsi:type="gmfgen:PredefinedParser"
> uses="//@diagram/@topLevelNodes.0/@labels.0/@modelFacet"/>
> </labelParsers>
> <contextMenus
> context="//@diagram">
> <items
> xsi:type="gmfgen:LoadResourceAction"/>
> </contextMenus>
> </gmfgen:GenEditorGenerator>
>
Re: Error in generated code: package name used wrongly [message #663880 is a reply to message #663838] Wed, 06 April 2011 17:10 Go to previous message
Federico Tomassetti is currently offline Federico TomassettiFriend
Messages: 186
Registered: July 2009
Location: Torino
Senior Member

I am out of the office now but that could work. If played a little bit with the GMF Templates: it seems that it calculates correctly the full name and later something trying to produce the import and replace the fully qualified name with the simple name. Maybe it assumes that the class name starts with the first capital letter...

Previous Topic:[ERROR] Cannot modify resource set without a write transaction
Next Topic:Losing relations arcs
Goto Forum:
  


Current Time: Thu Nov 27 03:21:25 GMT 2014

Powered by FUDForum. Page generated in 0.06381 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software