Class GanttChart
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Control
-
- org.eclipse.swt.widgets.Scrollable
-
- org.eclipse.swt.widgets.Composite
-
- org.eclipse.nebula.widgets.ganttchart.GanttChart
-
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class GanttChart extends org.eclipse.swt.widgets.Composite
GanttChart - SWT Widget - 2005-2011. Version 2.0 © Emil Crumhorn - emil dot crumhorn at gmail dot com.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
Fields Modifier and Type Field Description private IColorManager
_colorManager
private GanttComposite
_ganttComposite
private Holiday[]
_holidays
private ILanguageManager
_languageManager
private IPaintManager
_paintManager
private GanttChartPrinter
_printer
private ISettings
_settings
private int
_style
-
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
All Methods Static Methods Instance Methods Concrete Methods 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 changeprivate static Holiday[]
convertToHolidays(java.util.Calendar[] holidays)
IColorManager
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()
private void
init()
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
-
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, isAutoScalable, 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, toString
-
-
-
-
Field Detail
-
_ganttComposite
private GanttComposite _ganttComposite
-
_style
private int _style
-
_settings
private ISettings _settings
-
_colorManager
private IColorManager _colorManager
-
_paintManager
private IPaintManager _paintManager
-
_languageManager
private ILanguageManager _languageManager
-
_holidays
private Holiday[] _holidays
-
_printer
private GanttChartPrinter _printer
-
-
Constructor Detail
-
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
public GanttChart(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings)
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 Detail
-
addGroup
public void addGroup(GanttGroup group)
Adds a GanttGroup. A GanttGroup represents a collection of events that should all draw on the same line.- Parameters:
group
- GanttGroup to add
-
removeGroup
public void removeGroup(GanttGroup group)
Removes a GanttGroup.- Parameters:
group
- GanttGroup to remove
-
init
private void init()
-
convertToHolidays
private static Holiday[] convertToHolidays(java.util.Calendar[] holidays)
-
addConnection
public void addConnection(GanttEvent source, GanttEvent target)
Adds a dependency between two events.- Parameters:
source
- GanttEvent sourcetarget
- GanttEvent target
-
addDependency
public void addDependency(GanttEvent source, GanttEvent target)
Same as addConnection().- Parameters:
source
- GanttEvent sourcetarget
- GanttEvent target
-
addGanttEventListener
public void addGanttEventListener(IGanttEventListener listener)
Adds an event listener.- Parameters:
listener
- IGanttEventListener
-
removeGanttEventListener
public void removeGanttEventListener(IGanttEventListener listener)
Removes and event listener.- Parameters:
listener
- IGanttEventListener
-
getGanttComposite
public GanttComposite 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
public void reindex(GanttEvent event, int newIndex)
Re-indexes an event to show at a new location.- Parameters:
event
- GanttEvent to re-indexnewIndex
- new index position
-
getSettings
public ISettings getSettings()
Returns the currently set settings implementor.- Returns:
- Settings
-
getColorManager
public IColorManager getColorManager()
Returns the currently set color manager.- Returns:
- Color manager
-
getPaintManager
public IPaintManager getPaintManager()
Returns the currently set paint manager.- Returns:
- Paint manager
-
getLanguageManger
public ILanguageManager 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
public void addUndoRedoListener(IUndoRedoListener listener)
Adds a listener to be notified when undo/redo possibilities change- Parameters:
listener
-
-
removeUndoRedoListener
public void removeUndoRedoListener(IUndoRedoListener listener)
Removes a listener from being notified when undo/redo possibilities change- Parameters:
listener
-
-
getUndoRedoManager
public GanttUndoRedoManager getUndoRedoManager()
Returns the Undo/Redo manager- Returns:
GanttUndoRedoManager
-
getRandomEvent
public GanttEvent getRandomEvent()
Returns a random GanttEvent, useful for testing.- Returns:
- GanttEvent
-
setGanttChartPrinter
public void setGanttChartPrinter(GanttChartPrinter printer)
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.
-
-