Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Problem with registered Profile
Problem with registered Profile [message #1103129] Fri, 06 September 2013 08:08 Go to next message
Han G is currently offline Han G
Messages: 11
Registered: August 2013
Junior Member
Hi,
I am running a Eclipse-Plugin project which creates a Papyrus model. After the model was created I'd like to apply Stereotypes to some Classes via the Papyrus editor.

Therefore I created a UML-Profile as is done here http://www.eclipse.org/papyrus/usersTutorials/resources/PapyrusUserGuideSeries_AboutUMLProfile_v1.0.0_d20120606.pdf (see attachment). In order to use the UML-Profile after starting the plugin, I registered the model via the Papyrus UML extensionpoints as is done here http://www.papyrusuml.org/home/liblocal/docs/Documentation/ExtensionPoints/EnclosingProfileInPlugin.swf.

After starting the plugin I can select the profile via "Model Explorer" -> "MyModel" -> "Profiles" -> "Apply registered Profile". The dialog shows up and let's me select my Profile (it appears then in the "Profile application" area). But when I select a Class in order to apply my Struct-Stereotype, there is nothing in "Applicable Stereotypes".
Any ideas what I am missing? The Profile was definitely defined and no error messages showed up, yet it seems empty which it is not...

Thanks for help
Han
Re: Problem with registered Profile [message #1105210 is a reply to message #1103129] Mon, 09 September 2013 10:11 Go to previous messageGo to next message
Han G is currently offline Han G
Messages: 11
Registered: August 2013
Junior Member
I don't get it why I can't see any applicable Stereotypes. I created a larger Profile (again registered as described above) with Papyrus and tried to apply it to a UML model using the following snippet:
Profile profile = null;
    try {
      ResourceSet resourceSet = new ResourceSetImpl();
      profile = (Profile)EcoreUtil.getObjectByType(
        resourceSet.getResource(RegisteredProfile.getRegisteredProfile("MyProfile").uri, true)
          .getContents(), UMLPackage.Literals.PROFILE);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    
    System.out.println("Profile is defined = " + profile.isDefined() + "\nStereotypes:");
    for (Stereotype s : profile.getOwnedStereotypes())
      System.out.println("   " + s.getName());
    
    Model testModel = UMLFactory.eINSTANCE.createModel();
    testModel.setName("testModel");
    testModel.applyProfile(profile);
    
    System.out.println("Profile applied to model = " + testModel.isProfileApplied(profile));
    
    Package testPackage = testModel.createNestedPackage("testPackage");
    Class testClass = testPackage.createOwnedClass("testClass", false);
    
    System.out.println("Applicable Stereotypes = " + testClass.getApplicableStereotypes().size());

And I get the following output:
Profile is defined = true
Stereotypes:
   Friends
   Struct Extension
   Struct
   Enum Extension
   Fields
   Enum
   Clazz Extension
   Relation
   Instance
   Clazz
   Instance Extension
Profile applied to model = true
Applicable Stereotypes = 0

Everything except "Enum", "Enum Extension" and "Relation" is extending the imported metaclass "Class". But yet the last output states that there is no applicable Stereotype for Classes.
Has nobody an idea what I am doing wrong?

Regards
Han
Re: Problem with registered Profile [message #1105741 is a reply to message #1103129] Tue, 10 September 2013 04:13 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille Letavernier
Messages: 439
Registered: February 2011
Senior Member
Hi Han,


Are you trying to apply your Stereotypes programmatically or manually?

Programmatically, your model most likely needs to be in a Resource (Not sure about that, but most EMF-Based implementations require Resources and ResourceSet).

If it doesn't work in Papyrus, I lack information to help you. Do you have any error in your error log? Could you send us a plug-in with the failing profile, so that we could reproduce the error?


Regards,
Camille
Re: Problem with registered Profile [message #1105755 is a reply to message #1105741] Tue, 10 September 2013 04:33 Go to previous message
Han G is currently offline Han G
Messages: 11
Registered: August 2013
Junior Member
Hi,
Got the solution, but I don't understand why I needed this:
After defining the Profile I used "Import registered Profile" -> "Ecore" and applied the "EPackage" Stereotype on my Model. Then after defining the Model I was able to see and apply my Stereotypes.
Yet this step would be required in order to define a static Profile (that's where I found this) and not a dynamic one as I used.

Regards,
Han
Previous Topic:Serious bug in Kepler!
Next Topic:[Papyrus] Class Diagram association between class and use case
Goto Forum:
  


Current Time: Wed Aug 20 10:51:35 EDT 2014

Powered by FUDForum. Page generated in 0.02453 seconds