I've override the updateListeners method with my new
removeAssociationListener, that only registers the new event listener (at
the moment it does nothig), to see if works fine and the code is executed
when I delete an association.
But there is a problem: now the associations aren't created!
Someone knows why?
The code is the following ( I have created my own associaton fig class
FigMacmasAssociation)
public class FigMacmasAssociation extends FigAssociation {
public FigMacmasAssociation(Object edge, Layer lay){
super(edge, lay);
}
public void updateListeners(Object oldOwner, Object newOwner) {
removeAssociationListener();
super.updateListeners(oldOwner, newOwner);
}
protected void removeAssociationListener(){
Model.getPump().addModelEventListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt instanceof RemoveAssociationEvent) {
// do what you want to do when this event is fired
}
}
}, Model.getMetaTypes().getModelElement());
}
}
2007/7/12, David Orejuela <[EMAIL PROTECTED]>:
Very thanks for all the information, actually I'm working with it
2007/7/12, Michiel van der Wulp <[EMAIL PROTECTED]>:
>
> Hi David,
>
> For the FigAssociation to receive other events, you may have to overrule
> the following method of FigAssociation:
>
> public void updateListeners(Object oldOwner, Object newOwner) {
> removeAllElementListeners();
> if (newOwner != null) {
> addElementListener(newOwner, new String[] {"isAbstract",
> "remove"});
> }
> /* No further listeners required in this case - the rest is
> handled
> * by the notationProvider and sub-Figs. */
> }
>
> Regards,
> Michiel
>
>
>
> ----- Original Message -----
> *From:* David Orejuela <[EMAIL PROTECTED]>
> *To:* [email protected]
> *Sent:* Thursday, July 12, 2007 9:05 AM
> *Subject:* Re: [argouml-dev] ModelEventPump's property names
>
> Hi Bogdan,
> I'm also interested in this topic but I want to capture a
> RemoveAssociationEvent from a FigAssociation class. I'm a newbie and I don't
> know what I must do, I have written a modelChangued method with code for
> this event, but this method is never executed. have I more to do to enable
> it ?
>
> 2007/7/11, Bogdan Ciprian Pistol <[EMAIL PROTECTED]>:
> >
> > Hello,
> >
> > I have some trouble understanding what are the valid property names of
> > the ModelEventPump.
> >
> > Here is what I investigated so far (please notify me if I'm wrong):
> >
> > The ModelEventPump notify it's listeners on only 4 kinds of events
> > changes:
> > DeleteInstanceEvent, AttributeChangeEvent, RemoveAssociationEvent and
> > AddAssociationEvent.
> >
> > DeleteInstanceEvent uses the source UML element (the notifier) and a
> > property name (a string)
> > that in some parts of ArgoUML is expected to be "remove" and in other
> > parts it doesn't matter it's value, the only test done is if the event
> > is instance of DeleteInstanceEvent.
> >
> > AttributeChangeEvent is initialized with the source UML element, a
> > property name, old and new values. The propery name can have very
> > different values like: "name", "isAbstract", "isActive",
> > "isRoot", "isLeaf", "isSpecification", "visibility", "multiplicity",
> > "ownerScope", "changeability",
> > "targetScope" and maybe other values. (I extracted these values while
> > debugging).
> >
> > RemoveAssociation and AddAssociation events (from the MDR
> > implementation source code) doesn't give me clues how should be used
> > because the AssociationEvent (from MDR) has no source code or javadoc.
> > The events are using AssociationEvent#getNewElement(),
> > AssociationEvent#getEndName(), AssociationEvent#getFixedElement(),
> > which I do not know what are doing.
> >
> > The main problem for me are the valid values for property names.
> >
> > Bogdan,
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> ------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.10.2/894 - Release Date:
> 10/07/2007 17:44
>
>