com.dlsc.flexgantt.swing
Class GanttChartStatusBar<T extends AbstractGanttChart>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.dlsc.flexgantt.swing.StatusBar
                      extended by com.dlsc.flexgantt.swing.GanttChartStatusBar<T>
Type Parameters:
T - the type of the Gantt chart
All Implemented Interfaces:
IProgressMonitor, IDatelineModelListener, IMessageListener, IMultiGanttChartContainerListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.LayoutManager, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class GanttChartStatusBar<T extends AbstractGanttChart>
extends StatusBar
implements IMessageListener, java.beans.PropertyChangeListener, IDatelineModelListener, java.awt.event.MouseMotionListener, IMultiGanttChartContainerListener, IProgressMonitor

A status bar specifically designed for use in combination with a Gantt chart. The status bar has several built-in fields that can be used or not (as desired). Additional custom fields can be added via the method StatusBar.addItem(javax.swing.JComponent). Groups of fields can be visually separated by calling StatusBar.addSeparator().

The status bar implements the IProgressMonitor interface. It can be used to display progress of an activity without blocking the user from working with the Gantt chart. A blocking progress monitor gets provided by when calling AbstractGanttChart.getProgressMonitorFactory() and IProgressMonitorFactory.createProgressMonitor().

Since:
1.0
Author:
Dirk Lemmermann
See Also:
IStatusBarPolicy, IStatusBarPolicy.isStatusBarFieldVisible(StatusBarField), Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.dlsc.flexgantt.command.IProgressMonitor
UNKNOWN
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GanttChartStatusBar(IMultiGanttChartContainer<T> container)
          Constructs a new status bar for the given multi Gantt chart container.
GanttChartStatusBar(T gc)
          Constructs a new status bar for the given Gantt chart.
 
Method Summary
 void beginTask(java.lang.String name, int totalWork)
          Notifies that the main task is beginning.
 void containerChanged(MultiGanttChartContainerEvent evt)
          Listener callback method that will be invoked when the state of the container changes.
 void datelineModelChanged(DatelineModelEvent e)
          The listener's callback method that gets invoked when the model's time span or time zone changes.
 void datelineModelWillChange(DatelineModelEvent evt)
          The listener's callback method that gets invoked when the model's time span or time zone will change.
 void done()
          Notifies that the work is done; that is, either the main task is completed or the user canceled it.
protected  java.lang.String format(ITimeSpan span)
          Formats the given time span with the Gantt chart's status bar policy.
protected  java.lang.String format(long time)
          Forms the given time point with the Gantt chart's status bar policy.
 ActionSelector getActionSelector()
          Returns the action selector used by the status bar to display the actions (key strokes) defined on the Gantt chart.
 javax.swing.JLabel getActionSelectorLabel()
          Returns the label used to display the actions (key strokes) defined on the Gantt chart.
 javax.swing.JLabel getCrosshairLabel()
          Returns the label used to display the crosshair icon when popups are currently enabled.
 AbstractGanttChart getGanttChart()
          Returns the Gantt chart to which the status bar belongs.
 javax.swing.JLabel getGridLabel()
          Returns the label used to display the grid icon when the grid (vertical lines) are currently visible.
 javax.swing.JLabel getMemoryLabel()
          Returns the label used to display the current memory allocation.
 javax.swing.JLabel getMessagesLabel()
          Returns the label used to display the 'incoming messages' icon.
 javax.swing.JLabel getPopupLabel()
          Returns the label used to display the popup icon when popups are currently enabled.
 javax.swing.JLabel getTimeLabel()
          Returns the label used to display a time point.
 javax.swing.JLabel getTimeNowLabel()
          Returns the label used to display the 'time now'.
 javax.swing.JLabel getTimeZoneLabel()
          Returns the label used to display the time zone represented by the model of the Dateline (see IDatelineModel.getTimeZone()).
 javax.swing.JLabel getToolLabel()
          Returns the label used to display the tool icon.
 void internalWorked(double work)
          Internal method to handle scaling correctly.
 boolean isCanceled()
          Returns whether cancelation of current operation has been requested.
 void messageAdded(IMessage msg)
          Called when a message has been added.
 void messageRemoved(IMessage msg)
          Called when a message has been removed.
 void messagesCleared()
          Called when all messages have been removed.
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void setCanceled(boolean value)
          Sets the cancel state to the given value.
protected  void setStatusTime(long time)
          Sets a time point to be displayed in the status bar.
protected  void setStatusTimeSpan(ITimeSpan span)
          Sets a time span to be displayed in the status bar.
 void setTaskName(java.lang.String name)
          Sets the task name to the given value.
 void subTask(java.lang.String name)
          Notifies that a subtask of the main task is beginning.
protected  void updateStatusBar(T gc)
          Updates the content of the status bar based on the status bar policy retrieved from the given Gantt chart.
 void worked(int work)
          Notifies that a given number of work unit of the main task has been completed.
 
Methods inherited from class com.dlsc.flexgantt.swing.StatusBar
addItem, addLayoutComponent, addSeparator, getItemPanel, getResizeIconLabel, getStatus, getStatusLabel, layoutContainer, minimumLayoutSize, paintComponent, preferredLayoutSize, removeAllItems, removeLayoutComponent, setStatus
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, 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
 

Constructor Detail

GanttChartStatusBar

public GanttChartStatusBar(T gc)
Constructs a new status bar for the given Gantt chart.

Parameters:
gc - the Gantt chart for which the status bar will display information
Since:
1.0

GanttChartStatusBar

public GanttChartStatusBar(IMultiGanttChartContainer<T> container)
Constructs a new status bar for the given multi Gantt chart container. The status bar will automatically update itself whenever the user switches to another Gantt chart in the container. This way only one status bar instance is required for several Gantt charts at once.

Parameters:
container - the multi Gantt chart container
Since:
1.0
Method Detail

updateStatusBar

protected void updateStatusBar(T gc)
Updates the content of the status bar based on the status bar policy retrieved from the given Gantt chart.

Parameters:
gc - the Gantt chart with which the status bar will be linked
Since:
1.0
See Also:
IStatusBarPolicy.isStatusBarFieldVisible(StatusBarField)

datelineModelWillChange

public void datelineModelWillChange(DatelineModelEvent evt)
Description copied from interface: IDatelineModelListener
The listener's callback method that gets invoked when the model's time span or time zone will change.

Specified by:
datelineModelWillChange in interface IDatelineModelListener
Parameters:
evt - the event that occured on the dateline

datelineModelChanged

public void datelineModelChanged(DatelineModelEvent e)
Description copied from interface: IDatelineModelListener
The listener's callback method that gets invoked when the model's time span or time zone changes.

Specified by:
datelineModelChanged in interface IDatelineModelListener
Parameters:
e - the event that occured on the dateline

getGanttChart

public AbstractGanttChart getGanttChart()
Returns the Gantt chart to which the status bar belongs.

Returns:
the ganttChart
Since:
1.0

getGridLabel

public javax.swing.JLabel getGridLabel()
Returns the label used to display the grid icon when the grid (vertical lines) are currently visible.

Returns:
the label used to display the grid icon
Since:
1.0

getToolLabel

public javax.swing.JLabel getToolLabel()
Returns the label used to display the tool icon.

Returns:
the label used for the tool icon
Since:
1.0

getPopupLabel

public javax.swing.JLabel getPopupLabel()
Returns the label used to display the popup icon when popups are currently enabled.

Returns:
the label used to display the popup icon
Since:
1.0

getCrosshairLabel

public javax.swing.JLabel getCrosshairLabel()
Returns the label used to display the crosshair icon when popups are currently enabled.

Returns:
the label used to display the crosshair icon
Since:
1.0

getMemoryLabel

public javax.swing.JLabel getMemoryLabel()
Returns the label used to display the current memory allocation.

Returns:
the label used to display the memory usage
Since:
1.0

getMessagesLabel

public javax.swing.JLabel getMessagesLabel()
Returns the label used to display the 'incoming messages' icon.

Returns:
the label used to indicate that messages have arrived
Since:
1.0

getTimeLabel

public javax.swing.JLabel getTimeLabel()
Returns the label used to display a time point.

Returns:
the time label
Since:
1.0

getTimeNowLabel

public javax.swing.JLabel getTimeNowLabel()
Returns the label used to display the 'time now'.

Returns:
the label that displays the current time
Since:
1.0

getTimeZoneLabel

public javax.swing.JLabel getTimeZoneLabel()
Returns the label used to display the time zone represented by the model of the Dateline (see IDatelineModel.getTimeZone()).

Returns:
the label used for the time zone
Since:
1.0

format

protected java.lang.String format(long time)
Forms the given time point with the Gantt chart's status bar policy.

Parameters:
time - the time point to format
Returns:
a text representation of the given time point
Since:
1.0
See Also:
IStatusBarPolicy, AbstractGanttChart.getPolicyProvider()

format

protected java.lang.String format(ITimeSpan span)
Formats the given time span with the Gantt chart's status bar policy.

Parameters:
span - the time span to format
Returns:
a text representation of the given time span
Since:
1.0
See Also:
IStatusBarPolicy, AbstractGanttChart.getPolicyProvider()

messageAdded

public void messageAdded(IMessage msg)
Description copied from interface: IMessageListener
Called when a message has been added.

Specified by:
messageAdded in interface IMessageListener
Parameters:
msg - the added message

messageRemoved

public void messageRemoved(IMessage msg)
Description copied from interface: IMessageListener
Called when a message has been removed.

Specified by:
messageRemoved in interface IMessageListener
Parameters:
msg - the removed message

messagesCleared

public void messagesCleared()
Description copied from interface: IMessageListener
Called when all messages have been removed.

Specified by:
messagesCleared in interface IMessageListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getActionSelector

public ActionSelector getActionSelector()
Returns the action selector used by the status bar to display the actions (key strokes) defined on the Gantt chart.

Returns:
the action selector
Since:
1.0

getActionSelectorLabel

public javax.swing.JLabel getActionSelectorLabel()
Returns the label used to display the actions (key strokes) defined on the Gantt chart.

Returns:
the label used for the registed Gantt chart actions
Since:
1.0
See Also:
getActionSelector()

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

setStatusTime

protected void setStatusTime(long time)
Sets a time point to be displayed in the status bar.

Parameters:
time - the time point to display
Since:
1.0

setStatusTimeSpan

protected void setStatusTimeSpan(ITimeSpan span)
Sets a time span to be displayed in the status bar.

Parameters:
span - the span to display
Since:
1.0

containerChanged

public void containerChanged(MultiGanttChartContainerEvent evt)
Description copied from interface: IMultiGanttChartContainerListener
Listener callback method that will be invoked when the state of the container changes.

Specified by:
containerChanged in interface IMultiGanttChartContainerListener
Parameters:
evt - the container event

beginTask

public void beginTask(java.lang.String name,
                      int totalWork)
Description copied from interface: IProgressMonitor
Notifies that the main task is beginning. This must only be called once on a given progress monitor instance.

Specified by:
beginTask in interface IProgressMonitor
Parameters:
name - the name (or description) of the main task
totalWork - the total number of work units into which the main task is been subdivided. If the value is UNKNOWN the implementation is free to indicate progress in a way which doesn't require the total number of work units in advance.

done

public void done()
Description copied from interface: IProgressMonitor
Notifies that the work is done; that is, either the main task is completed or the user canceled it. This method may be called more than once (implementations should be prepared to handle this case).

Specified by:
done in interface IProgressMonitor

internalWorked

public void internalWorked(double work)
Description copied from interface: IProgressMonitor
Internal method to handle scaling correctly. This method must not be called by a client. Clients should always use the method worked(int).

Specified by:
internalWorked in interface IProgressMonitor
Parameters:
work - the amount of work done

isCanceled

public boolean isCanceled()
Description copied from interface: IProgressMonitor
Returns whether cancelation of current operation has been requested. Long-running operations should poll to see if cancelation has been requested.

Specified by:
isCanceled in interface IProgressMonitor
Returns:
true if cancellation has been requested, and false otherwise
See Also:
IProgressMonitor.setCanceled(boolean)

setCanceled

public void setCanceled(boolean value)
Description copied from interface: IProgressMonitor
Sets the cancel state to the given value.

Specified by:
setCanceled in interface IProgressMonitor
Parameters:
value - true indicates that cancelation has been requested (but not necessarily acknowledged); false clears this flag
See Also:
IProgressMonitor.isCanceled()

setTaskName

public void setTaskName(java.lang.String name)
Description copied from interface: IProgressMonitor
Sets the task name to the given value. This method is used to restore the task label after a nested operation was executed. Normally there is no need for clients to call this method.

Specified by:
setTaskName in interface IProgressMonitor
Parameters:
name - the name (or description) of the main task
See Also:
IProgressMonitor.beginTask(java.lang.String, int)

subTask

public void subTask(java.lang.String name)
Description copied from interface: IProgressMonitor
Notifies that a subtask of the main task is beginning. Subtasks are optional; the main task might not have subtasks.

Specified by:
subTask in interface IProgressMonitor
Parameters:
name - the name (or description) of the subtask

worked

public void worked(int work)
Description copied from interface: IProgressMonitor
Notifies that a given number of work unit of the main task has been completed. Note that this amount represents an installment, as opposed to a cumulative amount of work done to date.

Specified by:
worked in interface IProgressMonitor
Parameters:
work - the number of work units just completed