[EMAIL PROTECTED] wrote:
Thanks again for the insight, my C++ is a bit rusty so I didn't really get everything. But after all you're saying that if I give the same XDispatch object to the other button it should also get the same Listener, right? My experience shows that no matter what XDispatch I return, the addStatusListener gets called everytime and a new StatusListener gets assigned and I don't have a chance to tell it which one, since the addStatusListener gets the new StatusListener as an argument.
So have can I control this behaviour?

Hi Jimmy,

I am not sure if I understand your current problem. First you should assure that you provide one dispatch object for a command. AddStatusListener is called by user every interface elements which is bound to the command. That means you have no influence when or how often addStatusListener is called. Therefore a dispatch object must maintain a container for the listeners which can add themselves via addStatusListener.

The logical structure (pseudo code!) should look like:

DispatchObject::addStatusListener( XStatusListener xStatusListener )
{
  // Add new listener to my listener container
  ListenerContainer.add( xStatusListener );

  // Create current state event
  FeatureStateEvent aFeatureStateEvent;
  aFeatureStateEvent.State = aState;
  ...

  // send current status to the new listener
  xStatusListener.statusChanged( aFeatureStateEvent );
}

void DispatchObject::removeStatusListener( XStatusListener xStatusListener )
{
  // remove status listener from my container
  ListenerContainer.remove( xStatusListener );
}

XDispatch XDispatchProvider::queryDispatch( URL aURL, ... )
{
  if ( aURL.Protocol.equalsAscii( "myprotocol:" ))
  {
    // Look for a previously created dispatch object
    dispatchObject = container[aURL];
    if ( dispatch == null )
    {
      // create on demand new dispatch object
      dispatchObject = new DispatchObject( aURL );
      container[aURL] = dispatchObject;
    }
    return dispatchObject;
  }

  return null;
}

Regards,
Carsten

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to