|
Re: diagram code generation problem [message #190196 is a reply to message #190166] |
Fri, 30 May 2008 08:19 |
Boris Blajer 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);
> }
> ....
> }
|
|
|
Powered by
FUDForum. Page generated in 0.03347 seconds