[kepler-dev] Removing ports (and relations)

Rod Spears rods at ku.edu
Mon Aug 30 09:15:04 PDT 2004


Thanks, the setContainer(null) worked.

I did now find the documentation that _removePort shouldn't used, but 
rather that setContainer(null) should be.

I do not remember what the exception was, but very bad things were 
happening....

Thanks again for the help,
Rod


Edward A Lee wrote:

> At 08:37 AM 8/30/2004 -0500, Rod Spears wrote:
>
>> I need to remove a port, which means I need to unlink and and remove 
>> all the relations to that port. In fact, I think it would be best to 
>> remove (delete) all the relations linked to that port.
>
>
> When you remove a port (by calling port.setContainer(null) or
> via a MoML change request <deletePort name="portName"/>), it
> automatically takes care of removing links to relations.
>
> However, removing the relation is not necessarily the right thing
> to do. The relation likely has other links to it, and you don't
> necessarily want to remove those.
>
> Vergil has some code somewhere that tries to be smart about this...
> If the relation has exactly one other link to it, then it removes
> the relation.  Otherwise, it leaves it in place...
>
>
>> What would be the best way to get that done?
>>
>> I tried calling unlinkAll and unlinkAllInside on the port, that 
>> allowed me to remove the port without any exceptions, but the 
>> relation(s) was still there.
>>
>> Then I tried enumerating thru the relations and calling 
>> relation.unlinkAll(), but that causes an exception after the port 
>> goes away.
>
>
> What exception?
>
> Edward
>
>
>> I did not try the two approaches together.
>>
>> Thanks,
>> Rod
>
>
> ------------
> Edward A. Lee, Professor
> 518 Cory Hall, UC Berkeley, Berkeley, CA 94720
> phone: 510-642-0455, fax: 510-642-2739
> eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
>




More information about the Kepler-dev mailing list