Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » IllegalArgumetnException when applying a stereotyp
IllegalArgumetnException when applying a stereotyp [message #476969] Fri, 22 February 2008 14:10 Go to next message
Michael is currently offline MichaelFriend
Messages: 43
Registered: July 2009
Member
Hi everybody!

I have a problem when I want to apply a stereotype to a class. I get an
IllegalArgumentException from the metode applyStereotype in the class
ElementOperation. Here is my java code:

...

(before that, register Resource-Factories and Pathmaps)

Stereotype factoryStereotype =
factoryProfile.createOwnedStereotype("factory", true);

org.eclipse.uml2.uml.Class propertyMetaclass = referenceMetaclass(
factoryProfile, UMLPackage.Literals.CLASS.getName());

Extension extension =
factoryStereotype.createExtension(propertyMetaclass, false);

factoryProfile.define();

...

(loading a uml model)

umlModel.applyProfile(factoryProfile);

creator.applyStereotype(factoryStereotype); //creator = class in the
umlModel

--> here I get the exception! is maybe the refernce of the metaclass wrong?

I hope somebody can help me!

Thanx
Michael
Re: IllegalArgumetnException when applying a stereotyp [message #476976 is a reply to message #476969] Fri, 22 February 2008 15:07 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Michael

I'm just speculating but there either could be something wrong with the
definition, or the extension or possibly the stereotype was already
previously applied.
Impossible to tell without a stack trace or more information.

The code in the applyStereotype looks like this....
EClass definition = getDefinition(element, stereotype);


if (definition == null || getExtension(element, stereotype) == null

|| element.getStereotypeApplication(stereotype) != null) {


throw new IllegalArgumentException(String.valueOf(stereotype));

}



Cheers,
- James.


"Michael" <Michael@web.de> wrote in message
news:c0ebac4d81126ad6c57e0617c0e45775$1@www.eclipse.org...
> Hi everybody!
>
> I have a problem when I want to apply a stereotype to a class. I get an
> IllegalArgumentException from the metode applyStereotype in the class
> ElementOperation. Here is my java code:
>
> ..
>
> (before that, register Resource-Factories and Pathmaps)
>
> Stereotype factoryStereotype =
> factoryProfile.createOwnedStereotype("factory", true);
>
> org.eclipse.uml2.uml.Class propertyMetaclass = referenceMetaclass(
> factoryProfile, UMLPackage.Literals.CLASS.getName());
>
> Extension extension = factoryStereotype.createExtension(propertyMetaclass,
> false);
>
> factoryProfile.define();
>
> ..
>
> (loading a uml model)
>
> umlModel.applyProfile(factoryProfile);
>
> creator.applyStereotype(factoryStereotype); //creator = class in the
> umlModel
>
> --> here I get the exception! is maybe the refernce of the metaclass
> wrong?
>
> I hope somebody can help me!
>
> Thanx
> Michael
>
Re: IllegalArgumetnException when applying a stereotyp [message #476983 is a reply to message #476976] Mon, 25 February 2008 09:20 Go to previous message
Michael is currently offline MichaelFriend
Messages: 43
Registered: July 2009
Member
Hi James,

thank you for your reply! The Problem was the extension!
I have created it like this:

Extension extension =
factoryStereotype.createExtension(propertyMetaclass, true);

--> I noticed, that the parameter "true" has turned to "false"!

After that, everything works fine!

Thanx a lot! :)
Re: IllegalArgumetnException when applying a stereotyp [message #626075 is a reply to message #476969] Fri, 22 February 2008 15:07 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Michael

I'm just speculating but there either could be something wrong with the
definition, or the extension or possibly the stereotype was already
previously applied.
Impossible to tell without a stack trace or more information.

The code in the applyStereotype looks like this....
EClass definition = getDefinition(element, stereotype);


if (definition == null || getExtension(element, stereotype) == null

|| element.getStereotypeApplication(stereotype) != null) {


throw new IllegalArgumentException(String.valueOf(stereotype));

}



Cheers,
- James.


"Michael" <Michael@web.de> wrote in message
news:c0ebac4d81126ad6c57e0617c0e45775$1@www.eclipse.org...
> Hi everybody!
>
> I have a problem when I want to apply a stereotype to a class. I get an
> IllegalArgumentException from the metode applyStereotype in the class
> ElementOperation. Here is my java code:
>
> ..
>
> (before that, register Resource-Factories and Pathmaps)
>
> Stereotype factoryStereotype =
> factoryProfile.createOwnedStereotype("factory", true);
>
> org.eclipse.uml2.uml.Class propertyMetaclass = referenceMetaclass(
> factoryProfile, UMLPackage.Literals.CLASS.getName());
>
> Extension extension = factoryStereotype.createExtension(propertyMetaclass,
> false);
>
> factoryProfile.define();
>
> ..
>
> (loading a uml model)
>
> umlModel.applyProfile(factoryProfile);
>
> creator.applyStereotype(factoryStereotype); //creator = class in the
> umlModel
>
> --> here I get the exception! is maybe the refernce of the metaclass
> wrong?
>
> I hope somebody can help me!
>
> Thanx
> Michael
>
Re: IllegalArgumetnException when applying a stereotyp [message #626082 is a reply to message #476976] Mon, 25 February 2008 09:20 Go to previous message
Michael is currently offline MichaelFriend
Messages: 43
Registered: July 2009
Member
Hi James,

thank you for your reply! The Problem was the extension!
I have created it like this:

Extension extension =
factoryStereotype.createExtension(propertyMetaclass, true);

--> I noticed, that the parameter "true" has turned to "false"!

After that, everything works fine!

Thanx a lot! :)
Previous Topic:Re: ChildCreationExtender problem in edit plugin
Next Topic:Migrating from rational rose model to UML2
Goto Forum:
  


Current Time: Mon Aug 08 23:45:49 GMT 2022

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

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

Back to the top