How to delete stereotype from the persisted file? [message #477714] |
Tue, 09 September 2008 13:34 |
Eclipse User |
|
|
|
Originally posted by: zhengxie.ie.ibm.com
Hello,
when delete a uml element, its applied stereotype is unapplied and can't
be deleted from the persisted file.
if you need more info, please read on:
A class has a stereotype application as following, by "base_Class",
its properties have stereotype applications too.
......
<packagedElement xmi:type="uml:Class" xmi:id="_2Cm51SVlEdyPG407Qktk6Q"
name="
.......
<Requirements:analytical_requirement xmi:id="_2Cm51yVlEdyPG407Qktk6Q"
bid="IBMR7243" base_Class="_2Cm51SVlEdyPG407Qktk6Q"/>
<Requirements:measure_association xmi:id="_2CwDuiVlEdyPG407Qktk6Q"
base_Property="_2CwDuCVlEdyPG407Qktk6Q"/>
after the class is destroyed by calling
((org.eclipse.uml2.uml.Element)clazz).destroy(),
the stereotype is unapplied, but the following is left in the file
<Requirements:analytical_requirement xmi:id="_2Cm51yVlEdyPG407Qktk6Q"
bid="IBMR7243"/>
<Requirements:measure_association xmi:id="_2CwDuiVlEdyPG407Qktk6Q"/>
Then I use the following code:
for (Iterator iter = element.getAppliedStereotypes().iterator();
iter.hasNext();) {
Stereotype type = (Stereotype) iter.next();
element.unapplyStereotype(type);
type.destroy();
// element.eResource().getContents().remove(type);
}
still the same result.
Can these unapplied stereotypes being deleted also?
I try to delete them from the resource, but the stereotype in the
resource is loaded as DynamicEobject...
Basicly what I need is, when delete a uml element, its applied
stereotype is unapplied and also deleted from the persisted file.
What can be done?
Thanks a million.
Jen
|
|
|
Re: How to delete stereotype from the persisted file? [message #477716 is a reply to message #477714] |
Thu, 11 September 2008 14:06 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Zheng,
unapplyStereotype() should be all that is needed... no need to explicitly
call destroy() since it is called internally.
It may not be removed properly because there is some other reference to the
stereotype application.
I just tried this using the uml editor and it worked fine.
Have a look at org.eclipse.uml2.uml.editor.actions.UnapplyStereotypeAction.
Cheers,
- James.
"Zheng Xie" <zhengxie@ie.ibm.com> wrote in message
news:ga5u1l$9u5$1@build.eclipse.org...
> Hello,
>
> when delete a uml element, its applied stereotype is unapplied and can't
> be deleted from the persisted file.
>
> if you need more info, please read on:
>
> A class has a stereotype application as following, by "base_Class",
> its properties have stereotype applications too.
>
> .....
> <packagedElement xmi:type="uml:Class" xmi:id="_2Cm51SVlEdyPG407Qktk6Q"
> name="
> ......
> <Requirements:analytical_requirement xmi:id="_2Cm51yVlEdyPG407Qktk6Q"
> bid="IBMR7243" base_Class="_2Cm51SVlEdyPG407Qktk6Q"/>
> <Requirements:measure_association xmi:id="_2CwDuiVlEdyPG407Qktk6Q"
> base_Property="_2CwDuCVlEdyPG407Qktk6Q"/>
>
>
>
> after the class is destroyed by calling
> ((org.eclipse.uml2.uml.Element)clazz).destroy(),
>
> the stereotype is unapplied, but the following is left in the file
>
> <Requirements:analytical_requirement xmi:id="_2Cm51yVlEdyPG407Qktk6Q"
> bid="IBMR7243"/>
> <Requirements:measure_association xmi:id="_2CwDuiVlEdyPG407Qktk6Q"/>
>
>
> Then I use the following code:
> for (Iterator iter = element.getAppliedStereotypes().iterator();
> iter.hasNext();) {
> Stereotype type = (Stereotype) iter.next();
> element.unapplyStereotype(type);
> type.destroy();
> // element.eResource().getContents().remove(type);
> }
>
> still the same result.
>
> Can these unapplied stereotypes being deleted also?
>
> I try to delete them from the resource, but the stereotype in the resource
> is loaded as DynamicEobject...
>
> Basicly what I need is, when delete a uml element, its applied stereotype
> is unapplied and also deleted from the persisted file.
>
> What can be done?
>
> Thanks a million.
>
> Jen
|
|
|
Re: How to delete stereotype from the persisted file? [message #626912 is a reply to message #477714] |
Thu, 11 September 2008 14:06 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Zheng,
unapplyStereotype() should be all that is needed... no need to explicitly
call destroy() since it is called internally.
It may not be removed properly because there is some other reference to the
stereotype application.
I just tried this using the uml editor and it worked fine.
Have a look at org.eclipse.uml2.uml.editor.actions.UnapplyStereotypeAction.
Cheers,
- James.
"Zheng Xie" <zhengxie@ie.ibm.com> wrote in message
news:ga5u1l$9u5$1@build.eclipse.org...
> Hello,
>
> when delete a uml element, its applied stereotype is unapplied and can't
> be deleted from the persisted file.
>
> if you need more info, please read on:
>
> A class has a stereotype application as following, by "base_Class",
> its properties have stereotype applications too.
>
> .....
> <packagedElement xmi:type="uml:Class" xmi:id="_2Cm51SVlEdyPG407Qktk6Q"
> name="
> ......
> <Requirements:analytical_requirement xmi:id="_2Cm51yVlEdyPG407Qktk6Q"
> bid="IBMR7243" base_Class="_2Cm51SVlEdyPG407Qktk6Q"/>
> <Requirements:measure_association xmi:id="_2CwDuiVlEdyPG407Qktk6Q"
> base_Property="_2CwDuCVlEdyPG407Qktk6Q"/>
>
>
>
> after the class is destroyed by calling
> ((org.eclipse.uml2.uml.Element)clazz).destroy(),
>
> the stereotype is unapplied, but the following is left in the file
>
> <Requirements:analytical_requirement xmi:id="_2Cm51yVlEdyPG407Qktk6Q"
> bid="IBMR7243"/>
> <Requirements:measure_association xmi:id="_2CwDuiVlEdyPG407Qktk6Q"/>
>
>
> Then I use the following code:
> for (Iterator iter = element.getAppliedStereotypes().iterator();
> iter.hasNext();) {
> Stereotype type = (Stereotype) iter.next();
> element.unapplyStereotype(type);
> type.destroy();
> // element.eResource().getContents().remove(type);
> }
>
> still the same result.
>
> Can these unapplied stereotypes being deleted also?
>
> I try to delete them from the resource, but the stereotype in the resource
> is loaded as DynamicEobject...
>
> Basicly what I need is, when delete a uml element, its applied stereotype
> is unapplied and also deleted from the persisted file.
>
> What can be done?
>
> Thanks a million.
>
> Jen
|
|
|
Powered by
FUDForum. Page generated in 0.03071 seconds