gui.dialogs
Class ConnectionTimetableCreator

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byjavax.swing.JDialog
                      extended bygui.dialogs.ConnectionTimetableCreator
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public final class ConnectionTimetableCreator
extends javax.swing.JDialog
implements java.awt.event.ActionListener

A dialog used to define a timetable for a connection. A list of stations and their order is already known at the time of creating a timetable.

Author:
Piotrek
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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  Connection addedConnection
          A connection added to the world if the OK button has been clicked.
static int CANCEL
          The cancel dialog result.
private  javax.swing.JButton cancelButton
          A cancel button.
private  java.lang.String connectionName
          A name the new connection is to be given.
private  int dialogResult
          The dialog result.
private  javax.swing.JCheckBox eachDayCheckbox
          A `each day' check box.
private  javax.swing.JTextField everyXTimeSpanTextField
          A text field to receive the every x time span repetition per day.
private  javax.swing.JCheckBox fridayCheckbox
          A `Friday' checkbox.
private  int meanOfTransportation
          A mean of transportation for a new connection.
private  javax.swing.JCheckBox mondayCheckbox
          A `Monday' checkbox.
static int OK
          The OK dialog result.
private  javax.swing.JButton okButton
          An OK button.
private  java.awt.Container panel
          A main panel of this dialog.
private  javax.swing.JCheckBox repetitionsCheckBox
          A `Use repetitions' check box.
private  javax.swing.JTextField repetitionsLowerLimit
          A text field for a lower limit of repetitions.
private  javax.swing.JTextField repetitionsUpperLimit
          A text field for an upper limit of repetitions.
private  javax.swing.JCheckBox returnConnectionsCheckBox
          A 'return connection(s) check box.
private  javax.swing.JCheckBox saturdayCheckbox
          A `Saturday' checkbox.
private  java.util.ArrayList stations
          A list of stations.
private  int stationsCount
          A count of stations in the timetable.
private  javax.swing.JCheckBox sundayCheckbox
          A `Sunday' checkbox.
private  javax.swing.JCheckBox thursdayCheckbox
          A `Thursday' checkbox.
private  javax.swing.JButton timesPerDayPreviewButton
          A button used to preview the times that the `every x minutes' value defines.
private  StationsTimetableEditor timetableEditor
          An editor for times of arrivals and departures per stations.
private  javax.swing.JCheckBox tuesdayCheckbox
          A `Tuesday' checkbox.
private  javax.swing.JCheckBox wednesdayCheckbox
          A `Wednesday' checkbox.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
 
Fields inherited from class java.awt.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 javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ConnectionTimetableCreator(java.lang.String title, java.lang.String connectionName, java.util.ArrayList stations, int meanOfTransportation, Connection connection)
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
private  void AddOKCancel()
          Adds the OK and Cancel buttons.
private  void AddRepetitionOptions(boolean fAddNonEditionOptions)
          Adds the options to cuztomise the repetition of this connection.
 Connection GetAddedConnection()
          Gets the connection added to the world if the OK button has been clicked.
private  char GetDayOfWeekMask()
          Gets a mask of day of week set according to the settings on the dialog.
 int GetDialogResult()
          Gets the dialog result.
private  java.util.ArrayList GetInvertedShiftsList()
          Gets an ordered list of shifts of time for an inverted list of stations of a currently defined connection.
private  java.util.ArrayList GetInvertedStationsList()
          Gets an inverted list of stations.
private  java.util.ArrayList GetShiftsList()
          Gets an ordered list of shifts of time for a currently defined connection.
private  void OnEachDayCheckbox()
          A handler for the each day checkbox.
private  void OnOKButton()
          A handler for the OK button.
private  void OnPreviewButton()
          A handler for the preview button.
private  void OnRepetitionCheckbox()
          A handler for the repetiotion checkbox.
 boolean ValidateSettings(java.util.ArrayList errorsList, boolean fValidateDayOfWeek)
          Validates all the entered settings on this dialog.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

connectionName

private java.lang.String connectionName
A name the new connection is to be given.


meanOfTransportation

private int meanOfTransportation
A mean of transportation for a new connection.

See Also:
MeanOfTransportation.AIRPLANE, MeanOfTransportation.BUS, MeanOfTransportation.TRAIN, MeanOfTransportation.SHIP

stationsCount

private int stationsCount
A count of stations in the timetable.


stations

private java.util.ArrayList stations
A list of stations.


timetableEditor

private StationsTimetableEditor timetableEditor
An editor for times of arrivals and departures per stations.


okButton

private javax.swing.JButton okButton
An OK button.


cancelButton

private javax.swing.JButton cancelButton
A cancel button.


OK

public static final int OK
The OK dialog result.

See Also:
Constant Field Values

CANCEL

public static final int CANCEL
The cancel dialog result.

See Also:
Constant Field Values

dialogResult

private int dialogResult
The dialog result.


panel

private java.awt.Container panel
A main panel of this dialog.


addedConnection

private Connection addedConnection
A connection added to the world if the OK button has been clicked. Null if cancel has been chosen.


repetitionsLowerLimit

private javax.swing.JTextField repetitionsLowerLimit
A text field for a lower limit of repetitions.


repetitionsUpperLimit

private javax.swing.JTextField repetitionsUpperLimit
A text field for an upper limit of repetitions.


eachDayCheckbox

private javax.swing.JCheckBox eachDayCheckbox
A `each day' check box.


mondayCheckbox

private javax.swing.JCheckBox mondayCheckbox
A `Monday' checkbox.


tuesdayCheckbox

private javax.swing.JCheckBox tuesdayCheckbox
A `Tuesday' checkbox.


wednesdayCheckbox

private javax.swing.JCheckBox wednesdayCheckbox
A `Wednesday' checkbox.


thursdayCheckbox

private javax.swing.JCheckBox thursdayCheckbox
A `Thursday' checkbox.


fridayCheckbox

private javax.swing.JCheckBox fridayCheckbox
A `Friday' checkbox.


saturdayCheckbox

private javax.swing.JCheckBox saturdayCheckbox
A `Saturday' checkbox.


sundayCheckbox

private javax.swing.JCheckBox sundayCheckbox
A `Sunday' checkbox.


repetitionsCheckBox

private javax.swing.JCheckBox repetitionsCheckBox
A `Use repetitions' check box.


everyXTimeSpanTextField

private javax.swing.JTextField everyXTimeSpanTextField
A text field to receive the every x time span repetition per day.


timesPerDayPreviewButton

private javax.swing.JButton timesPerDayPreviewButton
A button used to preview the times that the `every x minutes' value defines.


returnConnectionsCheckBox

private javax.swing.JCheckBox returnConnectionsCheckBox
A 'return connection(s) check box.

Constructor Detail

ConnectionTimetableCreator

public ConnectionTimetableCreator(java.lang.String title,
                                  java.lang.String connectionName,
                                  java.util.ArrayList stations,
                                  int meanOfTransportation,
                                  Connection connection)
Constructor.

Parameters:
title - A title of the dialog window.
connectionName - A name the new connection is to be given. Ignored if connection is not null.
stations - A list of stations.
meanOfTransportation - A mean of transportation. This is required only to count the default times of travel. Ignored if connection is not null.
connection - A connection to be edited. Set it to null if creating a new connection.
See Also:
MeanOfTransportation.AIRPLANE, MeanOfTransportation.BUS, MeanOfTransportation.TRAIN, MeanOfTransportation.SHIP
Method Detail

GetDialogResult

public int GetDialogResult()
Gets the dialog result.

Returns:
The dialog result.

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)

OnEachDayCheckbox

private void OnEachDayCheckbox()
A handler for the each day checkbox. It enables/disables all the other day checboxes.

See Also:
actionPerformed(ActionEvent)

OnRepetitionCheckbox

private void OnRepetitionCheckbox()
A handler for the repetiotion checkbox. It enables/disables other repetition options.

See Also:
actionPerformed(ActionEvent)

OnPreviewButton

private void OnPreviewButton()
A handler for the preview button. It shows a dialog with the times of departures per day.

See Also:
actionPerformed(ActionEvent)

OnOKButton

private void OnOKButton()
A handler for the OK button. It adds a new connetions.

See Also:
actionPerformed(ActionEvent)

GetAddedConnection

public Connection GetAddedConnection()
Gets the connection added to the world if the OK button has been clicked. Null if cancel has been chosen.

Returns:
A connection added to the world or null if there was none added.

GetDayOfWeekMask

private char GetDayOfWeekMask()
Gets a mask of day of week set according to the settings on the dialog.

Returns:
A mask of day of week.
See Also:
Connection.MONDAY, Connection.TUESDAY, Connection.WEDNESDAY, Connection.THURSDAY, Connection.FRIDAY, Connection.SATURDAY, Connection.SUNDAY

GetShiftsList

private java.util.ArrayList GetShiftsList()
Gets an ordered list of shifts of time for a currently defined connection. The list starts with the departure time shift for the first station. For all the others it contain shifts for both arrival and departure. A list contains Integers representing the shifts in minutes. It is assumed the settings has been validated before a call to this method.

Returns:
A list of shifts in minutes.

GetInvertedShiftsList

private java.util.ArrayList GetInvertedShiftsList()
Gets an ordered list of shifts of time for an inverted list of stations of a currently defined connection. The list starts with the departure time shift for the first station. For all the others it contain shifts for both arrival and departure. A list contains Integers representing the shifts in minutes. It is assumed the settings has been validated before a call to this method.

Returns:
A list of shifts in minutes.

GetInvertedStationsList

private java.util.ArrayList GetInvertedStationsList()
Gets an inverted list of stations.

Returns:
An inverted list of stations.

AddOKCancel

private void AddOKCancel()
Adds the OK and Cancel buttons.


AddRepetitionOptions

private void AddRepetitionOptions(boolean fAddNonEditionOptions)
Adds the options to cuztomise the repetition of this connection.

Parameters:
fAddNonEditionOptions - Indicates whether to show the per day repetitons options and the return connection option. They are not available in the edition mode.

ValidateSettings

public boolean ValidateSettings(java.util.ArrayList errorsList,
                                boolean fValidateDayOfWeek)
Validates all the entered settings on this dialog.

Parameters:
errorsList - A list of strings, the error messages will be added to.
fValidateDayOfWeek - Indicates whether to check the settings for day of week. Preview button does not neet it.
Returns:
A bool value indicating whether the entered settings are OK.