gui.controls
Class TravelSolutionsChooser

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bygui.controls.TravelSolutionsChooser
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, java.io.Serializable

public final class TravelSolutionsChooser
extends javax.swing.JPanel
implements javax.swing.event.ListSelectionListener, java.awt.event.ActionListener

A list used to choose one of the generated travel solutions to be displayed in the view. It might be also sorted.

Author:
Piotrek
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.JButton acceptButton
          A button used to accept the selected travel proposal.
private  javax.swing.JButton closeButton
          A button used to close the travel solutions choosing.
private  javax.swing.DefaultListModel listModel
          The list model providing an API to add items to the list.
private  javax.swing.JScrollPane listPane
          The scroll pane making the list scrollable.
private  javax.swing.JButton rejectButton
          A button used to reject the selected travel proposal.
private  javax.swing.JButton saveButton
          A button used to save the travel solutions list to a file.
private  javax.swing.JList solutionsList
          A list control displaying the travel solutions.
private  javax.swing.JButton sortButton
          A button used to sort the current list of travel solutions.
private  javax.swing.JButton statsButton
          A button used to show the queries stats.
private  WorldView worldView
          A view displaying the selected travel solution.
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TravelSolutionsChooser(WorldView worldView, java.awt.event.ActionListener actionListener)
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 javax.swing.JButton GetAcceptButton()
          Gets the `accept' button.
 javax.swing.JButton GetCloseButton()
          Gets the `close' button.
 javax.swing.JButton GetRejectButton()
          Gets the `reject' button.
 ConnectionsFinderTask GetSelectedSolution()
          Gets the currently selected solution.
 java.util.ArrayList GetSolutionsList()
          Gets the current list of travel solutions in the chooser.
 javax.swing.JButton GetSortButton()
          Gets the `sort' button.
 void LoadSolutions(java.util.ArrayList solutions)
          Loads the given list of travel solutions into the list control.
 void paint(java.awt.Graphics g)
           
 void RemoveSelectedTravelSolution()
          Removes the currently selected travel solution.
private  void SaveListToFile(java.lang.String fileName)
          Saves the current list of solutions to the given file.
 void setBounds(int x, int y, int width, int height)
           
 void valueChanged(javax.swing.event.ListSelectionEvent e)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

acceptButton

private javax.swing.JButton acceptButton
A button used to accept the selected travel proposal.


rejectButton

private javax.swing.JButton rejectButton
A button used to reject the selected travel proposal.


sortButton

private javax.swing.JButton sortButton
A button used to sort the current list of travel solutions.


closeButton

private javax.swing.JButton closeButton
A button used to close the travel solutions choosing.


saveButton

private javax.swing.JButton saveButton
A button used to save the travel solutions list to a file.


statsButton

private javax.swing.JButton statsButton
A button used to show the queries stats.


worldView

private WorldView worldView
A view displaying the selected travel solution.


solutionsList

private javax.swing.JList solutionsList
A list control displaying the travel solutions.


listModel

private javax.swing.DefaultListModel listModel
The list model providing an API to add items to the list.


listPane

private javax.swing.JScrollPane listPane
The scroll pane making the list scrollable.

Constructor Detail

TravelSolutionsChooser

public TravelSolutionsChooser(WorldView worldView,
                              java.awt.event.ActionListener actionListener)
Constructor.

Parameters:
worldView - A view showing the selected travel solution.
actionListener - An action listener for the `Close' button.
Method Detail

GetAcceptButton

public javax.swing.JButton GetAcceptButton()
Gets the `accept' button.

Returns:
A `accept' button.

GetRejectButton

public javax.swing.JButton GetRejectButton()
Gets the `reject' button.

Returns:
A `reject' button.

GetSortButton

public javax.swing.JButton GetSortButton()
Gets the `sort' button.

Returns:
A `sort' button.

GetCloseButton

public javax.swing.JButton GetCloseButton()
Gets the `close' button.

Returns:
A `close' button.

paint

public void paint(java.awt.Graphics g)
See Also:
JComponent.paint(java.awt.Graphics)

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
See Also:
Component.setBounds(int, int, int, int)

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
See Also:
ListSelectionListener.valueChanged(javax.swing.event.ListSelectionEvent)

LoadSolutions

public void LoadSolutions(java.util.ArrayList solutions)
Loads the given list of travel solutions into the list control.

Parameters:
solutions - A list of travel solutions to be loaded.

GetSelectedSolution

public ConnectionsFinderTask GetSelectedSolution()
Gets the currently selected solution.

Returns:
A currently selected solution or a null value if there is none.

RemoveSelectedTravelSolution

public void RemoveSelectedTravelSolution()
Removes the currently selected travel solution.


GetSolutionsList

public java.util.ArrayList GetSolutionsList()
Gets the current list of travel solutions in the chooser.

Returns:
A current list of travel solutions stored in the chooser. If there are no solutions, an empty list is returned.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

SaveListToFile

private void SaveListToFile(java.lang.String fileName)
Saves the current list of solutions to the given file.

Parameters:
fileName - A name of the file to save the list to.