Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » diagram code generation problem
diagram code generation problem [message #190166] Thu, 29 May 2008 17:45 Go to next message
Ken Geis is currently offline Ken GeisFriend
Messages: 1
Registered: July 2009
Junior Member
I created the start of a CWM metamodel in EMF. I ran through the whole
GMF dashboard, but the generated diagram editor has errors in it.
Here's the first one.

I have an EPackage CWM.ObjectModel. When I generate the Java model, it
creates a Java package called CWM.ObjectModel with a bunch of classes in
it (like ObjectModelPackage.) So the generated diagram code below fails
because it is trying to import a package ("import CWM.ObjectModel;".)
So there are two places in the code below where ObjectModel is being
used as if it were a class, but it is a package.

Any help?


Ken Geis

------------------------------------------------------------ --

package CWM.diagram.edit.commands;

....
import CWM.ObjectModel;
....

public class CubeDimensionAssociationCreateCommand extends
CreateElementCommand
{
....
/**
* @generated
*/
public
CubeDimensionAssociationCreateCommand(CreateRelationshipRequ est request,
EObject source,
EObject target)
{
super(request);
this.source = source;
this.target = target;
if (request.getContainmentFeature() == null)
{
setContainmentFeature(ObjectModel.ObjectModelPackage.eINSTAN CE

.getNamespace_OwnedElement());
}

super.setElementToEdit(source);
}
....
}
Re: diagram code generation problem [message #190196 is a reply to message #190166] Fri, 30 May 2008 08:19 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Ken,

The import organizer in GMF cannot always correctly know what is a
package, a class or a class member (because it is impossible to actually
find the elements which may not have been generated YET). Thus we have
to use some sort of heuristics in the import organizer.

The current rules are more or less the following:
1. the first segments that do not have any uppercase letters are
considered packages;
2. all-uppercase identifiers are considered class members (assumed to be
static final constants);
3. Whatever starts with an uppercase letter, but is not
all-in-uppercase, is considered a class;
4. everything else is considered a class member.
5. There are exactly 3 hardcoded exceptions to the rule 2: SWT, URI and
NLS are considered class names, not attributes.

Thus, the CWM in your example is not recognized as a package (though I'm
not sure what it is recognized as). The immediate workaround would be to
make the package name all-lowercase. But you may also want to submit an
enhancement request to make the rules somehow configurable by the user.

Best regards,
Boris


Ken Geis wrote:
> I created the start of a CWM metamodel in EMF. I ran through the whole
> GMF dashboard, but the generated diagram editor has errors in it. Here's
> the first one.
>
> I have an EPackage CWM.ObjectModel. When I generate the Java model, it
> creates a Java package called CWM.ObjectModel with a bunch of classes in
> it (like ObjectModelPackage.) So the generated diagram code below fails
> because it is trying to import a package ("import CWM.ObjectModel;".) So
> there are two places in the code below where ObjectModel is being used
> as if it were a class, but it is a package.
>
> Any help?
>
>
> Ken Geis
>
> ------------------------------------------------------------ --
>
> package CWM.diagram.edit.commands;
>
> ....
> import CWM.ObjectModel;
> ....
>
> public class CubeDimensionAssociationCreateCommand extends
> CreateElementCommand
> {
> ....
> /**
> * @generated
> */
> public
> CubeDimensionAssociationCreateCommand(CreateRelationshipRequ est request,
> EObject source,
> EObject target)
> {
> super(request);
> this.source = source;
> this.target = target;
> if (request.getContainmentFeature() == null)
> {
> setContainmentFeature(ObjectModel.ObjectModelPackage.eINSTAN CE
>
> .getNamespace_OwnedElement());
> }
>
> super.setElementToEdit(source);
> }
> ....
> }
Previous Topic:setting properties on source or target when connecting
Next Topic:Connection link disappears when figures connected r moved apart
Goto Forum:
  


Current Time: Thu Apr 25 20:45:29 GMT 2024

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

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

Back to the top