org.openswing.swing.gantt.client
Class GanttControl

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.openswing.swing.gantt.client.GanttControl
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class GanttControl
extends javax.swing.JPanel

Title: OpenSwing Framework

Description: Panel that contains a grid on the left side (the gantt legend) and a gantt diagram on the right. Each row of the gannt is defined by a GanttRowVO object, that contains the legend values for the row and a set of Appointment objects. When the set of Appointment objects are read, this control analyze the objects and split an Appointment in more than one, if the Appointment is spreaded on more days, so that each new Appointment is bound inside a day. After editing the gantt, the set of changed Appointments of a specified row can be retrieved by means of "getAppointments" method that analyzes Appointment objects: if there exists two consecutive Appointments, then it joins them in a unique Appointment object, so that the method returns the minimal set of objects.

Copyright: Copyright (C) 2006 Mauro Carniel

This file is part of OpenSwing Framework. This library is free software; you can redistribute it and/or modify it under the terms of the (LGPL) Lesser General Public License as published by the Free Software Foundation; GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be contacted at: maurocarniel@tin.it

See Also:
Serialized Form

Nested Class Summary
 class GanttControl.GanttColumnEditor
          Title: OpenSwing Framework Description: Column editor used to resize the gantt bar.
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GanttControl()
           
 
Method Summary
 void addAppointmentChangeListener(AppointmentChangeListener listener)
          Add a AppointmentChangeListener listener to the current gantt control.
 void addNotify()
          Method called by the JVM to load gannt.
 void addRow(GanttRowVO ganttRow)
          Add a row to the panel (grid on the left + gantt).
 java.util.HashSet getAppointments(int row)
           
 int getColumnWidth()
           
 int getDividerLocation()
           
 java.util.Date getEndDate()
           
 GanttDataLocator getGanttDataLocator()
           
 java.util.Map getGanttParameters()
           
 int getRowCount()
           
 int getRowHeight()
           
 java.util.Date getStartDate()
           
 java.lang.Object getValueAt(int rowNumber, int colIndex)
           
 void init(java.lang.String[] columnNames)
          Create the grid content.
 boolean isAutoLoadData()
           
 boolean isEnableDelete()
           
 boolean isEnableEdit()
           
 boolean isEnableInsert()
           
 boolean isGanttEnabled()
           
 boolean isGridEnabled()
           
 boolean isShowDescription()
           
 boolean isShowTime()
           
 void reloadData()
          Load data in the gantt panel.
 void removeAppointmentChangeListener(AppointmentChangeListener listener)
          Remove the specified AppointmentChangeListener listener from the current gantt control.
 void setAutoLoadData(boolean autoLoadData)
          Define if grid must be automatically loaded when it is showed.
 void setColumnWidth(int width)
          Set columns width.
 void setDividerLocation(int location)
          Set divider location.
 void setEnableDelete(boolean enableDelete)
          Enable deleting of appointments.
 void setEnableEdit(boolean enableEdit)
          enable editing of appointments; default value: true.
 void setEnableInsert(boolean enableInsert)
          Enable inserting of appointments.
 void setEndDate(java.util.Date endDate)
          Set end date.
 void setGanttDataLocator(GanttDataLocator ganttDataLocator)
          Set the gantt data locator.
 void setGanttEnabled(boolean enabled)
          Set gantt editability.
 void setGanttParameters(java.util.Map ganttParameters)
          Set the gantt parameters.
 void setGridColumnVisible(int columnIndex, boolean visible)
          Set column visibility.
 void setGridColumnWidth(int columnIndex, int width)
          Set column width.
 void setGridEnabled(boolean enabled)
          Set editability for the grid on the left.
 void setRowHeight(int height)
          Set row height
 void setShowDescription(boolean showDescription)
          Show the description above the colored rectangle.
 void setShowTime(boolean showTime)
          Used to show the appointment duration above the colored rectangle.
 void setStartDate(java.util.Date startDate)
          Set start date
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GanttControl

public GanttControl()
Method Detail

setStartDate

public final void setStartDate(java.util.Date startDate)
Set start date

Parameters:
startDate - start date

setEndDate

public final void setEndDate(java.util.Date endDate)
Set end date.

Parameters:
endDate - end date

init

public void init(java.lang.String[] columnNames)
Create the grid content.

Parameters:
columnNames - column identifiers for the grid on the left

setColumnWidth

public final void setColumnWidth(int width)
Set columns width.

Parameters:
width - column width

getColumnWidth

public final int getColumnWidth()
Returns:
column width

addNotify

public final void addNotify()
Method called by the JVM to load gannt.


reloadData

public void reloadData()
Load data in the gantt panel.


addRow

public final void addRow(GanttRowVO ganttRow)
Add a row to the panel (grid on the left + gantt).


setGanttEnabled

public final void setGanttEnabled(boolean enabled)
Set gantt editability.

Parameters:
enabled - true if the gantt is editable, false otherwise

isGanttEnabled

public final boolean isGanttEnabled()
Returns:
gantt editability

setGridEnabled

public final void setGridEnabled(boolean enabled)
Set editability for the grid on the left.

Parameters:
enabled - true if the grid on the left is editable, false otherwise

isGridEnabled

public final boolean isGridEnabled()
Returns:
editability for the grid on the left

setRowHeight

public final void setRowHeight(int height)
Set row height

Parameters:
height - row height

getRowHeight

public final int getRowHeight()
Returns:
row height

setDividerLocation

public final void setDividerLocation(int location)
Set divider location.

Parameters:
location - divider location

getDividerLocation

public final int getDividerLocation()
Returns:
divider location

getGanttDataLocator

public final GanttDataLocator getGanttDataLocator()
Returns:
gantt data locator

setGanttDataLocator

public final void setGanttDataLocator(GanttDataLocator ganttDataLocator)
Set the gantt data locator.

Parameters:
ganttDataLocator - gantt data locator

getGanttParameters

public final java.util.Map getGanttParameters()
Returns:
gantt parameters

setGanttParameters

public final void setGanttParameters(java.util.Map ganttParameters)
Set the gantt parameters.

Parameters:
ganttParameters - gantt parameters

getAppointments

public final java.util.HashSet getAppointments(int row)
Parameters:
row - row in the gantt diagram
Returns:
set of Appointment objects defined in the specified row

getRowCount

public final int getRowCount()
Returns:
gantt rows number

isShowDescription

public final boolean isShowDescription()
Returns:
show the description above the colored rectangle

setShowDescription

public final void setShowDescription(boolean showDescription)
Show the description above the colored rectangle.

Parameters:
showDescription - show the description above the colored rectangle

getStartDate

public final java.util.Date getStartDate()
Returns:
start date in the gantt

getEndDate

public final java.util.Date getEndDate()
Returns:
end date in the gantt

isEnableDelete

public final boolean isEnableDelete()
Returns:
enable deleting of appointments

setEnableDelete

public final void setEnableDelete(boolean enableDelete)
Enable deleting of appointments.

Parameters:
enableDelete - enable deleting of appointments

isEnableInsert

public final boolean isEnableInsert()
Returns:
enable inserting of appointments

setEnableInsert

public final void setEnableInsert(boolean enableInsert)
Enable inserting of appointments.

Parameters:
enableInsert - enable inserting of appointments

isShowTime

public final boolean isShowTime()
Returns:
show the appointment duration above the colored rectangle

setShowTime

public final void setShowTime(boolean showTime)
Used to show the appointment duration above the colored rectangle.

Parameters:
showTime - show the appointment duration above the colored rectangle

addAppointmentChangeListener

public final void addAppointmentChangeListener(AppointmentChangeListener listener)
Add a AppointmentChangeListener listener to the current gantt control.

Parameters:
listener - listener to add

removeAppointmentChangeListener

public final void removeAppointmentChangeListener(AppointmentChangeListener listener)
Remove the specified AppointmentChangeListener listener from the current gantt control.

Parameters:
listener - listener to remove

getValueAt

public final java.lang.Object getValueAt(int rowNumber,
                                         int colIndex)
Parameters:
rowNumber - row number
colIndex - column index
Returns:
Object[] grid content (in the legend area), related to the specified row number

setGridColumnWidth

public final void setGridColumnWidth(int columnIndex,
                                     int width)
Set column width.

Parameters:
columnIndex - column index in the grid (legend area)
width - column width to set

setGridColumnVisible

public final void setGridColumnVisible(int columnIndex,
                                       boolean visible)
Set column visibility.

Parameters:
columnIndex - column index in the grid (legend area)
visible - column visibility

isEnableEdit

public final boolean isEnableEdit()
Returns:
enable editing of appointments

setEnableEdit

public final void setEnableEdit(boolean enableEdit)
enable editing of appointments; default value: true.

Parameters:
enableEdit - enable editing of appointments

isAutoLoadData

public final boolean isAutoLoadData()
Returns:
true to automatically load data when the gantt is showed, false otherwise

setAutoLoadData

public final void setAutoLoadData(boolean autoLoadData)
Define if grid must be automatically loaded when it is showed.

Parameters:
autoLoadData - true to automatically load data when the gantt is showed, false otherwise