com.sdm.quasar.client.swing.commands.adapters
Class JComponentCommandAdapter

java.lang.Object
  extended bycom.sdm.quasar.client.core.commands.AbstractCommandAdapter
      extended bycom.sdm.quasar.client.swing.commands.adapters.JComponentCommandAdapter
All Implemented Interfaces:
CommandAdapter, Disposable

public class JComponentCommandAdapter
extends AbstractCommandAdapter

The JComponentCommandAdapter is an bidirectional adapter between a JComponent that fires action events and the command interface of the quasar client. It trigges a Command, when the action event is fired and it sets the state of the JComponent due to the executable BooleanState of the Command.

Author:
Thomas Wolf

Constructor Summary
JComponentCommandAdapter(javax.swing.JComponent jcomponent, Command command)
          Creates a new JComponentCommandAdapter.
JComponentCommandAdapter(java.lang.String name, javax.swing.JComponent jcomponent, Command command)
          Creates a new JComponentCommandAdapter.
 
Method Summary
 void dispose()
          Disposes the component.
 BooleanState getEnabledBooleanState()
           
 javax.swing.JComponent getJComponent()
          Returns the JComponent adapted to the command.
 void setCommand(Command command)
          Sets (or resets if command==null) the Command this adapter adapts.
 void setEnabledBooleanState(BooleanState enabledState)
          Sets the BooleanState that controls the enabled state of th adapted JComponent.
 void setJComponent(javax.swing.JComponent jcomponent)
          Sets the JComponent to adapt to the command.
 
Methods inherited from class com.sdm.quasar.client.core.commands.AbstractCommandAdapter
executeCommand, getCommand, getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JComponentCommandAdapter

public JComponentCommandAdapter(javax.swing.JComponent jcomponent,
                                Command command)
Creates a new JComponentCommandAdapter.


JComponentCommandAdapter

public JComponentCommandAdapter(java.lang.String name,
                                javax.swing.JComponent jcomponent,
                                Command command)
Creates a new JComponentCommandAdapter.

Parameters:
name -
Method Detail

setCommand

public void setCommand(Command command)
Description copied from interface: CommandAdapter
Sets (or resets if command==null) the Command this adapter adapts.

Specified by:
setCommand in interface CommandAdapter
Overrides:
setCommand in class AbstractCommandAdapter
See Also:
AbstractCommandAdapter.setCommand(com.sdm.quasar.client.core.commands.Command)

getJComponent

public javax.swing.JComponent getJComponent()
Returns the JComponent adapted to the command.


setJComponent

public void setJComponent(javax.swing.JComponent jcomponent)
Sets the JComponent to adapt to the command.

Parameters:
jcomponent - the JComponent to adapt

getEnabledBooleanState

public BooleanState getEnabledBooleanState()
Returns:
a BooleanState that controls the enabled state of th adapted JComponent.

setEnabledBooleanState

public void setEnabledBooleanState(BooleanState enabledState)
Sets the BooleanState that controls the enabled state of th adapted JComponent.

Parameters:
enabledState - the BooleanState to use

dispose

public void dispose()
             throws DisposeException
Description copied from interface: Disposable
Disposes the component.

Important:
This method is called by an administrating component and must never be called directly.

The implementation should release any resources or objects allocated and any services registered. Furthermore, this method should be developed carefully to free a maximum of resources even when the system may have become unstable. In case of one or multiple errors, you should collect them in a DisposeException, continue with the execution, and throw it at the end of the method.

Note: The implementation must not return before the component is disposed. Any threads or asynchronous calls started must be completed before this method returns.

Throws:
DisposeException - if there was one or more errors while disposing the component.
See Also:
Disposable.dispose()