com.jeta.open.support
Class DefaultComponentFinder

java.lang.Object
  extended by com.jeta.open.support.DefaultComponentFinder
All Implemented Interfaces:
ComponentFinder, ContainerListener, EventListener

public class DefaultComponentFinder
extends Object
implements ComponentFinder, ContainerListener

Interface used to define a service for locating child components within a container that have a given name. Specialized implementations of this interface are responsible for managing the parent container assocation.


Constructor Summary
DefaultComponentFinder(Container parent)
          ctor
 
Method Summary
protected  void buildNames(Container container)
          Recursively searches all Components owned by this container.
 void componentAdded(ContainerEvent e)
          A component was added to the container
 void componentRemoved(ContainerEvent e)
          A component was remove from the container
 void enableComponent(String commandId, boolean bEnable)
          Enables/Disables the menu/toolbar button associated with the commandid
 Collection getAllNamedComponents()
          Recursively searches an associated parent container for all components that are named.
 Component getComponentByName(String componentName)
          Recursively searches an associated parent container for a component with the given name.
 Collection getComponentsByName(String compName)
          Recursively searches an associated parent container for all components with the given name.
 Container getContainer()
          Returns the container associated with this component finder.
 void reset()
          Tells the implementation that any cached components should be flushed and reloaded because the parent container might have changed.
 void setVisible(String commandId, boolean bVisible)
          Shows/Hides the menu/toolbar button associated with the commandid
 void unregisterComponent(Component c)
          Tells the implementation that any cached components should be flushed and reloaded because the parent container might have changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultComponentFinder

public DefaultComponentFinder(Container parent)
ctor

Method Detail

buildNames

protected void buildNames(Container container)
Recursively searches all Components owned by this container. If the Component has a name, we store it in the m_components hash table

Parameters:
container - the container to search

componentAdded

public void componentAdded(ContainerEvent e)
A component was added to the container

Specified by:
componentAdded in interface ContainerListener

componentRemoved

public void componentRemoved(ContainerEvent e)
A component was remove from the container

Specified by:
componentRemoved in interface ContainerListener

enableComponent

public void enableComponent(String commandId,
                            boolean bEnable)
Enables/Disables the menu/toolbar button associated with the commandid

Parameters:
commandId - the id of the command whose button to enable/disable
bEnable - true/false to enable/disable

getComponentByName

public Component getComponentByName(String componentName)
Description copied from interface: ComponentFinder
Recursively searches an associated parent container for a component with the given name. The first component found that has the name is returned. Null is returned if no component is found.

Specified by:
getComponentByName in interface ComponentFinder

getComponentsByName

public Collection getComponentsByName(String compName)
Recursively searches an associated parent container for all components with the given name. An empty collection is returned if no components are found with the given name.

Specified by:
getComponentsByName in interface ComponentFinder
Returns:
a collection of Component objects that have the given name.

getContainer

public Container getContainer()
Returns the container associated with this component finder.

Returns:
the container associated with this component finder.

unregisterComponent

public void unregisterComponent(Component c)
Tells the implementation that any cached components should be flushed and reloaded because the parent container might have changed.


setVisible

public void setVisible(String commandId,
                       boolean bVisible)
Shows/Hides the menu/toolbar button associated with the commandid

Parameters:
commandId - the id of the command whose button to enable/disable
bVisible - show/hide the component/disable

reset

public void reset()
Tells the implementation that any cached components should be flushed and reloaded because the parent container might have changed.

Specified by:
reset in interface ComponentFinder

getAllNamedComponents

public Collection getAllNamedComponents()
Recursively searches an associated parent container for all components that are named. An empty collection is returned if no names components exist.

Specified by:
getAllNamedComponents in interface ComponentFinder
Returns:
a collection of all named Component objects.


Copyright © 2005-2007 Jeff Tassin & Todd Viegut. All Rights Reserved.