nl.lxtreme.ols.api.ui
Interface ComponentProvider


public interface ComponentProvider

Service interface which provides new components at runtime.

For now, the only components that can be provided are JMenu instances, which are added in and removed from the main dialog's menu bar. Other kinds of components can/will be supported in the future.

If the implementing class of this interface contains a method with the signature #init(org.osgi.framework.BundleContext) (any access modifier), it will be called automatically upon registration of this service. This allows implementors to obtain the BundleContext of this service and access other OSGi services in a low-level manner.


Field Summary
static String COMPONENT_ID_KEY
          Constant to identify ComponentProvider services.
static String MENU_COMPONENT
          Constant to provide a menu component.
 
Method Summary
 void addedToContainer()
          Triggered when the component is added to a container.
 JComponent getComponent()
          Returns the actual instance of the component provided by this implementation.
 void removedFromContainer()
          Triggered when the component is about to get removed from a container.
 

Field Detail

COMPONENT_ID_KEY

static final String COMPONENT_ID_KEY
Constant to identify ComponentProvider services.

See Also:
Constant Field Values

MENU_COMPONENT

static final String MENU_COMPONENT
Constant to provide a menu component.

See Also:
Constant Field Values
Method Detail

addedToContainer

void addedToContainer()
Triggered when the component is added to a container.

Implementors can use this method to initialize listeners and/or other components in context of the (parent) container.

The implementation can validate some stuff. This function is always called on the Event Dispatch Thread (EDT).
Implementors may assume this function is called once after getComponent().


getComponent

JComponent getComponent()
Returns the actual instance of the component provided by this implementation.

Implementors of this interface should keep track of the returned components themselves to access their context (e.g.: their parent). In other words, implementors should return exactly one instance of the component provided by their implementation.

This function is always be called on the Event Dispatch Thread (EDT). The implementor may assume that this function is called once before addedToContainer() , but afterwards, this method can be called multiple times.

Returns:
the (Swing) component provided by this service, cannot be null.

removedFromContainer

void removedFromContainer()
Triggered when the component is about to get removed from a container.

Implementors can use this method to remove listeners and/or other components in context of the (parent) container.

The implementation can validate some stuff. This function must be called on the Event Dispatch Thread (EDT).
Implementors may assume this function is called once after getComponent().



Copyright © 2012 L'Xtreme IT consultancy. All Rights Reserved.