Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Context API confusion (very long)



>The current ContextManagerEvents don't provide enough information for
>our needs. In terms of the current API, I want to be able to register a
>listener that's told every time someone adds an EnabledSubmission to the
>workbench and everytime a context enables or disables. I also need to
>know which contextId is involved.
>
>I think the ContextManagerEvent should have the following methods:
>  getContextManager()
>  submissionAdded(String contextId)
>  submissionRemoved(String contextId)
>  contextEnabled(String contextId)
>  contextDisabled(String contextId)
>  contextDefined(String contextId)
>
>An example execution flow:
>1. ClientA submits contextA -  submissionAdded(contextA)
>2. contextA becomes enabled - contextActivated(contextA)
>3. ClientB submits contextA - submissionAdded(contextA)
>4. ClientA removes contextA - submissionRemoved(contextA)
>5. ClientB removes contextA - submissionRemoved(contextA)
>6. contextB becomes disabled - contextDisabled(contextA)

1. ContextManagerEvent does provide the method getContextManager().

2. Regarding submissionAdded and submissionRemoved, why would you want to
track this information? The submissions themselves aren't important, only
the actual enabled contexts are. In fact, if someone submits a request to
enabled a context for a particular part and that part isn't active at that
time, the ContextManager is not affected at all. Also, the ContextManager
knows nothing about the EnabledSubmission class, it only cares what
contexts are actually enabled, so if you really needed this for some
reason, the listener methods (and a new event object) would have to go
someplace else, like on ICommandSupport.

3. ContextManagerEvents are broadcast when the set of enabled contexts
changes or the set of defined contexts changes (and tells you why it
broadcast the event). It doesn't tell you the specific deltas in the event,
but you could keep track of that yourself with Set operations:
i.e. Set newlyEnabledContexts = new
HashSet(contextManager.getEnabledContextIds()).removeAll(previouslyEnabledContexts);

If you would like the actual deltas included for you as well, please file
an enhancement request and prefix [ContextMgmt] to the summary.

4. ContextEvents are broadcast when a specific context is enabled/disabled
or defined/undefined, so you can watch individual contexts easily:
i.e. IContextManager.getContext("debugging.java").addContextListener(..);

Thanks,
Chris.



Back to the top