Views that support grouping: Timetable / Week Range / List / Resource. The Resource view can only operate when grouping is enabled. The other views do not support grouping.
In order to enable grouping the following steps should be done:
The following code illustrates how to enable grouping by contacts:
Java Copy Code |
---|
// Define two contacts to group by |
The text displayed in the header of the corresponding resource depends on the type of the resource and is as follows:
The Resource view allows grouping by two resource types simultaneously. The primary resource type is still specified through the setGroupType method. The secondary resource type is specified through the setSecondaryGroupType method. When multiple grouping is enabled the view is divided by the primary resources first. Then each primary resource is additionally subdivided by all secondary resources. For example, if there are two primary resources and three secondary resources specified, the view will display two main headers, divided by three subheaders each, for a total of six rows.
Usually the setGroupType and setSecondaryGroupType methods are set to different values. For example, setGroupType can be set to GroupByContacts and setSecondaryGroupType can be set to GroupByResources, to group by contacts and resources respectively. However, it is possible to group resources by their runtime type. In this case both the primary and the secondary resources need to be placed in the Calendar.Resources collection and both setGroupType and setSecondaryGroupType need to be set to GroupByResources. In addition, setCustomGroupType and setCustomSecondaryGroupType must be set to the appropriate runtime types of the resources. The following example illustrates how to enable grouping by custom resources of type Machine and Worker:
Java Copy Code |
---|
calendar.setGroupType(GroupType.GroupByResources); |
It might not always be desired that a primary resource is associated with all secondary resources. In the above case for example, only a subset of the workers could be associated with a machine. This can achieved in JPlanner through the customizeGrouping method of the CalendarListener interface. Let us assume that the Machine class provides a list of workers that are qualified to work with that machine. In this case, the following customizeGrouping override enables grouping only by the qualified workers:
Java Copy Code |
---|
public void customizeGrouping(CustomizeGroupingEvent e) |