Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Scout/Concepts/CalendarField"
m |
(→Properties) |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
== Description == | == Description == | ||
The CalendarField is made to represent an {{ScoutJavadoc|AbstractCalendar|C}} with appointments. | The CalendarField is made to represent an {{ScoutJavadoc|AbstractCalendar|C}} with appointments. | ||
+ | The field gets his contents from the CalendarItemProviders defined in the fields source code. | ||
+ | Calendar item providers may also access a (remote) CalendarService. | ||
+ | === Calendar Item Provider === | ||
+ | |||
+ | A calendar displays calendar items provided by the CalendarItemProviders associated with a calendar field. Calendar item providers are written as inner classes of the calendar field as shown below. | ||
+ | In the example snipped below the fields calendar defines two item providers, a local provider and a remote provider. | ||
+ | |||
+ | <source lang="java"> | ||
+ | public class CalendarField extends AbstractCalendarField<CalendarField.Calendar> { | ||
+ | |||
+ | @Order(10.0) | ||
+ | public class Calendar extends AbstractExtensibleCalendar { | ||
+ | |||
+ | @Order(10.0) | ||
+ | public class LocalItemProvider extends AbstractExtensibleCalendarItemProvider { | ||
+ | @Override | ||
+ | protected void execLoadItems(Date minDate, Date maxDate, Holder<ICalendarItem[]> resultHolder) throws ProcessingException { | ||
+ | // logic to collect items to display in the range [minDate, maxDate] into the result holder | ||
+ | } | ||
+ | } | ||
+ | |||
+ | @Order(10.0) | ||
+ | public class RemoteItemProvider extends AbstractExtensibleCalendarItemProvider { | ||
+ | |||
+ | protected void execLoadItems(Date minDate, Date maxDate, Holder<ICalendarItem[]> resultHolder) throws ProcessingException { | ||
+ | // access (possibly remote) calendar service to load additional calendar items | ||
+ | resultHolder.setValue(SERVICES.getService(IRemoteCalendarService.class).getItems(minDate, maxDate)); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | // additional calendar item providers if necessary | ||
+ | ... | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | Adding item providers to a calendar field is also supported by the Scout SDK. A corresponding wizard is provided on the folder ''Calendar Item Providers'' as shown below: | ||
+ | |||
+ | [[image:Sdk_calendar_item_provider.png]] | ||
+ | |||
+ | See the [https://github.com/BSI-Business-Systems-Integration-AG/org.eclipsescout.demo/blob/master/widgets/org.eclipsescout.demo.widgets.client/src/org/eclipsescout/demo/widgets/client/ui/forms/CalendarFieldForm.java implementation] of the calendar field of the [[Scout/Demo#Widgets|Scout widget demo]] for an example of a local item provider. | ||
+ | |||
+ | === Calendar Services === | ||
+ | |||
+ | Calendar services are typically used to implement remote access to a third party calendar application such as Microsoft Outlook, Lotus notes or [http://code.google.com/p/google-api-java-client/wiki/APIs#Calendar_API Google+]. | ||
+ | Calendar services are realized as standard Scout services that implement the ''ICalendarService'' marker interface. | ||
+ | |||
+ | Usually a calendar service implements the following two methods | ||
+ | * ''getItems'' | ||
+ | * ''storeItems'' | ||
+ | |||
+ | The following snipped provides a small example for such a calendar service that provides a static set of calendar items. | ||
+ | |||
+ | <source lang="java"> | ||
+ | public class RemoteCalendarService extends AbstractService implements IRemoteCalendarService { | ||
+ | ArrayList<ICalendarItem> m_items = new ArrayList<ICalendarItem>(); | ||
+ | |||
+ | public RemoteCalendarService () { | ||
+ | java.util.Calendar cal = java.util.Calendar.getInstance(); | ||
+ | cal.add(java.util.Calendar.DAY_OF_YEAR, 1); | ||
+ | cal.set(java.util.Calendar.HOUR_OF_DAY, 13); | ||
+ | Date start = cal.getTime(); | ||
+ | cal.add(java.util.Calendar.MINUTE, 30); | ||
+ | Date end = cal.getTime(); | ||
+ | m_items.add(new CalendarAppointment(1L, 2L, start, end, false, "Important Meeting", "Product Strategy", "FFCC00")); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public ICalendarItem[] getItems(Date minDate, Date maxDate) throws ProcessingException { | ||
+ | return m_items.toArray(new ICalendarItem[m_items.size()]); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void storeItems(ICalendarItem[] items, boolean delta) throws ProcessingException { | ||
+ | // some business logic here. | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | As calendar services are usually implemented as a part of the Scout server application, the Scout SDK supports adding calendar services with a ''New Calendar Service...'' wizard on the node '''Calendar Services'''. | ||
+ | In the Scout Explorer calendar services are listed under the same node. | ||
+ | |||
+ | [[image:Sdk_calendar_service.png]] | ||
+ | |||
+ | === Calendar Features === | ||
+ | |||
+ | A calendar | ||
The CalendarField has 4 different views: | The CalendarField has 4 different views: | ||
* Month: Displays a whole month | * Month: Displays a whole month | ||
Line 18: | Line 106: | ||
{|{{BMTableStyle}} | {|{{BMTableStyle}} | ||
|-{{BMTHStyle}} | |-{{BMTHStyle}} | ||
+ | ! Type | ||
! RAP | ! RAP | ||
! SWT | ! SWT | ||
Line 23: | Line 112: | ||
! Swing Rayo | ! Swing Rayo | ||
|- | |- | ||
− | | [[Image:Scout_3. | + | | Month || [[Image:Scout_3.8_CalendarField_Month_RAP.png]] || [[Image:Scout_3.8_CalendarField_Month_SWT.png]] || [[Image:Scout_3.8_CalendarField_Month_Swing.png]] || [[Image:Scout_3.8_CalendarField_Month_Swing_Rayo.png]] |
+ | |- | ||
+ | | Week || [[Image:Scout_3.8_CalendarField_Week_RAP.png]] || [[Image:Scout_3.8_CalendarField_Week_SWT.png]] || [[Image:Scout_3.8_CalendarField_Week_Swing.png]] || [[Image:Scout_3.8_CalendarField_Week_Swing_Rayo.png]] | ||
+ | |- | ||
+ | | Working week || [[Image:Scout_3.8_CalendarField_WorkingWeek_RAP.png]] || [[Image:Scout_3.8_CalendarField_WorkingWeek_SWT.png]] || [[Image:Scout_3.8_CalendarField_WorkingWeek_Swing.png]] || [[Image:Scout_3.8_CalendarField_WorkingWeek_Swing_Rayo.png]] | ||
+ | |- | ||
+ | | Day || [[Image:Scout_3.8_CalendarField_Day_RAP.png]] || [[Image:Scout_3.8_CalendarField_Day_SWT.png]] || [[Image:Scout_3.8_CalendarField_Day_Swing.png]] || [[Image:Scout_3.8_CalendarField_Day_Swing_Rayo.png]] | ||
|- | |- | ||
|} | |} | ||
Line 29: | Line 124: | ||
== Properties == | == Properties == | ||
''Defined with {{ScoutLink|Concepts|GetConfigured Methods|getConfiguredXxxxxx()}} methods''. | ''Defined with {{ScoutLink|Concepts|GetConfigured Methods|getConfiguredXxxxxx()}} methods''. | ||
+ | |||
See also the {{ScoutLink|Concepts|Field|Field}} and {{ScoutLink|Concepts|ValueField|Value field}} pages for the properties that all fields have in common. | See also the {{ScoutLink|Concepts|Field|Field}} and {{ScoutLink|Concepts|ValueField|Value field}} pages for the properties that all fields have in common. | ||
+ | |||
+ | === getConfiguredGridH === | ||
+ | |||
+ | To display a calendar field in a meaningful way, its height need to be explicitly set to a couple of rows. | ||
+ | To start, use 10 for getConfiguredGridH. | ||
== Events == | == Events == |
Revision as of 09:42, 2 September 2013
The Scout documentation has been moved to https://eclipsescout.github.io/.
Specific type of The Scout documentation has been moved to https://eclipsescout.github.io/. to represent String.
- implements: The Scout documentation has been moved to https://eclipsescout.github.io/.
- extends: The Scout documentation has been moved to https://eclipsescout.github.io/.
Contents
Description
The CalendarField is made to represent an The Scout documentation has been moved to https://eclipsescout.github.io/. with appointments. The field gets his contents from the CalendarItemProviders defined in the fields source code. Calendar item providers may also access a (remote) CalendarService.
Calendar Item Provider
A calendar displays calendar items provided by the CalendarItemProviders associated with a calendar field. Calendar item providers are written as inner classes of the calendar field as shown below. In the example snipped below the fields calendar defines two item providers, a local provider and a remote provider.
public class CalendarField extends AbstractCalendarField<CalendarField.Calendar> { @Order(10.0) public class Calendar extends AbstractExtensibleCalendar { @Order(10.0) public class LocalItemProvider extends AbstractExtensibleCalendarItemProvider { @Override protected void execLoadItems(Date minDate, Date maxDate, Holder<ICalendarItem[]> resultHolder) throws ProcessingException { // logic to collect items to display in the range [minDate, maxDate] into the result holder } } @Order(10.0) public class RemoteItemProvider extends AbstractExtensibleCalendarItemProvider { protected void execLoadItems(Date minDate, Date maxDate, Holder<ICalendarItem[]> resultHolder) throws ProcessingException { // access (possibly remote) calendar service to load additional calendar items resultHolder.setValue(SERVICES.getService(IRemoteCalendarService.class).getItems(minDate, maxDate)); } } // additional calendar item providers if necessary ... } }
Adding item providers to a calendar field is also supported by the Scout SDK. A corresponding wizard is provided on the folder Calendar Item Providers as shown below:
See the implementation of the calendar field of the Scout widget demo for an example of a local item provider.
Calendar Services
Calendar services are typically used to implement remote access to a third party calendar application such as Microsoft Outlook, Lotus notes or Google+. Calendar services are realized as standard Scout services that implement the ICalendarService marker interface.
Usually a calendar service implements the following two methods
- getItems
- storeItems
The following snipped provides a small example for such a calendar service that provides a static set of calendar items.
public class RemoteCalendarService extends AbstractService implements IRemoteCalendarService { ArrayList<ICalendarItem> m_items = new ArrayList<ICalendarItem>(); public RemoteCalendarService () { java.util.Calendar cal = java.util.Calendar.getInstance(); cal.add(java.util.Calendar.DAY_OF_YEAR, 1); cal.set(java.util.Calendar.HOUR_OF_DAY, 13); Date start = cal.getTime(); cal.add(java.util.Calendar.MINUTE, 30); Date end = cal.getTime(); m_items.add(new CalendarAppointment(1L, 2L, start, end, false, "Important Meeting", "Product Strategy", "FFCC00")); } @Override public ICalendarItem[] getItems(Date minDate, Date maxDate) throws ProcessingException { return m_items.toArray(new ICalendarItem[m_items.size()]); } @Override public void storeItems(ICalendarItem[] items, boolean delta) throws ProcessingException { // some business logic here. } }
As calendar services are usually implemented as a part of the Scout server application, the Scout SDK supports adding calendar services with a New Calendar Service... wizard on the node Calendar Services. In the Scout Explorer calendar services are listed under the same node.
Calendar Features
A calendar The CalendarField has 4 different views:
- Month: Displays a whole month
- Week: Displays a week
- Working week: Displays a week from Monday to Friday
- Day: Displays only a day
Screenshot
Type | RAP | SWT | Swing | Swing Rayo |
---|---|---|---|---|
Month | ||||
Week | ||||
Working week | ||||
Day |
Properties
Defined with The Scout documentation has been moved to https://eclipsescout.github.io/. methods.
See also the The Scout documentation has been moved to https://eclipsescout.github.io/. and The Scout documentation has been moved to https://eclipsescout.github.io/. pages for the properties that all fields have in common.
getConfiguredGridH
To display a calendar field in a meaningful way, its height need to be explicitly set to a couple of rows. To start, use 10 for getConfiguredGridH.
Events
Defined with The Scout documentation has been moved to https://eclipsescout.github.io/. methods.
See also the The Scout documentation has been moved to https://eclipsescout.github.io/. and The Scout documentation has been moved to https://eclipsescout.github.io/. pages for the events that all fields have in common.
See Also
- The Scout documentation has been moved to https://eclipsescout.github.io/.
- The Scout documentation has been moved to https://eclipsescout.github.io/.
- The Scout documentation has been moved to https://eclipsescout.github.io/.