com.jeta.open.gui.framework
Class JETAController

java.lang.Object
  extended by com.jeta.open.gui.framework.JETAController

public abstract class JETAController
extends Object

This is the base class for all controllers in an application. We follow the model-view-controller pattern extensively in the UI. All controllers should derive from this class. A controller is resposible for all event handlers for a JETAPanel (JETAPanels handle only layout and view logic). This controller class also supports disabling listeners. This is useful when updating a view with components that fire events when changed programmatically such as JComboBoxes. See enableEvents(boolean). Usage:

 class MyController extends JETAController {
        public MyController(JETAContainer view) {
                super(view);
                // assign a button handler. If the view has a menu and toolbar button
                // for the same command, this assignAction method will install handlers
                // on both.
                assignAction(MyViewNames.ID_LOGIN_BUTTON, new LoginAction());
                // assign other listeners
        }
 
        public class LoginAction implements ActionListener {
                public void actionPerformed(ActionEvent evt) {
                        MyFrame frame = (MyFrame) getView();
                        //... 
                }
        }
 }
 


Nested Class Summary
static class JETAController.ListenerManager
           
 class JETAController.TextFocusListener
          Focus listener for text fields
 
Constructor Summary
JETAController(JETAContainer view)
          ctor
 
Method Summary
 boolean actionPerformed(String actionName, ActionEvent evt)
          Forwarded from the view when an action occurs.
 void assignAction(String compName, ActionListener action)
          Registers and ActionListener with this controller.
protected  void assignComponentAction(Component comp, String commandId, ActionListener action)
          Registers this controller as an action listener with all components that have the given name found in the associated view.
 void assignListener(String compName, ChangeListener listener)
          Assigns a change listener to the Component for the given name - assuming the component has method addChangeListener( ChangeListener )
 void assignListener(String compName, ListSelectionListener listener)
          Assigns a list listener to the JList for the given name
 void enableEvents(boolean enable)
          Sets the flag that indicates if listener/action events should be propagated to registered listeners
 ActionListener getAction(String actionName)
          Returns the first action listener associated with the given name.
 ActionListener getPrimaryActionListener()
          Returns the main action listener that is registered with components in the associated view.
 JETAContainer getView()
          Returns the view that is associated with this controller.
 boolean invokeAction(String actionName)
          Invokes the action assigned to the given name
 boolean isEventsEnabled()
           
 void stateChanged(ChangeEvent e)
          Forwarded from the view when a change event occurs.
 void updateComponents(Object src)
          Forwards the call to the UIDirector if it is not null
 void valueChanged(ListSelectionEvent e)
          Forwarded from the view when a list selection event occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JETAController

public JETAController(JETAContainer view)
ctor

Parameters:
view - the view whose events we are handling.
Method Detail

actionPerformed

public boolean actionPerformed(String actionName,
                               ActionEvent evt)
Forwarded from the view when an action occurs. This method Lookups up the name of any ActionListener in the m_commands hash map that corresponds to the actionName. It then invokes the

Parameters:
actionName - the name of the action associated with the event
evt - the action event
Returns:
true if the controller handled the action
See Also:
method if a component is found.

assignAction

public void assignAction(String compName,
                         ActionListener action)
Registers and ActionListener with this controller. This controller adds itself as a listener to all components with the given name in the associated view.


assignComponentAction

protected void assignComponentAction(Component comp,
                                     String commandId,
                                     ActionListener action)
Registers this controller as an action listener with all components that have the given name found in the associated view.


assignListener

public void assignListener(String compName,
                           ListSelectionListener listener)
Assigns a list listener to the JList for the given name


assignListener

public void assignListener(String compName,
                           ChangeListener listener)
Assigns a change listener to the Component for the given name - assuming the component has method addChangeListener( ChangeListener )


enableEvents

public void enableEvents(boolean enable)
Sets the flag that indicates if listener/action events should be propagated to registered listeners


getPrimaryActionListener

public ActionListener getPrimaryActionListener()
Returns the main action listener that is registered with components in the associated view.

Returns:
the main action listener

getAction

public ActionListener getAction(String actionName)
Returns the first action listener associated with the given name. If the listener is not found, null is returned

Returns:
the action listener associated with the given component.

getView

public JETAContainer getView()
Returns the view that is associated with this controller.


invokeAction

public boolean invokeAction(String actionName)
Invokes the action assigned to the given name


isEventsEnabled

public boolean isEventsEnabled()
Returns:
the flag that indicates if listener/action events should be propagated to registered listeners

stateChanged

public void stateChanged(ChangeEvent e)
Forwarded from the view when a change event occurs.


updateComponents

public void updateComponents(Object src)
Forwards the call to the UIDirector if it is not null


valueChanged

public void valueChanged(ListSelectionEvent e)
Forwarded from the view when a list selection event occurs. This method

Parameters:
e - the list selection event


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