aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Fauth2013-06-26 07:07:13 (EDT)
committerDirk Fauth2013-06-26 07:07:13 (EDT)
commit5179eeccf4b65abaca5b3aa7969b739d5b631191 (patch)
treebd8c339b6dd2ddc9647eeae94462ea3c59f67482
parent121558560c2e979dbf705ef8248ba5f7a554d123 (diff)
downloadorg.eclipse.nebula-5179eeccf4b65abaca5b3aa7969b739d5b631191.zip
org.eclipse.nebula-5179eeccf4b65abaca5b3aa7969b739d5b631191.tar.gz
org.eclipse.nebula-5179eeccf4b65abaca5b3aa7969b739d5b631191.tar.bz2
Added possibility to specify holidays in the gantt chart and
corresponding configuration of the color that should be used to render them.
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractColorManager.java8
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttChart.java11
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java53
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttSection.java18
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IFillBackgroundColors.java14
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeGrayBlue.java8
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeHighContrastBlack.java8
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeSilver.java8
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeWindowsBlue.java8
9 files changed, 134 insertions, 2 deletions
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractColorManager.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractColorManager.java
index 1d12d5e..fec6bea 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractColorManager.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractColorManager.java
@@ -153,6 +153,14 @@ public abstract class AbstractColorManager implements IColorManager {
return getSaturdayBackgroundColorBottom();
}
+ public Color getHolidayBackgroundColorTop() {
+ return getSaturdayBackgroundColorTop();
+ }
+
+ public Color getHolidayBackgroundColorBottom() {
+ return getSaturdayBackgroundColorBottom();
+ }
+
public Color getWeekdayTextColor() {
return getBlack();
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttChart.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttChart.java
index 4657bc6..f897146 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttChart.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttChart.java
@@ -83,6 +83,8 @@ public class GanttChart extends Composite {
private IPaintManager _paintManager;
private ILanguageManager _languageManager;
+ private Calendar[] _holidays;
+
/**
* Constructs a new GANTT chart widget. For styles, please see {@link GanttFlags}.
*
@@ -146,6 +148,8 @@ public class GanttChart extends Composite {
* @param settings ISettings implementation or null
* @param colorManager IColorManager implementation or null
* @param paintManager IPaintManager implementation or null
+ * @param languageManager {@link ILanguageManager} implementation or null
+ * @param holidays Calendar objects specifying holidays
* @throws IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
* </ul>
@@ -154,7 +158,7 @@ public class GanttChart extends Composite {
* subclass</li>
* </ul>
*/
- public GanttChart(final Composite parent, final int style, final ISettings settings, final IColorManager colorManager, final IPaintManager paintManager, final ILanguageManager languageManager) {
+ public GanttChart(final Composite parent, final int style, final ISettings settings, final IColorManager colorManager, final IPaintManager paintManager, final ILanguageManager languageManager, Calendar... holidays) {
super(parent, SWT.NONE);
int styleToUse = style;
@@ -169,6 +173,9 @@ public class GanttChart extends Composite {
_colorManager = colorManager;
_paintManager = paintManager;
_languageManager = languageManager;
+
+ _holidays = holidays;
+
init();
}
@@ -218,7 +225,7 @@ public class GanttChart extends Composite {
_languageManager = new DefaultLanguageManager();
}
- _ganttComposite = new GanttComposite(this, _style, _settings, _colorManager, _paintManager, _languageManager);
+ _ganttComposite = new GanttComposite(this, _style, _settings, _colorManager, _paintManager, _languageManager, _holidays);
_ganttComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java
index 363f957..f0352ab 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java
@@ -150,6 +150,9 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
private Color _sunBGColorTop;
private Color _sunBGColorBottom;
+ private Color _holidayBGColorTop;
+ private Color _holidayBGColorBottom;
+
private Color _wkBGColorTop;
private Color _wkBGColorBottom;
@@ -322,6 +325,9 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
private int _daysToAppendForEndOfDay;
+
+ private final Calendar[] holidays;
+
static {
final String osProperty = System.getProperty("os.name");
if (osProperty != null) {
@@ -338,6 +344,10 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
}
public GanttComposite(final GanttChart parent, final int style, final ISettings settings, final IColorManager colorManager, final IPaintManager paintManager, final ILanguageManager languageManager) {
+ this(parent, style, settings, colorManager, paintManager, languageManager, null);
+ }
+
+ public GanttComposite(final GanttChart parent, final int style, final ISettings settings, final IColorManager colorManager, final IPaintManager paintManager, final ILanguageManager languageManager, final Calendar[] holidays) {
super(parent, SWT.NO_BACKGROUND | SWT.DOUBLE_BUFFERED | SWT.V_SCROLL | SWT.H_SCROLL);
_parentChart = parent;
@@ -428,6 +438,8 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
updateHorizontalScrollbar();
}
});
+
+ this.holidays = holidays;
}
// midnight "thread" (we need to redraw the screen once at Midnight as the date line will otherwise be incorrect)
@@ -635,6 +647,8 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
_satBGColorBottom = _colorManager.getSaturdayBackgroundColorBottom();
_sunBGColorTop = _colorManager.getSundayBackgroundColorTop();
_sunBGColorBottom = _colorManager.getSundayBackgroundColorBottom();
+ _holidayBGColorTop = _colorManager.getHolidayBackgroundColorTop();
+ _holidayBGColorBottom = _colorManager.getHolidayBackgroundColorBottom();
_weekdayTextColor = _colorManager.getWeekdayTextColor();
_sunTextColor = _colorManager.getSundayTextColor();
@@ -1779,6 +1793,14 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
gc.fillGradientRectangle(startX, startY, dayWidth, heightY, true);
}
+ if (isHoliday(temp)) {
+ gc.setForeground(getHolidayBackgroundGradient(true, gs));
+ gc.setBackground(getHolidayBackgroundGradient(false, gs));
+
+ // fill the whole thing all the way down
+ gc.fillGradientRectangle(startX, startY, dayWidth, heightY, true);
+ }
+
if (DateHelper.isToday(temp)) {
gc.setForeground(_todayBGColorTop);
gc.setBackground(_todayBGColorBottom);
@@ -1798,6 +1820,19 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
}
+
+ private boolean isHoliday(Calendar day) {
+ if (holidays != null) {
+ for (Calendar h : holidays) {
+ if (h.equals(day)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
// draws the zoom level box in the corner, only shown when zooming
private void drawZoomLevel(final GC gc) {
@@ -3055,6 +3090,24 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
return internalGetDayBackgroundGradient(day, top, gs);
}
+ private Color getHolidayBackgroundGradient(final boolean top, final GanttSection gs) {
+ Color ret = null;
+ if (top) {
+ if (gs == null) {
+ ret = _holidayBGColorTop;
+ } else {
+ ret = gs.getHolidayBackgroundColorTop();
+ }
+ } else {
+ if (gs == null) {
+ ret = _holidayBGColorBottom;
+ } else {
+ ret = gs.getHolidayBackgroundColorBottom();
+ }
+ }
+ return ret;
+ }
+
private Color internalGetDayBackgroundGradient(final int day, final boolean top, final GanttSection gs) {
Color ret = null;
switch (day) {
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttSection.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttSection.java
index e064622..be86b07 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttSection.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttSection.java
@@ -51,6 +51,8 @@ public class GanttSection implements IFillBackgroundColors {
private Color _saturdayBgColorBottom;
private Color _sundayBgColorTop;
private Color _sundayBgColorBottom;
+ private Color _holidayBgColorTop;
+ private Color _holidayBgColorBottom;
private Color _weekdayBgColorTop;
private Color _weekdayBgColorBottom;
private Color _selectedBgColorTop;
@@ -222,6 +224,14 @@ public class GanttSection implements IFillBackgroundColors {
return _sundayBgColorTop == null ? _fillColorManager.getSundayBackgroundColorTop() : _sundayBgColorTop;
}
+ public Color getHolidayBackgroundColorBottom() {
+ return _holidayBgColorBottom == null ? _fillColorManager.getHolidayBackgroundColorBottom() : _holidayBgColorBottom;
+ }
+
+ public Color getHolidayBackgroundColorTop() {
+ return _holidayBgColorTop == null ? _fillColorManager.getHolidayBackgroundColorTop() : _holidayBgColorTop;
+ }
+
public Color getWeekdayBackgroundColorBottom() {
return _weekdayBgColorBottom == null ? _fillColorManager.getWeekdayBackgroundColorBottom() : _weekdayBgColorBottom;
}
@@ -262,6 +272,14 @@ public class GanttSection implements IFillBackgroundColors {
_sundayBgColorBottom = sundayBackgroundColorBottom;
}
+ public void setHolidayBackgroundColorTop(final Color holidayBackgroundColorTop) {
+ _holidayBgColorTop = holidayBackgroundColorTop;
+ }
+
+ public void setHolidayBackgroundColorBottom(final Color holidayBackgroundColorBottom) {
+ _holidayBgColorBottom = holidayBackgroundColorBottom;
+ }
+
public void setWeekdayBackgroundColorTop(final Color weekdayBackgroundColorTop) {
_weekdayBgColorTop = weekdayBackgroundColorTop;
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IFillBackgroundColors.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IFillBackgroundColors.java
index 4c07fe8..63aa3e6 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IFillBackgroundColors.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IFillBackgroundColors.java
@@ -50,6 +50,20 @@ public interface IFillBackgroundColors {
Color getSundayBackgroundColorBottom();
/**
+ * The top background gradient color used for drawing the holiday column.
+ *
+ * @return Color
+ */
+ Color getHolidayBackgroundColorTop();
+
+ /**
+ * The bottom background gradient color used for drawing the holiday column.
+ *
+ * @return Color
+ */
+ Color getHolidayBackgroundColorBottom();
+
+ /**
* The bottom background gradient color used for drawing the weekday column.
*
* @return Color
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeGrayBlue.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeGrayBlue.java
index a4c6993..b330593 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeGrayBlue.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeGrayBlue.java
@@ -145,6 +145,14 @@ public class ColorThemeGrayBlue implements IColorManager {
return getSaturdayBackgroundColorBottom();
}
+ public Color getHolidayBackgroundColorTop() {
+ return getSaturdayBackgroundColorTop();
+ }
+
+ public Color getHolidayBackgroundColorBottom() {
+ return getSaturdayBackgroundColorBottom();
+ }
+
public Color getWeekdayTextColor() {
return getBlack();
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeHighContrastBlack.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeHighContrastBlack.java
index 1796ec4..4f838f8 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeHighContrastBlack.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeHighContrastBlack.java
@@ -145,6 +145,14 @@ public class ColorThemeHighContrastBlack implements IColorManager {
return getSaturdayBackgroundColorBottom();
}
+ public Color getHolidayBackgroundColorTop() {
+ return getSaturdayBackgroundColorTop();
+ }
+
+ public Color getHolidayBackgroundColorBottom() {
+ return getSaturdayBackgroundColorBottom();
+ }
+
public Color getWeekdayTextColor() {
return getTextColor();
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeSilver.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeSilver.java
index 34a23d9..529b035 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeSilver.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeSilver.java
@@ -145,6 +145,14 @@ public class ColorThemeSilver implements IColorManager {
return getSaturdayBackgroundColorBottom();
}
+ public Color getHolidayBackgroundColorTop() {
+ return getSaturdayBackgroundColorTop();
+ }
+
+ public Color getHolidayBackgroundColorBottom() {
+ return getSaturdayBackgroundColorBottom();
+ }
+
public Color getWeekdayTextColor() {
return getBlack();
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeWindowsBlue.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeWindowsBlue.java
index d52b6ec..a26d9f4 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeWindowsBlue.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/themes/ColorThemeWindowsBlue.java
@@ -147,6 +147,14 @@ public class ColorThemeWindowsBlue implements IColorManager {
return getSaturdayBackgroundColorBottom();
}
+ public Color getHolidayBackgroundColorTop() {
+ return getSaturdayBackgroundColorTop();
+ }
+
+ public Color getHolidayBackgroundColorBottom() {
+ return getSaturdayBackgroundColorBottom();
+ }
+
public Color getWeekdayTextColor() {
return getBlack();
}