Class GanttChart
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class GanttChart
extends org.eclipse.swt.widgets.Composite
Website
If you want more info or more documentation, please visit: http://www.hexapixel.com/
Description
The GANTT widget has taken hints from Microsoft Project as far as arrow styles and overall look and feel goes. There are features such as dependencies, checkpoints, revised
dates, and much more. Nearly everything is customizable and you can zoom in to detailed day views all the way out to yearly overviews (12 zoom levels). Events can be resized,
dragged and dropped and various other things.
The widget is extremely simple to use for those wishing a basic implementation, or you can customize everything down to the pixel level if you so wish. Basically, if you don't like something, change it!
Important note: This class exposes a few select methods from the actual GanttComposite (where all the magic happens). If you are looking for a specific method and can't find it here, do a call to getGanttComposite() and see if the method you are looking for is located there.
Example creation code:
GanttChart ganttChart = new GanttChart(parentComposite, SWT.NONE);
Calendar calStart = Calendar.getInstance();
Calendar calEnd = Calendar.getInstance();
calEnd.add(Calendar.DATE, 10);
// set the data object to null, and percentage complete to 50
GanttEvent event = new GanttEvent(ganttChart, "Project X", calStart, calEnd, 50);
Customizing
As you may wish to customize the widget beyond the capabilities it already has, there are a few ways you may basically take control over as much or little as you please. First,
there are four interfaces that are of importance. They are the IPaintManager, the IColorManager, the ISettings and the ILanguageManager. Let's start with the IColorManager.
IColorManager
If you don't specify a color manager, the DefaultColorManager will be used. The color manager's job is to return colors to the method that is painting everything that is visual
in the chart. The colors that are returned from the ColorManager will determine everything as far as looks go.
IPaintManager
This interface is one you want to use if you want to dig really deep into how things are drawn. This class by default controls exactly how an event is represented visually,
pixel by pixel. If you don't like the look of a certain object on the chart, this is the interface you will want to implement.
ISettings
This interface is probably the most likely that you will be implementing on your own. Mainly this interface controls pixel values (widths, heights, multipliers) and various
boolean flags (if events can be moved, resized, etc).
ILanguageManager
Should you wish to use a different language than English, this is the interface to implement where you can override all the English text strings with whatever you wish.
- Version:
- 2.0
-
Field Summary
-
Constructor Summary
Constructors Constructor Description GanttChart(org.eclipse.swt.widgets.Composite parent, int style)
Constructs a new GANTT chart widget.GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings)
Constructs a new GANTT chart widget with custom settingsISettings
.GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager)
Constructs a new GANTT chart widget with custom settings and a custom color managerIColorManager
.GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager)
Constructs a new GANTT chart widget with custom settings, custom color managerIColorManager
, a custom paint managerIPaintManager
and a custom language managerILanguageManager
.GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager, java.util.Calendar... holidays)
Constructs a new GANTT chart widget with custom settings, custom color managerIColorManager
, a custom paint managerIPaintManager
and a custom language managerILanguageManager
.GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager, Holiday... holidays)
Constructs a new GANTT chart widget with custom settings, custom color managerIColorManager
, a custom paint managerIPaintManager
and a custom language managerILanguageManager
. -
Method Summary
Modifier and Type Method Description void
addConnection(GanttEvent source, GanttEvent target)
Adds a dependency between two events.void
addDependency(GanttEvent source, GanttEvent target)
Same as addConnection().void
addGanttEventListener(IGanttEventListener listener)
Adds an event listener.void
addGroup(GanttGroup group)
Adds a GanttGroup.void
addUndoRedoListener(IUndoRedoListener listener)
Adds a listener to be notified when undo/redo possibilities changeIColorManager
getColorManager()
Returns the currently set color manager.GanttComposite
getGanttComposite()
Returns the widget that is the actual GANTT widget at the root level.org.eclipse.swt.widgets.ScrollBar
getHorizontalBar()
ILanguageManager
getLanguageManger()
Returns the currently set language manager.IPaintManager
getPaintManager()
Returns the currently set paint manager.GanttEvent
getRandomEvent()
Returns a random GanttEvent, useful for testing.ISettings
getSettings()
Returns the currently set settings implementor.GanttUndoRedoManager
getUndoRedoManager()
Returns the Undo/Redo managerorg.eclipse.swt.widgets.ScrollBar
getVerticalBar()
void
print()
Will print the GanttChart based on the settings made in the PrintDialog.void
redrawGanttChart()
Redraws the GanttChart.void
reindex(GanttEvent event, int newIndex)
Re-indexes an event to show at a new location.void
removeGanttEventListener(IGanttEventListener listener)
Removes and event listener.void
removeGroup(GanttGroup group)
Removes a GanttGroup.void
removeUndoRedoListener(IUndoRedoListener listener)
Removes a listener from being notified when undo/redo possibilities changevoid
setGanttChartPrinter(GanttChartPrinter printer)
Set a different GanttChartPrinter that should be used to print this GanttChart.Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getScrollbarsMode
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Constructor Details
-
GanttChart
public GanttChart(org.eclipse.swt.widgets.Composite parent, int style)Constructs a new GANTT chart widget. For styles, please seeGanttFlags
.- Parameters:
parent
- Parent compositestyle
- Widget style- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
GanttChart
Constructs a new GANTT chart widget with custom settingsISettings
. For styles, please seeGanttFlags
.- Parameters:
parent
- Parent compositestyle
- Widget stylesettings
- ISettings implementation or null- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
GanttChart
public GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager)Constructs a new GANTT chart widget with custom settings and a custom color managerIColorManager
. For styles, please seeGanttFlags
.- Parameters:
parent
- Parent compositestyle
- Widget stylesettings
- ISettings implementation or nullcolorManager
- IColorManager implementation- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
GanttChart
public GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager, java.util.Calendar... holidays)Constructs a new GANTT chart widget with custom settings, custom color managerIColorManager
, a custom paint managerIPaintManager
and a custom language managerILanguageManager
. If any of the managers is set to null the default manager using that implementation will be used. For styles, please seeGanttFlags
.- Parameters:
parent
- Parent compositestyle
- Widget stylesettings
- ISettings implementation or nullcolorManager
- IColorManager implementation or nullpaintManager
- IPaintManager implementation or nulllanguageManager
-ILanguageManager
implementation or nullholidays
- Calendar objects specifying holidays- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
GanttChart
public GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager)Constructs a new GANTT chart widget with custom settings, custom color managerIColorManager
, a custom paint managerIPaintManager
and a custom language managerILanguageManager
. If any of the managers is set to null the default manager using that implementation will be used. For styles, please seeGanttFlags
.- Parameters:
parent
- Parent compositestyle
- Widget stylesettings
- ISettings implementation or nullcolorManager
- IColorManager implementation or nullpaintManager
- IPaintManager implementation or null- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
GanttChart
public GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager, Holiday... holidays)Constructs a new GANTT chart widget with custom settings, custom color managerIColorManager
, a custom paint managerIPaintManager
and a custom language managerILanguageManager
. If any of the managers is set to null the default manager using that implementation will be used. For styles, please seeGanttFlags
.- Parameters:
parent
- Parent compositestyle
- Widget stylesettings
- ISettings implementation or nullcolorManager
- IColorManager implementation or nullpaintManager
- IPaintManager implementation or nulllanguageManager
-ILanguageManager
implementation or nullholidays
- Holiday objects specifying holidays- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
-
-
Method Details
-
addGroup
Adds a GanttGroup. A GanttGroup represents a collection of events that should all draw on the same line.- Parameters:
group
- GanttGroup to add
-
removeGroup
Removes a GanttGroup.- Parameters:
group
- GanttGroup to remove
-
addConnection
Adds a dependency between two events.- Parameters:
source
- GanttEvent sourcetarget
- GanttEvent target
-
addDependency
Same as addConnection().- Parameters:
source
- GanttEvent sourcetarget
- GanttEvent target
-
addGanttEventListener
Adds an event listener.- Parameters:
listener
- IGanttEventListener
-
removeGanttEventListener
Removes and event listener.- Parameters:
listener
- IGanttEventListener
-
getGanttComposite
Returns the widget that is the actual GANTT widget at the root level.- Returns:
- GanttComposite
-
redrawGanttChart
public void redrawGanttChart()Redraws the GanttChart. Call this if an update to the chart has been made that did not cause an automatic redrawing of the chart. -
reindex
Re-indexes an event to show at a new location.- Parameters:
event
- GanttEvent to re-indexnewIndex
- new index position
-
getSettings
Returns the currently set settings implementor.- Returns:
- Settings
-
getColorManager
Returns the currently set color manager.- Returns:
- Color manager
-
getPaintManager
Returns the currently set paint manager.- Returns:
- Paint manager
-
getLanguageManger
Returns the currently set language manager.- Returns:
- Language manager
-
getVerticalBar
public org.eclipse.swt.widgets.ScrollBar getVerticalBar()- Overrides:
getVerticalBar
in classorg.eclipse.swt.widgets.Scrollable
-
getHorizontalBar
public org.eclipse.swt.widgets.ScrollBar getHorizontalBar()- Overrides:
getHorizontalBar
in classorg.eclipse.swt.widgets.Scrollable
-
addUndoRedoListener
Adds a listener to be notified when undo/redo possibilities change- Parameters:
listener
-
-
removeUndoRedoListener
Removes a listener from being notified when undo/redo possibilities change- Parameters:
listener
-
-
getUndoRedoManager
Returns the Undo/Redo manager- Returns:
GanttUndoRedoManager
-
getRandomEvent
Returns a random GanttEvent, useful for testing.- Returns:
- GanttEvent
-
setGanttChartPrinter
Set a different GanttChartPrinter that should be used to print this GanttChart.- Parameters:
printer
- The GanttChartPrinter that should be used to print this GanttChart.
-
print
public void print()Will print the GanttChart based on the settings made in the PrintDialog.
-