aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertin Kiekebosch2013-05-08 04:07:52 (EDT)
committerJudith Gull2013-05-08 04:38:36 (EDT)
commit076a480f89ead73e8842de121ab9471e1d7908d4 (patch)
treedd88c6294468b92d30a43f80ed5fcd6fd48cf36f
parenteef2792d37da9b6046fc3bb3d112ca58db76947b (diff)
downloadorg.eclipse.scout.rt-076a480f89ead73e8842de121ab9471e1d7908d4.zip
org.eclipse.scout.rt-076a480f89ead73e8842de121ab9471e1d7908d4.tar.gz
org.eclipse.scout.rt-076a480f89ead73e8842de121ab9471e1d7908d4.tar.bz2
Bug 388722 - Calendar field improvmentsrefs/changes/07/12607/3
Applies patch by Bertin Kiekebosch with minor changes https://bugs.eclipse.org/bugs/show_bug.cgi?id=388722 Change-Id: Ie5962edcdee8a47720fb2da1a31998cfcf7de350 Reviewed-on: https://git.eclipse.org/r/12607 Tested-by: Hudson CI Reviewed-by: Judith Gull <jgu@bsiag.com> IP-Clean: Judith Gull <jgu@bsiag.com>
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/AbstractCalendar.java109
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/ICalendar.java98
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/AbstractCalendarDocumentBuilder.java197
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarDayBuilder.java15
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarMonthBuilder.java9
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWeekBuilder.java17
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWorkWeekBuilder.java17
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineComponentElementFactory.java22
-rw-r--r--org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineTextComponentElementFactory.java8
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/calendar/SwingScoutCalendar.java22
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/AbstractCalendarCell.java2
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/DateChooser.java58
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/LargeCalendarCell.java14
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/SmallCalendarCell.java6
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/CalendarItemContainer.java6
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/SwtScoutCalendar.java4
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/layout/WeekItemLayout.java16
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/AbstractCell.java51
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/CentralPanel.java4
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/SwtCalendar.java53
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/TimelineColumn.java26
-rw-r--r--org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/WeekCell.java14
-rw-r--r--org.eclipse.scout.svg.ui.rap/src/org/eclipse/scout/svg/ui/rap/calendarfield/RwtScoutCalendarField.java6
23 files changed, 700 insertions, 74 deletions
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/AbstractCalendar.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/AbstractCalendar.java
index 407f514..632c916 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/AbstractCalendar.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/AbstractCalendar.java
@@ -92,6 +92,48 @@ public abstract class AbstractCalendar extends AbstractPropertyObserver implemen
return null;
}
+ @ConfigProperty(ConfigProperty.INTEGER)
+ @Order(500)
+ @ConfigPropertyValue("6")
+ protected int getConfiguredStartHour() {
+ return 6;
+ }
+
+ @ConfigProperty(ConfigProperty.INTEGER)
+ @Order(510)
+ @ConfigPropertyValue("19")
+ protected int getConfiguredEndHour() {
+ return 19;
+ }
+
+ @ConfigProperty(ConfigProperty.BOOLEAN)
+ @Order(520)
+ @ConfigPropertyValue("true")
+ protected boolean getConfiguredUseOverflowCells() {
+ return true;
+ }
+
+ @ConfigProperty(ConfigProperty.BOOLEAN)
+ @Order(530)
+ @ConfigPropertyValue("true")
+ protected boolean getConfiguredShowDisplayModeSelection() {
+ return true;
+ }
+
+ @ConfigProperty(ConfigProperty.BOOLEAN)
+ @Order(540)
+ @ConfigPropertyValue("true")
+ protected boolean getConfiguredMarkNoonHour() {
+ return true;
+ }
+
+ @ConfigProperty(ConfigProperty.BOOLEAN)
+ @Order(550)
+ @ConfigPropertyValue("true")
+ protected boolean getConfiguredMarkOutOfMonthDays() {
+ return true;
+ }
+
private Class<? extends ICalendarItemProvider>[] getConfiguredProducers() {
Class[] dca = ConfigurationUtility.getDeclaredPublicClasses(getClass());
Class<ICalendarItemProvider>[] foca = ConfigurationUtility.sortFilteredClassesByOrderAnnotation(dca, ICalendarItemProvider.class);
@@ -139,6 +181,13 @@ public abstract class AbstractCalendar extends AbstractPropertyObserver implemen
m_uiFacade = new P_UIFacade();
setTitle(getConfiguredTitle());
setSelectedDate(new Date());
+ setStartHour(getConfiguredStartHour());
+ setEndHour(getConfiguredEndHour());
+ setUseOverflowCells(getConfiguredUseOverflowCells());
+ setShowDisplayModeSelection(getConfiguredShowDisplayModeSelection());
+ setMarkNoonHour(getConfiguredMarkNoonHour());
+ setMarkOutOfMonthDays(getConfiguredMarkOutOfMonthDays());
+
// menus
ArrayList<IMenu> menuList = new ArrayList<IMenu>();
Class<? extends IMenu>[] ma = getConfiguredMenus();
@@ -258,6 +307,66 @@ public abstract class AbstractCalendar extends AbstractPropertyObserver implemen
}
@Override
+ public int getEndHour() {
+ return (Integer) propertySupport.getProperty(PROP_END_HOUR);
+ }
+
+ @Override
+ public void setEndHour(int hour) {
+ propertySupport.setProperty(PROP_END_HOUR, hour);
+ }
+
+ @Override
+ public int getStartHour() {
+ return (Integer) propertySupport.getProperty(PROP_START_HOUR);
+ }
+
+ @Override
+ public void setStartHour(int hour) {
+ propertySupport.setProperty(PROP_START_HOUR, hour);
+ }
+
+ @Override
+ public boolean getUseOverflowCells() {
+ return (Boolean) propertySupport.getProperty(PROP_USE_OVERFLOW_CELLS);
+ }
+
+ @Override
+ public void setUseOverflowCells(boolean useOverflowCells) {
+ propertySupport.setProperty(PROP_USE_OVERFLOW_CELLS, useOverflowCells);
+ }
+
+ @Override
+ public boolean getShowDisplayModeSelection() {
+ return (Boolean) propertySupport.getProperty(PROP_SHOW_DISPLAY_MODE_SELECTION);
+ }
+
+ @Override
+ public void setShowDisplayModeSelection(boolean showDisplayModeSelection) {
+ propertySupport.setProperty(PROP_SHOW_DISPLAY_MODE_SELECTION, showDisplayModeSelection);
+ }
+
+ @Override
+ public boolean getMarkNoonHour() {
+ return (Boolean) propertySupport.getProperty(PROP_MARK_NOON_HOUR);
+ }
+
+ @Override
+ public void setMarkNoonHour(boolean markNoonHour) {
+ propertySupport.setProperty(PROP_MARK_NOON_HOUR, markNoonHour);
+ }
+
+ @Override
+ public boolean getMarkOutOfMonthDays() {
+ return (Boolean) propertySupport.getProperty(PROP_MARK_OUT_OF_MONTH_DAYS);
+ }
+
+ @Override
+ public void setMarkOutOfMonthDays(boolean markOutOfMonthDays) {
+ propertySupport.setProperty(PROP_MARK_OUT_OF_MONTH_DAYS, markOutOfMonthDays);
+ }
+
+ @Override
public boolean isLoadInProgress() {
return propertySupport.getPropertyBool(PROP_LOAD_IN_PROGRESS);
}
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/ICalendar.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/ICalendar.java
index 192c8e1..159da6f 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/ICalendar.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/calendar/ICalendar.java
@@ -60,6 +60,33 @@ public interface ICalendar extends IPropertyObserver {
*/
String PROP_LOAD_IN_PROGRESS = "loadInProgress";
/**
+ * type int
+ */
+ String PROP_START_HOUR = "startHour";
+ /**
+ * type int
+ */
+ String PROP_END_HOUR = "endHour";
+ /**
+ * type {@link Boolean}
+ */
+ String PROP_USE_OVERFLOW_CELLS = "useOverflowCells";
+ /**
+ * type {@link Boolean}
+ */
+ String PROP_SHOW_DISPLAY_MODE_SELECTION = "showDisplayModeSelection";
+
+ /**
+ * type {@link Boolean}
+ */
+ String PROP_MARK_NOON_HOUR = "markNoonHour";
+
+ /**
+ * type {@link Boolean}
+ */
+ String PROP_MARK_OUT_OF_MONTH_DAYS = "markOutOfMonthDays";
+
+ /**
* {@link Object}
* <p>
* Container of this calendar, {@link ICalendarField}
@@ -147,6 +174,77 @@ public interface ICalendar extends IPropertyObserver {
boolean isCalendarChanging();
/**
+ * Configures the starting hour of the calendar. Only visible when the calendar is in day, week or work-week mode.
+ * Together with getEndHour and getOverflowCells is defines the timeline of a day.
+ * <p>
+ * Default {@code 6}.
+ *
+ * @see getEndHour
+ * @see getUseOverflowCells
+ */
+ int getStartHour();
+
+ void setStartHour(int hour);
+
+ /**
+ * The starting hour of the calendar. Only visible when the calendar is in day, week or work-week mode.
+ * Together with getStartHour and getUseOverflowCells is defines the timeline of a day.
+ * <p>
+ * Default {@code 19}.
+ *
+ * @see getStartHour
+ * @see getUseOverflowCells
+ */
+ int getEndHour();
+
+ void setEndHour(int hour);
+
+ /**
+ * Defines the label of the first and last cell of the calendar. Only visible when the calendar is in day, week or
+ * work-week mode. Together with getConfiguredStartHour and getConfiguredEndHour it defines the timeline of a day. If
+ * true the timeline displays "sooner" and "later" instead of the first and last defined hour.
+ * <p>
+ * Appointments that are outside the defined hours of the calender are still shown in the first and last cell.
+ * <p>
+ * Default {@code true}.
+ *
+ * @see getEndHour
+ * @see getStartHour
+ */
+ boolean getUseOverflowCells();
+
+ void setUseOverflowCells(boolean useOverflowCells);
+
+ /**
+ * Specifies whether the display mode options (day, week, workweek or month) at the bottom of the calendar are visible
+ * or not. If hidden, set the mode in code with setDisplayMode(ICalendar.DISPLAY_MODE_WEEK);
+ * <p>
+ * Default {@code true}.
+ */
+ boolean getShowDisplayModeSelection();
+
+ void setShowDisplayModeSelection(boolean showDisplayModeSelection);
+
+ /**
+ * Defines whether or not the noon hour is painted with a darker color. The type of client (Swing, SWT) defines how
+ * it is actually painted. In RAP this is not supported.
+ */
+ boolean getMarkNoonHour();
+
+ void setMarkNoonHour(boolean markNoonHour);
+
+ /**
+ * Defines whether or not days that are outside the current month are painted with a darker background color.
+ */
+ boolean getMarkOutOfMonthDays();
+
+ void setMarkOutOfMonthDays(boolean markOutOfMonthDays);
+
+ /*
+ * UI interface
+ */
+
+ /**
* {@link Object}
* <p>
* Container of this calendar, {@link ICalendarField}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/AbstractCalendarDocumentBuilder.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/AbstractCalendarDocumentBuilder.java
index 78f9ad8..4dabe60 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/AbstractCalendarDocumentBuilder.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/AbstractCalendarDocumentBuilder.java
@@ -3,6 +3,7 @@ package org.eclipse.scout.rt.ui.svg.calendar.builder;
import java.awt.Point;
import java.io.InputStream;
import java.security.InvalidParameterException;
+import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.util.Arrays;
import java.util.Calendar;
@@ -26,6 +27,7 @@ import org.eclipse.scout.commons.LocaleThreadLocal;
import org.eclipse.scout.commons.logger.IScoutLogger;
import org.eclipse.scout.commons.logger.ScoutLogManager;
import org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent;
+import org.eclipse.scout.rt.client.ui.basic.calendar.DateTimeFormatFactory;
import org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar;
import org.eclipse.scout.rt.shared.ScoutTexts;
import org.eclipse.scout.rt.ui.svg.calendar.Activator;
@@ -35,6 +37,7 @@ import org.eclipse.scout.rt.ui.svg.calendar.builder.listener.ICalendarDocumentLi
import org.eclipse.scout.rt.ui.svg.calendar.comp.IComponentElementFactory;
import org.eclipse.scout.svg.client.SVGUtility;
import org.w3c.dom.Element;
+import org.w3c.dom.Text;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGStylable;
@@ -98,7 +101,7 @@ public abstract class AbstractCalendarDocumentBuilder {
private final Element m_elLinkMenuContainer;
private final Element[][] m_elGridBox;
private final Element[][] m_elGridText;
- private final Element[][] m_elTimeLineGrid;
+ private Element[][] m_elTimeLineGrid;
private final Element[] m_elTimeLineTexts;
private final Element[] m_elWeekDayHeadings;
private final Element m_elMenuContainer;
@@ -117,6 +120,14 @@ public abstract class AbstractCalendarDocumentBuilder {
private final Map<Integer, Object> m_linkIdToItemIdMap;
private final Map<Object, Integer> m_ItemIdToLinkIdMap;
+ private int m_startHour = 6;
+ private int m_endHour = 19;
+ private boolean m_useOverflowCells = true;
+ private boolean m_showDisplayModeSelectionPanel = true;
+ private boolean m_markNoonHour = true;
+ private boolean m_markOutOfMonthDays = true;
+ private DateFormat m_formatHHMM;
+
protected AbstractCalendarDocumentBuilder(String svgFile) {
// read document
InputStream is = null;
@@ -138,6 +149,7 @@ public abstract class AbstractCalendarDocumentBuilder {
}
m_listenerList = new EventListenerList();
+ m_formatHHMM = new DateTimeFormatFactory().getHourMinute();
// initialize locale dependent labels and options
DateFormatSymbols dateSymbols = new DateFormatSymbols(LocaleThreadLocal.get());
@@ -234,6 +246,25 @@ public abstract class AbstractCalendarDocumentBuilder {
protected abstract IComponentElementFactory getComponentElementFactory();
+ protected abstract void resizeDayBoxes(double gridHeight);
+
+ protected abstract double getGridTop();
+
+ protected void resetTimeLineGrid() {
+ m_elTimeLineGrid = getGridElements("tlg", getNumWeekdays(), getEndHour() - getStartHour() + 2);
+ }
+
+ protected String formatHour(int h) {
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(2000, 01, 01, h, 0, 0);
+ String s = m_formatHHMM.format(cal.getTime());
+ if (s.charAt(1) == ':') {
+ s = "0" + s;
+ }
+ return s;
+ }
+
public void hyperlinkActivated(String hyperlinkUrl) {
Date currentDate = getShownDate();
if (currentDate == null) {
@@ -334,9 +365,10 @@ public abstract class AbstractCalendarDocumentBuilder {
CalendarSvgUtility.setCalendarDisplayModeXPos(e, xPos);
m_displayModeTextWidth[i] = xPos; // remember the original text position to apply scaling later on.
- SVGUtility.addHyperlink(e, LINK_DISPLAY_MODE_PREFIX + linkMenuIds[i]);
-
- xPos += SVGTextContentSupport.getComputedTextLength(e) + MARGIN;
+ if (getShowDisplayModeSelectionPanel() == true) {
+ SVGUtility.addHyperlink(e, LINK_DISPLAY_MODE_PREFIX + linkMenuIds[i]);
+ xPos += SVGTextContentSupport.getComputedTextLength(e) + MARGIN;
+ }
// set the font to bold after the size has been calculated
if (isCurrentDisplayMode) {
@@ -398,6 +430,105 @@ public abstract class AbstractCalendarDocumentBuilder {
}
}
+ public void reconfigureLayout() {
+ if (getDisplayMode() == ICalendar.DISPLAY_MODE_MONTH) {
+ return; // nothing to reconfigure
+ }
+ if (getShowDisplayModeSelectionPanel() == false) {
+ Element el = getSVGDocument().getElementById("LinkMenuLayer");
+ el.setAttribute("display", "none");
+ }
+
+ int nrOfHours = (getEndHour() - getStartHour()) + 1;
+ double gridTop = getGridTop();
+ double gridLeft = 73.998;
+ double gridHeight = 441.075 - gridTop;
+ if (getShowDisplayModeSelectionPanel() == false) {
+ gridHeight = 474.597 - gridTop;
+ }
+ resizeDayBoxes(gridHeight);
+
+ double gridWidth = 550.16 - gridLeft;
+ double cellWidth = gridWidth / getNumWeekdays();
+ double cellHeight = gridHeight / (nrOfHours + 1);
+ SVGDocument svgDoc = getSVGDocument();
+
+ // remove old timeLinetext elements
+ Element el = svgDoc.getElementById("TimeLineText");
+ if (el.hasChildNodes())
+ {
+ while (el.getChildNodes().getLength() >= 1)
+ {
+ el.removeChild(el.getFirstChild());
+ }
+ }
+
+ Element newEl;
+ double y;
+
+ Element[] timeLineTexts = getElementTimeLineTexts();
+
+ timeLineTexts = new Element[nrOfHours];
+ String rowText;
+ for (int i = 0; i < nrOfHours; i++) {
+ y = gridTop + cellHeight + ((gridHeight / (nrOfHours + 1)) * i);
+ newEl = svgDoc.createElementNS(SVGUtility.SVG_NS, "rect");
+ newEl.setAttribute("x", "6.377");
+ newEl.setAttribute("y", String.valueOf(y));
+ newEl.setAttribute("width", "57.371");
+ newEl.setAttribute("height", "20.414");
+ newEl.setAttribute("fill", "none");
+ el.appendChild(newEl);
+
+ y = y + 12.8877;
+ newEl = svgDoc.createElementNS(SVGUtility.SVG_NS, "text");
+ newEl.setAttribute("transform", "matrix(1 0 0 1 6.3774 " + String.valueOf(y) + ")");
+ newEl.setAttribute("style", "fill:#9D9D9C; font-family:Arial; font-size:11");
+
+ rowText = formatHour(getStartHour() + i);
+ if (getUseOverflowCells()) {
+ if (i == 0) {
+ rowText = ScoutTexts.get("Calendar_earlier");
+ }
+ else if ((getStartHour() + i) == getEndHour()) {
+ rowText = ScoutTexts.get("Calendar_later");
+ }
+ }
+ Text textNode = svgDoc.createTextNode(rowText);
+ newEl.appendChild(textNode);
+
+ el.appendChild(newEl);
+ timeLineTexts[i] = newEl;
+ }
+
+ // remove old TimeLineGrid elements
+ Element elTimeLineGrid = getSVGDocument().getElementById("TimeLineGrid");
+ if (elTimeLineGrid.hasChildNodes())
+ {
+ while (elTimeLineGrid.getChildNodes().getLength() >= 1)
+ {
+ elTimeLineGrid.removeChild(elTimeLineGrid.getFirstChild());
+ }
+ }
+
+ String cellStyle = "fill:none;stroke:#C0C0C0;stroke-width:0.5;stroke-miterlimit:10;";
+
+ for (int d = 0; d < getNumWeekdays(); d++) {
+ for (int h = 0; h < nrOfHours + 1; h++) {
+ newEl = svgDoc.createElementNS(SVGUtility.SVG_NS, "rect");
+ newEl.setAttribute("id", "tlg" + String.valueOf(d) + String.valueOf(h));
+ newEl.setAttribute("x", String.valueOf(gridLeft + (cellWidth * d)));
+ newEl.setAttribute("y", String.valueOf(gridTop + (cellHeight * h)));
+ newEl.setAttribute("width", String.valueOf(cellWidth));
+ newEl.setAttribute("height", String.valueOf(cellHeight));
+ newEl.setAttribute("style", cellStyle);
+ elTimeLineGrid.appendChild(newEl);
+ }
+ }
+ resetTimeLineGrid();
+ initGridHyperlink();
+ }
+
public void setSize(int w, int h) {
final float ratio = Math.max(Math.min(w / ORIG_CALENDAR_WIDTH, ORIG_FONT_SIZE / MIN_FONT_SIZE), ORIG_FONT_SIZE / MAX_FONT_SIZE);
final float newFontSize = ORIG_FONT_SIZE / ratio;
@@ -582,12 +713,10 @@ public abstract class AbstractCalendarDocumentBuilder {
// Background color
String bgColor = null;
- if (month != cal.get(Calendar.MONTH)) {
+ bgColor = COLOR_MONTH_BACKGROUND;
+ if (month != cal.get(Calendar.MONTH) && getMarkOutOfMonthDays()) {
bgColor = COLOR_FOREIGN_MONTH_BACKGROUND;
}
- else {
- bgColor = COLOR_MONTH_BACKGROUND;
- }
if (hasTimeLine()) {
for (int i = 0; i < m_elTimeLineGrid.length; i++) {
CalendarSvgUtility.setBackgroundColor(m_elTimeLineGrid[i][wd], bgColor);
@@ -674,6 +803,26 @@ public abstract class AbstractCalendarDocumentBuilder {
}
}
+ public void setWorkHours(int startHour, int endHour, boolean useOverflowCells) {
+ m_startHour = startHour;
+ m_endHour = endHour;
+ m_useOverflowCells = useOverflowCells;
+
+ initTimeLineText();
+ }
+
+ public void setShowDisplayModeSelectionPanel(boolean showDisplayModeSelectionPanel) {
+ m_showDisplayModeSelectionPanel = showDisplayModeSelectionPanel;
+ }
+
+ public void setMarkNoonHour(boolean markNoonHour) {
+ m_markNoonHour = markNoonHour;
+ }
+
+ public void setMarkOutOfMonthDays(boolean markOutOfMonthDays) {
+ m_markOutOfMonthDays = markOutOfMonthDays;
+ }
+
public CalendarComponent[] getComponents() {
if (m_components == null) {
return null;
@@ -836,6 +985,38 @@ public abstract class AbstractCalendarDocumentBuilder {
return m_numContextMenus;
}
+ protected int getEndHour() {
+ return m_endHour;
+ }
+
+ protected int getStartHour() {
+ return m_startHour;
+ }
+
+ protected boolean getUseOverflowCells() {
+ return m_useOverflowCells;
+ }
+
+ protected boolean getShowDisplayModeSelectionPanel() {
+ return m_showDisplayModeSelectionPanel;
+ }
+
+ protected boolean getMarkNoonHour() {
+ return m_markNoonHour;
+ }
+
+ protected boolean getMarkOutOfMonthDays() {
+ return m_markOutOfMonthDays;
+ }
+
+ protected Element[] getElementTimeLineTexts() {
+ return m_elTimeLineTexts;
+ }
+
+ protected Element[][] getElementTimeLineGrid() {
+ return m_elTimeLineGrid;
+ }
+
private Date getShownDate() {
return m_shownDate;
}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarDayBuilder.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarDayBuilder.java
index b87fc2c..8186d93 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarDayBuilder.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarDayBuilder.java
@@ -2,10 +2,12 @@ package org.eclipse.scout.rt.ui.svg.calendar.builder;
import java.util.Calendar;
+import org.apache.batik.util.SVGConstants;
import org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar;
import org.eclipse.scout.rt.shared.ScoutTexts;
import org.eclipse.scout.rt.ui.svg.calendar.comp.IComponentElementFactory;
import org.eclipse.scout.rt.ui.svg.calendar.comp.TimeLineTextComponentElementFactory;
+import org.w3c.dom.Element;
public class CalendarDayBuilder extends AbstractCalendarDocumentBuilder {
public CalendarDayBuilder() {
@@ -19,7 +21,7 @@ public class CalendarDayBuilder extends AbstractCalendarDocumentBuilder {
@Override
protected IComponentElementFactory getComponentElementFactory() {
- return new TimeLineTextComponentElementFactory();
+ return new TimeLineTextComponentElementFactory(getStartHour(), getEndHour());
}
@Override
@@ -62,4 +64,15 @@ public class CalendarDayBuilder extends AbstractCalendarDocumentBuilder {
protected int getBigNextField() {
return Calendar.WEEK_OF_YEAR;
}
+
+ @Override
+ protected double getGridTop() {
+ return 30.672;
+ }
+
+ @Override
+ protected void resizeDayBoxes(double height) {
+ Element el = getSVGDocument().getElementById("b00");
+ el.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "" + height);
+ }
}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarMonthBuilder.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarMonthBuilder.java
index 8595f66..c5ddf5a 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarMonthBuilder.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarMonthBuilder.java
@@ -62,4 +62,13 @@ public class CalendarMonthBuilder extends AbstractCalendarDocumentBuilder {
protected int getBigNextField() {
return Calendar.YEAR;
}
+
+ @Override
+ protected void resizeDayBoxes(double gridHeight) {
+ }
+
+ @Override
+ protected double getGridTop() {
+ return 0;
+ }
}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWeekBuilder.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWeekBuilder.java
index b6fd380..1973230 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWeekBuilder.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWeekBuilder.java
@@ -2,10 +2,12 @@ package org.eclipse.scout.rt.ui.svg.calendar.builder;
import java.util.Calendar;
+import org.apache.batik.util.SVGConstants;
import org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar;
import org.eclipse.scout.rt.shared.ScoutTexts;
import org.eclipse.scout.rt.ui.svg.calendar.comp.IComponentElementFactory;
import org.eclipse.scout.rt.ui.svg.calendar.comp.TimeLineComponentElementFactory;
+import org.w3c.dom.Element;
public class CalendarWeekBuilder extends AbstractCalendarDocumentBuilder {
public CalendarWeekBuilder() {
@@ -19,7 +21,7 @@ public class CalendarWeekBuilder extends AbstractCalendarDocumentBuilder {
@Override
protected IComponentElementFactory getComponentElementFactory() {
- return new TimeLineComponentElementFactory();
+ return new TimeLineComponentElementFactory(getStartHour(), getEndHour());
}
@Override
@@ -61,4 +63,17 @@ public class CalendarWeekBuilder extends AbstractCalendarDocumentBuilder {
protected int getBigNextField() {
return Calendar.MONTH;
}
+
+ @Override
+ protected double getGridTop() {
+ return 64.508;
+ }
+
+ @Override
+ protected void resizeDayBoxes(double height) {
+ for (int i = 0; i < getNumWeekdays(); i++) {
+ Element el = getSVGDocument().getElementById("b" + i + "0");
+ el.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "" + height);
+ }
+ }
}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWorkWeekBuilder.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWorkWeekBuilder.java
index fa2efab..65a356b 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWorkWeekBuilder.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/builder/CalendarWorkWeekBuilder.java
@@ -2,10 +2,12 @@ package org.eclipse.scout.rt.ui.svg.calendar.builder;
import java.util.Calendar;
+import org.apache.batik.util.SVGConstants;
import org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar;
import org.eclipse.scout.rt.shared.ScoutTexts;
import org.eclipse.scout.rt.ui.svg.calendar.comp.IComponentElementFactory;
import org.eclipse.scout.rt.ui.svg.calendar.comp.TimeLineComponentElementFactory;
+import org.w3c.dom.Element;
public class CalendarWorkWeekBuilder extends AbstractCalendarDocumentBuilder {
public CalendarWorkWeekBuilder() {
@@ -19,7 +21,7 @@ public class CalendarWorkWeekBuilder extends AbstractCalendarDocumentBuilder {
@Override
protected IComponentElementFactory getComponentElementFactory() {
- return new TimeLineComponentElementFactory();
+ return new TimeLineComponentElementFactory(getStartHour(), getEndHour());
}
@Override
@@ -61,4 +63,17 @@ public class CalendarWorkWeekBuilder extends AbstractCalendarDocumentBuilder {
protected int getBigNextField() {
return Calendar.MONTH;
}
+
+ @Override
+ protected double getGridTop() {
+ return 64.508;
+ }
+
+ @Override
+ protected void resizeDayBoxes(double height) {
+ for (int i = 0; i < getNumWeekdays(); i++) {
+ Element el = getSVGDocument().getElementById("b" + i + "0");
+ el.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "" + height);
+ }
+ }
}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineComponentElementFactory.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineComponentElementFactory.java
index 827f73a..4f00dba 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineComponentElementFactory.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineComponentElementFactory.java
@@ -22,8 +22,8 @@ import org.w3c.dom.Element;
* parallel components are displayed by splitting the horizontal space as needed.
*/
public class TimeLineComponentElementFactory extends AbstractComponentElementFactory {
- private static final int START_HOUR = 7;
- private static final int END_HOUR = 19;
+ private static int m_startHour = 7;
+ private static int m_endHour = 19;
private static final float PADDING = 1.5f;
// defines the minimal height of an calendar element to ensure it can be clicked even if the linear duration scale would be smaller
@@ -36,6 +36,12 @@ public class TimeLineComponentElementFactory extends AbstractComponentElementFac
private static final Integer EVENT_START = new Integer(2);
private static final Integer EVENT_END = new Integer(1);
+ public TimeLineComponentElementFactory(int startHour, int endHour) {
+ super();
+ m_startHour = startHour;
+ m_endHour = endHour;
+ }
+
/**
* helper class to store meta data to a calendar component.
*/
@@ -139,6 +145,7 @@ public class TimeLineComponentElementFactory extends AbstractComponentElementFac
setElementDimensions(newEl, elementDimension);
composite.appendChild(newEl);
+
Element txt = createTextElement(c.comp, newEl, elementDimension, day);
if (txt != null) {
composite.appendChild(txt);
@@ -201,7 +208,8 @@ public class TimeLineComponentElementFactory extends AbstractComponentElementFac
}
private static float getYOffset(CalendarComponentComposite d, SvgRect container, boolean isEnd) {
- final int NUM_ELEMENTS = END_HOUR - START_HOUR + 3;
+
+ final int NUM_ELEMENTS = m_endHour - m_startHour + 2;
final float ELEMENT_HEIGHT = container.height / NUM_ELEMENTS;
// get time of current element
@@ -224,7 +232,7 @@ public class TimeLineComponentElementFactory extends AbstractComponentElementFac
return 0;
}
}
- else if (hour < START_HOUR) {
+ else if (hour < m_startHour) {
// EARLIER
if (isEnd) {
return ELEMENT_HEIGHT * 2;
@@ -233,7 +241,7 @@ public class TimeLineComponentElementFactory extends AbstractComponentElementFac
return ELEMENT_HEIGHT;
}
}
- else if (hour >= END_HOUR) {
+ else if (hour >= m_endHour) {
// LATER
if (isEnd) {
return container.height;
@@ -244,8 +252,8 @@ public class TimeLineComponentElementFactory extends AbstractComponentElementFac
}
else {
// LINEAR TIME LINE
- final int minutes = ((hour - START_HOUR) * 60) + minute;
- final int totalMinutes = (END_HOUR - START_HOUR) * 60;
+ final int minutes = ((hour - m_startHour) * 60) + minute;
+ final int totalMinutes = (m_endHour - m_startHour) * 60;
final float timeHeight = container.height - (2 * ELEMENT_HEIGHT);
return ELEMENT_HEIGHT + (minutes * timeHeight / totalMinutes);
}
diff --git a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineTextComponentElementFactory.java b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineTextComponentElementFactory.java
index 29d26a0..5ee5734 100644
--- a/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineTextComponentElementFactory.java
+++ b/org.eclipse.scout.rt.ui.svg.calendar/src/org/eclipse/scout/rt/ui/svg/calendar/comp/TimeLineTextComponentElementFactory.java
@@ -13,6 +13,14 @@ import org.w3c.dom.Element;
*/
public class TimeLineTextComponentElementFactory extends TimeLineComponentElementFactory {
+ /**
+ * @param startHour
+ * @param endHour
+ */
+ public TimeLineTextComponentElementFactory(int startHour, int endHour) {
+ super(startHour, endHour);
+ }
+
private final static float TEXT_Y_OFFSET = 4.0f; // small offset so that it looks better
@Override
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/calendar/SwingScoutCalendar.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/calendar/SwingScoutCalendar.java
index 6c2026a..451883c 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/calendar/SwingScoutCalendar.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/calendar/SwingScoutCalendar.java
@@ -77,6 +77,26 @@ public class SwingScoutCalendar extends SwingScoutComposite<ICalendar> {
setSetupFromScout(getScoutObject().getDisplayMode(), getScoutObject().isDisplayCondensed());
setCalendarComponentsFromScout(getScoutObject().getComponents());
setSelectionFromScout(getScoutObject().getSelectedDate(), getScoutObject().getSelectedComponent());
+ setWorkHours(getScoutObject().getStartHour(), getScoutObject().getEndHour(), getScoutObject().getUseOverflowCells());
+ setShowDisplayModeSelectionPanel(getScoutObject().getShowDisplayModeSelection());
+ setMarkNoonHour(getScoutObject().getMarkNoonHour());
+ setMarkOutOfMonthDays(getScoutObject().getMarkOutOfMonthDays());
+ }
+
+ private void setWorkHours(int startHour, int endHour, boolean useOverflowCells) {
+ getDateChooser().setWorkHours(startHour, endHour, useOverflowCells);
+ }
+
+ private void setShowDisplayModeSelectionPanel(boolean visible) {
+ getDateChooser().setShowDisplayModeSelectionPanel(visible);
+ }
+
+ private void setMarkNoonHour(boolean visible) {
+ getDateChooser().setMarkNoonHour(visible);
+ }
+
+ private void setMarkOutOfMonthDays(boolean visible) {
+ getDateChooser().setMarkOutOfMonthDays(visible);
}
public DateChooser getDateChooser() {
@@ -298,7 +318,7 @@ public class SwingScoutCalendar extends SwingScoutComposite<ICalendar> {
if (e.isPopupTrigger()) {
handleSwingCalendarPopup(e);
}
- if(fix!=null) {
+ if (fix != null) {
fix.mouseReleased(this, e);
}
}
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/AbstractCalendarCell.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/AbstractCalendarCell.java
index d07871a..3d770a3 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/AbstractCalendarCell.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/AbstractCalendarCell.java
@@ -87,5 +87,7 @@ public abstract class AbstractCalendarCell extends JLabel {
public abstract void resetItemCache();
+ public abstract void setWorkingHours(int startHour, int endHour, boolean useOverflowCells);
+
public abstract void refresh();
}
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/DateChooser.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/DateChooser.java
index 497896b..5007a54 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/DateChooser.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/DateChooser.java
@@ -60,6 +60,8 @@ public class DateChooser {
public static final int DISPLAY_MODE_MONTH = ICalendar.DISPLAY_MODE_MONTH;
public static final int DISPLAY_MODE_WORKWEEK = ICalendar.DISPLAY_MODE_WORKWEEK;
+ public static final int MIN_CELLPANEL_HEIGHT = 150;
+
private int m_displayMode = DISPLAY_MODE_MONTH;
private int m_timelessHeight = 0;
private boolean m_largeVersion;
@@ -90,6 +92,13 @@ public class DateChooser {
private DateChooser m_childCalendar;
private boolean m_calendarUpdating;
+ private int m_startHour = 6;
+ private int m_endHour = 19;
+ private boolean m_useOverflowCells = true;
+ private DateFormat m_formatHHMM;
+ private boolean m_markOutOfMonthDays;
+ private boolean m_markNoonHour = true;
+
public DateChooser() {
this(false);
}
@@ -115,6 +124,7 @@ public class DateChooser {
m_listenerList = new EventListenerList();
preConstructorInitialization(params);
initializationByConstructor(largeVersion, displayMode, displayCondensed);
+ m_formatHHMM = new DateTimeFormatFactory().getHourMinute();
}
/**
@@ -890,6 +900,7 @@ public class DateChooser {
updateSelections();
fireVisibleRangeChanged();
}
+
}
public Date getViewDate() {
@@ -936,6 +947,7 @@ public class DateChooser {
m_daysPanel.add(createDayLabel(wd[i]));
}
}
+
//
MouseProxyAdapter proxy = new MouseProxyAdapter();
m_cellsPanel.removeAll();
@@ -967,11 +979,23 @@ public class DateChooser {
m_cell[y][x] = createCalendarCell();
m_cell[y][x].setBorder(m_cellBorder);
m_cell[y][x].addMouseListener(proxy);
+ m_cell[y][x].setWorkingHours(m_startHour, m_endHour, m_useOverflowCells);
rowPanel.add(m_cell[y][x]);
}
}
}
+ private String formatHour(int h) {
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(2000, 01, 01, h, 0, 0);
+ String s = m_formatHHMM.format(cal.getTime());
+ if (s.charAt(1) == ':') {
+ s = "0" + s;
+ }
+ return s;
+ }
+
private void updateSelections() {
for (int y = 0; y < m_cell.length; y++) {
for (int x = 0; x < m_cell[y].length; x++) {
@@ -1087,6 +1111,40 @@ public class DateChooser {
}
}
+ public void setWorkHours(int startHour, int endHour, boolean useOverflowCells) {
+ m_startHour = startHour;
+ m_endHour = endHour;
+ m_useOverflowCells = useOverflowCells;
+ for (int i = 0; i < m_cell.length; i++) {
+ for (int k = 0; k < m_cell[i].length; k++) {
+ m_cell[i][k].setWorkingHours(startHour, endHour, useOverflowCells);
+ }
+ }
+ reconfigureLayout();
+ }
+
+ public void setShowDisplayModeSelectionPanel(boolean visible) {
+ if (m_controlPanel != null) {
+ m_controlPanel.setVisible(visible);
+ }
+ }
+
+ public boolean getMarkNoonHour() {
+ return m_markNoonHour;
+ }
+
+ public void setMarkNoonHour(boolean markNoonHour) {
+ m_markNoonHour = markNoonHour;
+ }
+
+ public void setMarkOutOfMonthDays(boolean markOutOfMonthDays) {
+ m_markOutOfMonthDays = markOutOfMonthDays;
+ }
+
+ public boolean getMarkOutOfMonthDays() {
+ return m_markOutOfMonthDays;
+ }
+
public static Date nextDay(Date d) {
if (d == null) {
return null;
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/LargeCalendarCell.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/LargeCalendarCell.java
index 194d087..1db3e11 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/LargeCalendarCell.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/LargeCalendarCell.java
@@ -71,6 +71,7 @@ public class LargeCalendarCell extends AbstractCalendarCell {
private int m_displayType = DateChooser.DISPLAY_MODE_MONTH;
private int m_startHour = 6;// 6-7 is for all items before 7 //MIN=0
private int m_endHour = 19;// 18-19 is for all items after 18 //MAX=23
+ private boolean m_useOverflowCells = false;
private String m_weekLabel;
private String m_dateLabel;
private String m_dayLabel;
@@ -119,6 +120,13 @@ public class LargeCalendarCell extends AbstractCalendarCell {
}
@Override
+ public void setWorkingHours(int startHour, int endHour, boolean useOverflowCells) {
+ m_startHour = startHour;
+ m_endHour = endHour;
+ m_useOverflowCells = useOverflowCells;
+ }
+
+ @Override
public int getTimelessItemCount() {
getItems();// enforce cache filling
return m_countTimeless;
@@ -315,10 +323,8 @@ public class LargeCalendarCell extends AbstractCalendarCell {
@Override
public void paint(Graphics g) {
super.paint(g);
- if (m_isMajor) {
- setBackground(m_yesMajorColor);
- }
- else {
+ setBackground(m_yesMajorColor);
+ if (!m_isMajor && m_dateChooser.getMarkOutOfMonthDays()) {
setBackground(m_notMajorColor);
}
Insets insets = getInsets();
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/SmallCalendarCell.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/SmallCalendarCell.java
index c95e217..9a7285e 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/SmallCalendarCell.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/ext/calendar/SmallCalendarCell.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -49,6 +49,10 @@ public class SmallCalendarCell extends AbstractCalendarCell {
}
@Override
+ public void setWorkingHours(int startHour, int endHour, boolean useOverflowCells) {
+ }
+
+ @Override
protected void onSpacePressed() {
m_dateChooser.setSelectedDate(getRepresentedDate());
}
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/CalendarItemContainer.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/CalendarItemContainer.java
index 5f5a7e0..e2bbd51 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/CalendarItemContainer.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/CalendarItemContainer.java
@@ -42,7 +42,7 @@ public class CalendarItemContainer implements Comparable {
m_bounds = new Rectangle(1, 2, 3, 4);
long repTimeOfDayStart = AbstractCell.getTimeOfDayMillis(m_cell.getDate().getTime());
// TODO why + 1
- long displayInterval = CalendarConstants.HOUR_MILLIS * (CalendarConstants.DAY_TIMELINE_END_TIME /* TODO need this? + 1 */- CalendarConstants.DAY_TIMELINE_START_TIME);
+ long displayInterval = CalendarConstants.HOUR_MILLIS * (cell.getCalendar().getEndHour() /* TODO need this? + 1 */- cell.getCalendar().getStartHour());
CalendarModel model = m_cell.getCalendar().getModel();
//
m_fullDay = model.isFullDay(item);
@@ -60,7 +60,7 @@ public class CalendarItemContainer implements Comparable {
m_toRelative = m_fromRelative;
}
else {
- m_toRelative = AbstractCell.getTimeOfDayMillis(d2) - repTimeOfDayStart - CalendarConstants.HOUR_MILLIS * CalendarConstants.DAY_TIMELINE_START_TIME;
+ m_toRelative = AbstractCell.getTimeOfDayMillis(d2) - repTimeOfDayStart - CalendarConstants.HOUR_MILLIS * cell.getCalendar().getStartHour();
}
if (m_toRelative < 0) {
m_toRelative = 0;
@@ -70,7 +70,7 @@ public class CalendarItemContainer implements Comparable {
}
// check end of day set
if (m_fromRelative >= displayInterval - CalendarConstants.HOUR_MILLIS
- && m_toRelative >= displayInterval - CalendarConstants.DAY_TIMELINE_END_TIME * CalendarConstants.HOUR_MILLIS) {
+ && m_toRelative >= displayInterval - cell.getCalendar().getEndHour() * CalendarConstants.HOUR_MILLIS) {
m_fromRelative = displayInterval - CalendarConstants.HOUR_MILLIS;
m_toRelative = displayInterval;
}
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/SwtScoutCalendar.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/SwtScoutCalendar.java
index 7fb9043..1055fbf 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/SwtScoutCalendar.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/SwtScoutCalendar.java
@@ -85,6 +85,10 @@ public class SwtScoutCalendar extends SwtCalendar {
selectedDate.setTime(calendarModel.getSelectedDate());
}
setViewDate(selectedDate);
+ setWorkingHours(calendarModel.getStartHour(), calendarModel.getEndHour(), calendarModel.getUseOverflowCells());
+ setShowDisplayModeSelection(calendarModel.getShowDisplayModeSelection());
+ setMarkNoonHour(calendarModel.getMarkNoonHour());
+ setMarkOutOfMonthDays(calendarModel.getMarkOutOfMonthDays());
//attach property listener
m_activePropertyListener = new P_ScoutCalendarPropertyListener();
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/layout/WeekItemLayout.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/layout/WeekItemLayout.java
index 348eb02..b2224da 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/layout/WeekItemLayout.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/layout/WeekItemLayout.java
@@ -26,6 +26,9 @@ public class WeekItemLayout extends Layout {
private static final int MIN_WIDTH = 3;
private static final int MIN_HEIGHT = 4;
+ private int m_startHour = CalendarConstants.DAY_TIMELINE_START_TIME;
+ private int m_endHour = CalendarConstants.DAY_TIMELINE_END_TIME;
+ private boolean m_useOverflowCells = true;
@Override
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
@@ -58,7 +61,7 @@ public class WeekItemLayout extends Layout {
int hTimed = clipRect.height - yOffset - hTimeless;
Rectangle r = new Rectangle(0, 0, 0, 0);
- long intervalMillis = (CalendarConstants.DAY_TIMELINE_END_TIME /*+ 1*/- CalendarConstants.DAY_TIMELINE_START_TIME) * CalendarConstants.HOUR_MILLIS;
+ long intervalMillis = (m_endHour /*+ 1*/- m_startHour) * CalendarConstants.HOUR_MILLIS;
int timelessItemHeight = 0;
int countTimeless = dat.getTimelessCount();
@@ -109,4 +112,15 @@ public class WeekItemLayout extends Layout {
}
+ /**
+ * @param startHour
+ * @param endHour
+ * @param useOverflowCells
+ */
+ public void setWorkingHours(int startHour, int endHour, boolean useOverflowCells) {
+ m_startHour = startHour;
+ m_endHour = endHour;
+ m_useOverflowCells = useOverflowCells;
+ }
+
}
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/AbstractCell.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/AbstractCell.java
index f456e89..4e62833 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/AbstractCell.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/AbstractCell.java
@@ -320,29 +320,29 @@ public abstract class AbstractCell extends Composite implements PaintListener {
// System.out.println(toString() + " got event " + e);
switch (e.detail) {
case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_ARROW_NEXT:
- Calendar newDate = Calendar.getInstance();
- newDate.setTime(m_cellDate.getTime());
- newDate.add(Calendar.DATE, 1);
- AbstractCell cell = m_calendar.getCentralPanel().getCellFromDate(newDate.getTime());
- if (cell != null) {
- cell.setSelected();
- }
- e.doit = false;
- break;
- case SWT.TRAVERSE_TAB_PREVIOUS:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- newDate = Calendar.getInstance();
- newDate.setTime(m_cellDate.getTime());
- newDate.add(Calendar.DATE, -1);
- cell = m_calendar.getCentralPanel().getCellFromDate(newDate.getTime());
- if (cell != null) {
- cell.setSelected();
- }
- e.doit = false;
- break;
+ case SWT.TRAVERSE_ARROW_NEXT:
+ Calendar newDate = Calendar.getInstance();
+ newDate.setTime(m_cellDate.getTime());
+ newDate.add(Calendar.DATE, 1);
+ AbstractCell cell = m_calendar.getCentralPanel().getCellFromDate(newDate.getTime());
+ if (cell != null) {
+ cell.setSelected();
+ }
+ e.doit = false;
+ break;
+ case SWT.TRAVERSE_TAB_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ newDate = Calendar.getInstance();
+ newDate.setTime(m_cellDate.getTime());
+ newDate.add(Calendar.DATE, -1);
+ cell = m_calendar.getCentralPanel().getCellFromDate(newDate.getTime());
+ if (cell != null) {
+ cell.setSelected();
+ }
+ e.doit = false;
+ break;
+ }
}
- }
});
// to make this cell focusable
addListener(SWT.KeyDown, new Listener() {
@@ -418,13 +418,10 @@ public abstract class AbstractCell extends Composite implements PaintListener {
setWeekText(weekName);
// gray background for cell not in the curent month
- if (m_isCurrentPeriod) {
- setBackground(SwtColors.getInstance().getWhite());
- }
- else {
+ setBackground(SwtColors.getInstance().getWhite());
+ if (!m_isCurrentPeriod && m_calendar.getMarkOutOfMonthDays()) {
setBackground(SwtColors.getInstance().getLightgray());
}
-
}
/** add items to this cell */
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/CentralPanel.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/CentralPanel.java
index 2d498e9..b56dc28 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/CentralPanel.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/CentralPanel.java
@@ -108,6 +108,10 @@ public class CentralPanel extends Composite {
});
}
+ public SwtCalendar getCalendar() {
+ return m_calendar;
+ }
+
protected void setState() {
// clear existing widgets
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/SwtCalendar.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/SwtCalendar.java
index 35f13e6..ee16b58 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/SwtCalendar.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/SwtCalendar.java
@@ -18,11 +18,12 @@ import java.util.Map;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.scout.commons.logger.IScoutLogger;
import org.eclipse.scout.commons.logger.ScoutLogManager;
+import org.eclipse.scout.rt.ui.swt.basic.calendar.CalendarConstants;
import org.eclipse.scout.rt.ui.swt.basic.calendar.CalendarModel;
import org.eclipse.scout.rt.ui.swt.basic.calendar.CalendarViewEvent;
+import org.eclipse.scout.rt.ui.swt.basic.calendar.DisplayMode;
import org.eclipse.scout.rt.ui.swt.basic.calendar.EmptyCalendarModel;
import org.eclipse.scout.rt.ui.swt.basic.calendar.ICalendarViewListener;
-import org.eclipse.scout.rt.ui.swt.basic.calendar.DisplayMode;
import org.eclipse.scout.rt.ui.swt.basic.calendar.SwtColors;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
@@ -83,6 +84,13 @@ public class SwtCalendar extends Composite implements PaintListener {
/** selection scope widget (month, week, work week, day */
private SelectionScopeBar m_selectionScope;
+ /** workingHour settings **/
+ private int m_startHour = CalendarConstants.DAY_TIMELINE_START_TIME;
+ private int m_endHour = CalendarConstants.DAY_TIMELINE_END_TIME;
+ private boolean m_useOverflowCells = true;
+ private boolean m_markNoonHour = true;
+ private boolean m_markOutOfMonthDays = true;
+
public SwtCalendar(Composite parent, int style) {
super(parent, style);
@@ -270,6 +278,49 @@ public class SwtCalendar extends Composite implements PaintListener {
}
}
+ /**
+ * @param showDisplayModeSelection
+ */
+ public void setShowDisplayModeSelection(boolean showDisplayModeSelection) {
+ m_selectionScope.setVisible(showDisplayModeSelection);
+ ((GridData) m_selectionScope.getLayoutData()).exclude = !showDisplayModeSelection;
+ }
+
+ public void setWorkingHours(int startHour, int endHour, boolean useOverflowCells) {
+ m_startHour = startHour;
+ // to keep swt in sync with swing, swt needs an extra hour to draw timeline
+ m_endHour = endHour + 1;
+ m_useOverflowCells = useOverflowCells;
+ }
+
+ public void setMarkNoonHour(boolean markNoonHour) {
+ m_markNoonHour = markNoonHour;
+ }
+
+ public void setMarkOutOfMonthDays(boolean markOutOfMonthDays) {
+ m_markOutOfMonthDays = markOutOfMonthDays;
+ }
+
+ public int getStartHour() {
+ return m_startHour;
+ }
+
+ public int getEndHour() {
+ return m_endHour;
+ }
+
+ public boolean getUseOverflowCells() {
+ return m_useOverflowCells;
+ }
+
+ public boolean getMarkNoonHour() {
+ return m_markNoonHour;
+ }
+
+ public boolean getMarkOutOfMonthDays() {
+ return m_markOutOfMonthDays;
+ }
+
public void setDisplayMode(int newMode) {
// check argument
if (newMode != DisplayMode.MONTH &&
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/TimelineColumn.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/TimelineColumn.java
index 323dd55..c3e2cc7 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/TimelineColumn.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/TimelineColumn.java
@@ -87,37 +87,35 @@ public class TimelineColumn extends Composite implements PaintListener {
int hTimeless = Math.max(0, timelessHeight - 1);
int yTimed = m_realOffsetY + hTimeless + 1;
- int slots = (CalendarConstants.DAY_TIMELINE_END_TIME - CalendarConstants.DAY_TIMELINE_START_TIME);
+ int slots = (m_centralPanel.getCalendar().getEndHour() - m_centralPanel.getCalendar().getStartHour());
double deltaY = Double.valueOf((bounds.height - yTimed) / (slots * 1.0));
// draw noon rect
int x1 = 1;
- int y1 = (int) Math.round(deltaY * (12 - CalendarConstants.DAY_TIMELINE_START_TIME)) + yTimed;
+ int y1 = (int) Math.round(deltaY * (12 - m_centralPanel.getCalendar().getStartHour())) + yTimed;
int x2 = bounds.width - 3;
int y2 = (int) Math.round(deltaY);
+ // right background color within noon rectangle
Rectangle noon = new Rectangle(x1, y1, x2, y2);
- e.gc.setBackground(SwtColors.getInstance().getLightgray());
+ if (m_centralPanel.getCalendar().getMarkNoonHour()) {
+ e.gc.setBackground(SwtColors.getInstance().getLightgray());
+ }
+ else {
+ e.gc.setBackground(SwtColors.getInstance().getWhite());
+ }
e.gc.fillRectangle(noon);
e.gc.setBackground(SwtColors.getInstance().getWhite());
- int time = CalendarConstants.DAY_TIMELINE_START_TIME;
+ int time = m_centralPanel.getCalendar().getStartHour();
for (int i = 0; i < slots; i++) {
int y = (int) Math.round(deltaY * i) + yTimed;
- // right background color within noon rectangle
- if (time == 12) {
- e.gc.setBackground(SwtColors.getInstance().getLightgray());
- }
- else {
- e.gc.setBackground(SwtColors.getInstance().getWhite());
- }
-
e.gc.drawLine(0, y, bounds.width - 1, y);
- if (time <= CalendarConstants.DAY_TIMELINE_START_TIME) {
+ if (time <= m_centralPanel.getCalendar().getStartHour() && m_centralPanel.getCalendar().getUseOverflowCells()) {
e.gc.drawText(SwtUtility.getNlsText(Display.getCurrent(), "Calendar_earlier"), 3, y + 1, true);
}
- else if (time >= CalendarConstants.DAY_TIMELINE_END_TIME - 1) {
+ else if ((time >= m_centralPanel.getCalendar().getEndHour() - 1) && m_centralPanel.getCalendar().getUseOverflowCells()) {
e.gc.drawText(SwtUtility.getNlsText(Display.getCurrent(), "Calendar_later"), 3, y + 1, true);
}
else {
diff --git a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/WeekCell.java b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/WeekCell.java
index c9c6eec..f70e240 100644
--- a/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/WeekCell.java
+++ b/org.eclipse.scout.rt.ui.swt/src/org/eclipse/scout/rt/ui/swt/basic/calendar/widgets/WeekCell.java
@@ -93,6 +93,7 @@ public class WeekCell extends AbstractCell {
// create new grid layout
WeekItemLayout layout = new WeekItemLayout();
+ layout.setWorkingHours(getCalendar().getStartHour(), getCalendar().getEndHour(), getCalendar().getUseOverflowCells());
this.setLayout(layout);
}
@@ -116,7 +117,7 @@ public class WeekCell extends AbstractCell {
int yTimed = m_realOffsetY + hTimeless + 1;
Rectangle bounds = getBounds();
- int slots = (CalendarConstants.DAY_TIMELINE_END_TIME - CalendarConstants.DAY_TIMELINE_START_TIME);
+ int slots = (getCalendar().getEndHour() - getCalendar().getStartHour());
double deltaY = Double.valueOf((bounds.height - yTimed) / (slots * 1.0));
// set foreground color
@@ -124,15 +125,20 @@ public class WeekCell extends AbstractCell {
// draw noon rect
int x1 = 1;
- int y1 = (int) Math.round(deltaY * (12 - CalendarConstants.DAY_TIMELINE_START_TIME)) + yTimed;
+ int y1 = (int) Math.round(deltaY * (12 - getCalendar().getStartHour())) + yTimed;
int x2 = bounds.width - 3;
int y2 = (int) Math.round(deltaY);
Rectangle noon = new Rectangle(x1, y1, x2, y2);
- e.gc.setBackground(SwtColors.getInstance().getLightgray());
+ if (getCalendar().getMarkNoonHour() || (!isCurrentPeriod() && getCalendar().getMarkOutOfMonthDays())) {
+ e.gc.setBackground(SwtColors.getInstance().getLightgray());
+ }
+ else {
+ e.gc.setBackground(SwtColors.getInstance().getWhite());
+ }
e.gc.fillRectangle(noon);
e.gc.setBackground(SwtColors.getInstance().getWhite());
- int time = CalendarConstants.DAY_TIMELINE_START_TIME; // we have 1 slot before start time
+ int time = getCalendar().getStartHour(); // we have 1 slot before start time
for (int i = 0; i < slots; i++) { // we go one slot after end time
int y = (int) Math.round(deltaY * i) + yTimed;
e.gc.drawLine(0, y, bounds.width - 1, y);
diff --git a/org.eclipse.scout.svg.ui.rap/src/org/eclipse/scout/svg/ui/rap/calendarfield/RwtScoutCalendarField.java b/org.eclipse.scout.svg.ui.rap/src/org/eclipse/scout/svg/ui/rap/calendarfield/RwtScoutCalendarField.java
index 86adcc8..3ee93aa 100644
--- a/org.eclipse.scout.svg.ui.rap/src/org/eclipse/scout/svg/ui/rap/calendarfield/RwtScoutCalendarField.java
+++ b/org.eclipse.scout.svg.ui.rap/src/org/eclipse/scout/svg/ui/rap/calendarfield/RwtScoutCalendarField.java
@@ -139,6 +139,12 @@ public class RwtScoutCalendarField extends AbstractRwtScoutSvgComposite<ICalenda
private void initDocBuilder(AbstractCalendarDocumentBuilder builder) {
Date selDate = getScoutObject().getCalendar().getSelectedDate();
CalendarComponent selComp = getScoutObject().getCalendar().getSelectedComponent();
+
+ builder.setWorkHours(getScoutObject().getCalendar().getStartHour(), getScoutObject().getCalendar().getEndHour(), getScoutObject().getCalendar().getUseOverflowCells());
+ builder.setShowDisplayModeSelectionPanel(getScoutObject().getCalendar().getShowDisplayModeSelection());
+ builder.setMarkNoonHour(getScoutObject().getCalendar().getMarkNoonHour());
+ builder.setMarkOutOfMonthDays(getScoutObject().getCalendar().getMarkOutOfMonthDays());
+ builder.reconfigureLayout();
builder.setShownDate(selDate);
builder.setSelection(selDate, selComp);
builder.setNumContextMenus(getContextMenusFromScout().length);