The Context Framework allows Drombler FX managed components such as Dockable Panes and Actions to communicate in a loosly coupled way - even across bundle boundaries.

The basic abstraction is the org.drombler.commons.context.Context interface. You can use it to look for instances of the specified type and listen for changes of its content.

1. Content Providers

Content providers provide their local context to the application framework.

Typical content providers are:

  • Editor Dockable Panes (the object to edit, custom implementations of action command interfaces such as Savable to interact with actions such as the "Save" action)

  • View Dockable Panes with a "current selection"

1.1. Local Context

Each content provider only manages its own local context.

They provide their local context to the application framework by implementing the LocalContextProvider interface.

To add content to a Context you need a mutable Context implementation such as: SimpleContext

2. Content Consumers

Content consumers query a Context for some type and listen for changes in a Context content using a ContextListener.

Typical content consumers are:

  • View Dockable Panes (show some information about an object)

  • Actions (look for instances of their action command interface)

  • Status Bar Elements (reflect the current state of an object)

2.1. Active Context

The Active Context provides access to the content of the local Context of the currently active object (e.g. a Dockable Pane).

Content consumers interested in the Active Context can implement the following interface: ActiveContextSensitive

Drombler FX will inject the Active Context into managed components.

Note: Don’t forget to listen for changes in the Active Context content using a ContextListener!

2.2. Application Context

The Application-wide Context provides access to the combined content of the local Context of all registered contexts (e.g. provided by open Dockable Panes).

Content consumers interested in the Application-wide Context can implement the following interface: ApplicationContextSensitive

Drombler FX will inject the Application Context into managed components.

Note: Don’t forget to listen for changes in the Application Context content using a ContextListener!

See Actions, Menus and Toolbars for a sample.