All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.demos.travel.flight.FlightInfoViewer

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----com.ibm.beans.demos.travel.flight.FlightInfoViewer

public class FlightInfoViewer
extends Panel
implements FlightInfoListener, Serializable, ActionListener, ListboxListener, ItemSelectable

This bean is a simple viewer for Airline Flight Information. It is one of the beans that make up the complex composite flight selector bean. Through republishing, the flight selector bean receives FlightInfoEvent's sent from the FlightInfoDap that are then forwarded to the flight info viewer which displays information representing available flights from a Vector of FlightInformation objects stored in the FlightInfoEvent object. A script ties the flight info viewer bean to other beans that make up the composite flight selector bean so that each time the user clicks on a flight, information about the flight is sent to the image viewer bean and the text area bean. When the user has decided on a particular flight, he or she can then click on the Ok button, which causes the viewer to fire a FlightRequestedEvent to the itinerary bean.

See Also:
FlightInfoDap, FlightInfoEvent, FlightInformation, FlightRequestedEvent

Constructor Index

 o FlightInfoViewer()
Constructs an instance of the FlightInfoViewer bean.

Method Index

 o actionPerformed(ActionEvent)
Responds to the user clicking on the Ok button, by firing a FlightRequested event to all registered listeners.
 o addFlightRequestedListener(FlightRequestedListener)
Registers a listener for the FlightRequestedEvent.
 o addItemListener(ItemListener)
Registers a listener for an ItemEvent.
 o createListBox()
Creates, initializes, and embeds the MultiColumnListbox.
 o doLayout()
Sizes and positions the MultiColumnListbox within the viewer based on the current size of the viewer.
 o fireFlightRequested()
Notifies all registered listeners that a flight has been requested.
 o fireItem()
Notifies all registered listeners that a flight has been selected.
 o FlightInformationChanged(FlightInfoEvent)
Receives Flight Information data from the FlightInfoDap.
 o getAvailableFlights()
Returns the Vector of FlightInformation objects corresponding to the list of available flights.
 o getListBox()
Retrieves a reference to the embedded MultiColumnListbox control.
 o getPreferredSize()
Returns the preferredSize property of this bean.
 o getSelectedFlight()
Returns the FlightInformation object corresponding to the currently selected flight.
 o getSelectedObjects()
Returns an array of FlightInformation objects corresponding to the currently selected flight.
 o removeFlightRequestedListener(FlightRequestedListener)
Deregisters a listener for the FlightRequestedEvent.
 o removeItemListener(ItemListener)
Deregisters a listener for an ItemEvent.
 o rowDeselected(ListboxEvent)
Responds to the user deselecting a flight from the list of available flights, by firing a new ItemEvent to each of the registered listeners.
 o rowSelected(ListboxEvent)
Responds to the user selecting a flight from the list of available flights, by firing a new ItemEvent to each of the registered listeners.
 o setAvailableFlights(Vector)
Updates Flight Information data.

Constructors

 o FlightInfoViewer
 public FlightInfoViewer()
Constructs an instance of the FlightInfoViewer bean. The constructor initializes instance data and creates and embeds the MultiColumnListbox control, which is used to convey the Airline Flight Information to the user. The MultiColumnListbox is initially empty; it will be filled in when the FlightInformationChanged() method is invoked.

See Also:
createListBox

Methods

 o createListBox
 public void createListBox()
Creates, initializes, and embeds the MultiColumnListbox.

 o FlightInformationChanged
 public void FlightInformationChanged(FlightInfoEvent flightInfoEvent)
Receives Flight Information data from the FlightInfoDap. The Vector of FlightInformation objects is retrieved from the FlightInfoEvent, and passed to the setAvailableFlights() method.

Parameters:
flightInfoEvent - A FlightInfoEvent object describing the event that occurred.
See Also:
setAvailableFlights, FlightInfoEvent
 o rowSelected
 public void rowSelected(ListboxEvent listboxEvent)
Responds to the user selecting a flight from the list of available flights, by firing a new ItemEvent to each of the registered listeners.

Parameters:
listboxEvent - An ListboxEvent object describing the event that occurred.
See Also:
fireItem
 o rowDeselected
 public void rowDeselected(ListboxEvent listboxEvent)
Responds to the user deselecting a flight from the list of available flights, by firing a new ItemEvent to each of the registered listeners.

Parameters:
listboxEvent - An ListboxEvent object describing the event that occurred.
See Also:
fireItem
 o fireItem
 public void fireItem()
Notifies all registered listeners that a flight has been selected. In the demo scenario, this event fires in response to the user clicking on one of the items in the MultiColumnListbox, and the ImageViewer bean and TextArea bean are updated using data from the FlightInformation object contained in the ItemEvent by means of a script attached to this method.

See Also:
rowSelected, rowDeselected
 o addItemListener
 public synchronized void addItemListener(ItemListener itemListener)
Registers a listener for an ItemEvent.

Parameters:
itemListener - The registering ItemListener.
See Also:
removeItemListener
 o removeItemListener
 public synchronized void removeItemListener(ItemListener itemListener)
Deregisters a listener for an ItemEvent.

Parameters:
itemListener - The deregistering ItemListener.
See Also:
addItemListener
 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns an array of FlightInformation objects corresponding to the currently selected flight. In the demo, since the MultiColumnListbox containing the flight information is set to single-select mode, this will always be either null or an array with one element. This method is required by the ItemSelectable interface; in general, it is probably easier to use the getSelectedFlight() method, which avoids the need to have to index into an array).

Returns:
An array of FlightInformation objects describing the selected flight.
See Also:
getSelectedFlight
 o getSelectedFlight
 public FlightInformation getSelectedFlight()
Returns the FlightInformation object corresponding to the currently selected flight. If multiple selections were enabled for the MultiColumnListbox, the getSelectedObjects() method would have to be used instead of this method.

Returns:
A FlightInformation object describing the selected flight.
See Also:
getSelectedObjects
 o getAvailableFlights
 public Vector getAvailableFlights()
Returns the Vector of FlightInformation objects corresponding to the list of available flights.

Returns:
A Vector of FlightInformation objects corresponding to the available flights.
See Also:
setAvailableFlights, FlightInformation
 o setAvailableFlights
 public synchronized void setAvailableFlights(Vector newAvailableFlights)
Updates Flight Information data. In the demo scenario, this information comes from a FlightInfoEvent fired by the FlightInfoDap. Any currently displayed flight information is cleared, and a new list of flight information is presented.

Parameters:
newAvailableFlights - A Vector of FlightInformation objects.
See Also:
FlightInformationChanged, getAvailableFlights, FlightInformation
 o actionPerformed
 public void actionPerformed(ActionEvent actionEvent)
Responds to the user clicking on the Ok button, by firing a FlightRequested event to all registered listeners.

Parameters:
actionEvent - An ActionEvent object describing the event that occurred.
See Also:
fireFlightRequested
 o fireFlightRequested
 public void fireFlightRequested()
Notifies all registered listeners that a flight has been requested. In the demo scenario, this event fires in response to receiving an actionPerformed event from the Ok button, and the itinerary bean is the only registered listener.

See Also:
actionPerformed, FlightRequested
 o addFlightRequestedListener
 public synchronized void addFlightRequestedListener(FlightRequestedListener fRL)
Registers a listener for the FlightRequestedEvent.

Parameters:
fRL - The registering FlightRequestedListener.
See Also:
removeFlightRequestedListener
 o removeFlightRequestedListener
 public synchronized void removeFlightRequestedListener(FlightRequestedListener fRL)
Deregisters a listener for the FlightRequestedEvent.

Parameters:
fRL - The deregistering FlightRequestedListener.
See Also:
addFlightRequestedListener
 o getPreferredSize
 public Dimension getPreferredSize()
Returns the preferredSize property of this bean. This is used to determine the initial size of the viewer in the Layout view).

Returns:
A Dimension object containing the preferred width and height.
Overrides:
getPreferredSize in class Container
 o doLayout
 public void doLayout()
Sizes and positions the MultiColumnListbox within the viewer based on the current size of the viewer.

Overrides:
doLayout in class Container
 o getListBox
 public MultiColumnListbox getListBox()
Retrieves a reference to the embedded MultiColumnListbox control.

Returns:
A reference to the embedded listBox.

All Packages  Class Hierarchy  This Package  Previous  Next  Index