Skip Headers
Oracle® Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework
11g Release 2 (11.1.2.1.0)

Part Number E16181-02
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

26 Using Gantt Chart Components

This chapter describes how to display data in Gantt charts using the ADF Data Visualization projectGantt, resourceUtilizationGantt, and schedulingGantt components. If your application uses the Fusion technology stack, then you can use data controls to create Gantt charts. For more information, see the "Creating Databound Gantt Charts" section in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

This chapter includes the following sections:

26.1 About Gantt Chart Components

A Gantt chart is a type of horizontal bar graph that you use to plan and track projects. It shows resources or tasks in a time frame with a distinct beginning and end. A Gantt chart component is composed of two regions, one displaying the Gantt chart data in a table, and the other displaying the Gantt chart data graphically with a resizable splitter between the two regions. The table and chart regions share the same data and selection model, supporting and synchronizing scrolling, and expanding and collapsing of rows between the two regions.

At runtime, Gantt charts provide interaction capabilities in the table region to the user such as entering data, expanding and collapsing rows, showing and hiding columns, navigating to a row, and sorting and totaling columns. In the chart region, users can drag a task to a new date, select multiple tasks to create dependencies, and extend the task date. A Gantt chart toolbar is available to support user operations such as changing or filtering the view of the data, and creating, deleting, cutting, copying, and pasting tasks.

Both Gantt chart regions are based on an ADF Faces tree table component. For more information about ADF tree tables, including virtualization of rows, see Chapter 12, "Using Tables and Trees."

ADF Gantt chart components include a project Gantt chart, a resource utilization Gantt chart, and a scheduling Gantt chart.

26.1.1 End User and Presentation Features

To understand how Gantt charts are used and can be customized, it is helpful to understand these elements and features:

26.1.1.1 Scrolling, Zooming, and Panning

The Gantt chart design lets you perform horizontal scrolling of the table and the chart regions independently. This is especially helpful when you want to hold specific task or resource information constant in the table region while scrolling through multiple time periods of information in the chart region.

Users can also zoom in and out on the time scale of a Gantt chart by holding the Ctrl key and using the mouse scroll wheel. A tooltip displays to allow the user to keep track of the current level when zooming through multiple levels at a time. This is especially useful for users with a scroll wheel without a click function.

In project and scheduling Gantt charts, users can pan the chart area by dragging it vertically and horizontally using the cursor. A move cursor displays when the user clicks inside the chart area, other than on a task.

26.1.1.2 Selection

This feature provides access to the rowKeys of the selected tasks in the scheduling Gantt chart and the selected time buckets in the resource utilization Gantt chart components. Furthermore, this feature will allow access to the rowKeys of the currently selected task in the scheduling Gantt and the currently selected time bucket in the resource utilization Gantt. By default, the project Gantt chart provides access to the scheduled tasks.

26.1.1.3 How to Navigate to a Specific Date in a Gantt Chart- Navigation and Display

You can move the chart region of the Gantt chart rapidly to a specific date.

To navigate to a specific date in a Gantt chart:

  1. From the View menu, choose Go to Date.

  2. In the Go to Date dialog, specify the desired date by clicking the Select Date icon and indicating the date in the calendar.

  3. Click OK.

The display of the chart region of the Gantt chart begins at the date you requested.

26.1.1.4 How to Control the Visibility of Columns in the Table Region

By default, all the columns that you define when you create a databound Gantt chart are visible in the table region. You can selectively cause one or more of these columns to be hidden.

To control the display of columns in the table region of a Gantt chart:

  1. From the View menu, select List Pane.

  2. From the context menu, select Columns.

  3. In the Columns menu, deselect any column that you want to be hidden in the table region of the Gantt chart. You can also select any column that you want to make visible in the table region.

    Note:

    You must keep at least one column visible in the table region.

26.1.1.5 Navigating in a Gantt Chart

You can browse through Gantt chart regions by scrolling, or you can access a specific date in the chart region. You can also control if columns in the table region are visible.

26.1.1.6 How to Display Data in a Hierarchical List or a Flat List

If a Gantt chart is using a hierarchical data model, then you have the option of displaying all the Gantt chart data in a collapsed form or in an expanded form.

To control the display of Gantt chart data in a list:

  1. From the View menu, select List Pane.

  2. From the ensuing menu, select either Show As List, for an expanded list, or Show As Hierarchy, for a collapsed list.

26.1.1.7 How to Change the Gantt Chart Time Scale

You can change the time scale display in a Gantt chart and you can zoom in and out on a time axis to display the chart region in different time units. You can also use a specialized zoom-to-fit feature in which you select the amount of time that you want to display in the chart region without a need to scroll the chart.

To change the settings of a time axis:

  1. From the View menu, select Time Scale.

  2. In the ensuing Time Scale dialog, in the Time Unit column, select a new unit value for either the major axis, the minor axis, or both axes. A sample box displays sample settings for the time unit that you select. Figure 26-1 shows the Time Scale dialog.

    Figure 26-1 Time Scale Dialog

    time scale dialog
  3. Click OK.

To zoom in or out on a time axis:

  1. Optionally, on the toolbar, click the Zoom In icon to display the time axis at a lower level time unit.

  2. Optionally, on the toolbar, click the Zoom Out icon to display the time axis at a higher level time unit.

  3. Optionally, in the box on the toolbar after the zoom icons, select a time period that represents the amount of time on the chart that you want to display without the need to scroll.

  4. Optionally, right-click the time axis for which you wish to change the scale and select an available time unit from the submenu.

26.1.1.8 Server-Side Events

When a user interaction involves a change in data, the Gantt chart processes the change by performing validation, event handling, and update of the data model. Validation ensures that the data submitted meets basic requirements, for example, that a date is valid and does not fall into a nonworking time period. When validation fails, the update of the data model is omitted, and an error message is returned.

When a Gantt chart server-side event is fired, an event with validated information about the change is sent to the registered listener. The listener is then responsible for updating the underlying data model. A customized event handler can be registered by specifying a method binding expression on the dataChangeListener attribute of the Gantt chart component.

Server-side events supported by the Gantt chart include:

  • Update of data in the table cells of the Gantt chart table region

  • Create, update, delete, move, cut, copy, paste, indent, outdent of tasks

  • Reassignment of resource by dragging the task bar from one row to another

  • Drag the task bar to another date

  • Extend the duration of a task

  • Link or unlink tasks

  • Select a row or multiple rows in the Gantt chart table region

  • Undo or redo of user actions

  • Double-click on a task bar

Users can filter the data in a Gantt chart using a dropdown list from the toolbar. You can create a custom filter.

26.1.2 Gantt Chart Component Use Cases and Examples

The Gantt chart provides the following components:

  • Project Gantt chart: A project Gantt chart is used for project management. The chart lists tasks vertically and shows the duration of each task as a bar on a horizontal time line. It graphs each task on a separate line as shown in Figure 26-2.

    Figure 26-2 Project Gantt Chart for a Software Application

    Project Gantt chart for software application
  • Resource Utilization Gantt chart: A resource utilization Gantt chart graphically shows the metrics for a resource, for example, whether resources are over or under allocated. It shows resources vertically while showing their metrics, such as allocation and capacity on the horizontal time axis. Figure 26-3 shows a resource utilization Gantt chart illustrating how many hours are allocated and utilized for a particular developer resource in a given time period.

    Figure 26-3 Resource Utilization Gantt Chart for a Software Application

    resource utilization Gantt chart for application
  • Scheduling Gantt chart: A scheduling Gantt chart is used for resource scheduling. The chart is based on manual scheduling boards and shows resources vertically, with corresponding activities on the horizontal time axis. Examples of resources include people, machines, or rooms. The scheduling Gantt chart uses a single line to graph all the tasks that are assigned to a resource as shown in Figure 26-4.

    Figure 26-4 Scheduling Gantt Chart for a Software Application

    Scheduling Gantt chart for software application

A Gantt chart consists of the following functional areas:

  • Table region: Displays Gantt chart data attributes in a table with columns. The table region requires a minimum of one column, but you can define attributes for as many columns as desired in the Gantt chart data binding dialogs.

    For example, in Figure 26-2, the table region contains the following columns: Name (of the task), Priority, Orig. Est., Curr. Est., Elapsed (days), Remaining (days), and Resources.

  • Chart region: Displays a bar graph of the Gantt chart data along a horizontal time axis. The time axis provides for major and minor settings to allow for zooming. The major setting is for larger time increments and the minor setting is for smaller time increments.

    For example, in Figure 26-2, the chart region graphs tasks on a time axis that shows days within weeks.

  • Information panel: Displays both the information region that displays text about the selected task or metrics about the selected resource, and the optional legend that displays task types in the area beneath the table region and the chart region. Note that the Gantt chart legend is not present unless you insert the legend child tag inside the parent Gantt chart tag.

  • Toolbar: Lets users perform operations on the Gantt chart. The toolbar is visible in the Gantt chart by default. You can change the visibility of the toolbar by setting the ShowToolbar attribute on the Appearance page of the Property Inspector for the Gantt chart.

    The toolbar consists of the following sections:

    • Menu bar: The left section of the toolbar contains a set of menus for the Gantt chart. Each Gantt chart type has a set of default options. Figure 26-5 displays the menu bar, which is visible in the Gantt chart by default. You can change the visibility of the menu bar by setting the ShowMenuBar attribute in the Appearance page of the Property Inspector for the Gantt chart. You can customize menu items by using the menubar facet.

      Note:

      The View menu items do not require that you write application code to make them functional. However, you must provide application code for any items that you want to use on the other menus.

      Figure 26-5 Sample Menu Bar for a Gantt Chart

      Gantt chart menu bar
    • Toolbar buttons: The right section of the toolbar displays a set of action buttons for working with the Gantt chart. Each Gantt chart type has a set of default options. Figure 26-6 shows a sample toolbar for a project Gantt chart.

      Figure 26-6 Sample Toolbar for a Project Gantt Chart

      Project Gantt chart toolbar

    You can customize toolbar buttons by using the toolbar facet.

  • Context menu: Right-clicking in the Gantt chart table or chart regions provides a popup context menu with a standard set of menu items. You can provide your own set of menu items by using the tablePopupMenu or chartPopupMenu facet.

  • Printing service: The Gantt chart provides printing capability in conjunction with XML Publisher by generating PDF files. For more information, see Section 26.6, "Printing a Gantt Chart".

26.1.3 Additional Functionality for Gantt Chart Components

You may find it helpful to understand other ADF Faces features before you implement your Gantt chart component. Additionally, once you have added a Gantt chart component to your page, you may find that you need to add functionality such as validation and accessibility. Following are links to other functionality that Gantt chart components can use:

  • Partial page rendering: You may want a Gantt chart to refresh to show new data based on an action taken on another component on the page. For more information, see Chapter 8, "Rerendering Partial Page Content."

  • Personalization: Users can change the way the Gantt chart displays at runtime, those values will not be retained once the user leaves the page unless you configure your application to allow user customization. For information, see Chapter 32, "Allowing User Customization on JSF Pages."

  • Accessibility: You can make your Gantt chart components accessible. For more information, see Chapter 30, "Developing Accessible ADF Faces Pages."

  • Export to Excel: You can export the table region of the project Gantt chart using af:exportCollectionActionListener. For more information, see Section 12.10, "Exporting Data from Table, Tree, or Tree Table."

  • Content Delivery: You configure your Gantt chart table region to fetch a certain number of rows at a time from your data source using the contentDelivery attribute. For more information, see Section 12.2.2, "Content Delivery."

  • Automatic data binding: If your application uses the Fusion technology stack, then you can create automatically bound Gantt charts based on how your ADF Business components are configured. For more information, see the "Creating Databound Gantt Charts" section of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

    Note:

    If you know the UI components on your page will eventually use ADF data binding, but you need to develop the pages before the data controls are ready, then you should consider using placeholder data controls, rather than manually binding the components. Using placeholder data controls will provide the same declarative development experience as using developed data controls. For more information, see the "Designing a Page Using Placeholder Data Controls" chapter of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

    Additionally, data visualization components share much of the same functionality, such as how data is delivered, automatic partial page rendering (PPR), image formats, and how data can be displayed and edited. For more information, see Section 21.2, "Common Functionality in Data Visualization Components."

26.2 Using Gantt Chart Components

The data model for a Gantt chart can be either a tree (hierarchical) model or a collection model that contains a row set or flat list of objects. For more information, see the "Creating Databound ADF Gantt Charts" section in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

When you bind a Gantt chart to a data control, you specify how the collection in the data control maps to the node definitions of the Gantt chart.

26.2.1 Data for a Project Gantt Chart

The data model for a project Gantt chart supports hierarchical data and uses TreeModel to access the data in the underlying list. The specific model class is org.apache.myfaces.trinidad.model.TreeModel.

The collection of objects returned by the TreeModel must have, at a minimum, the following properties:

  • taskId: The ID of the task.

  • startTime: The start time of the task.

  • endTime: The end time of the task.

Optionally, the object could implement the oracle.adf.view.faces.bi.model.Task interface to ensure it provides the correct properties to the Gantt chart.

When binding the data to an ADF data control, the following node definitions are available in a project Gantt chart:

  • Task node: Represents a collection of tasks. The task node definition has the following types of optional accessors:

    • subTask (available only for project Gantt chart)

    • splitTask

  • Split task node: Represents a collection of split tasks. A split task node definition does not have accessors.

  • Dependency node: Represents a collection of dependencies for a task. A dependency node definition does not have accessors.

  • Recurring task node: Represents a collection of recurring tasks. A recurring task node definition does not have accessors.

Table 26-1 shows a complete list of data object keys for the project Gantt chart.

Table 26-1 Data Object Keys for Project Gantt

Data Object Key Date Type and Description

actualEnd

Date. The actual end time for normal and milestone tasks.

actualStart

Date. The actual start time for normal and milestone tasks.

completedThrough

Date. Completed through for normal and summary tasks.

critical

Boolean. Specifies whether or not the task is critical for all tasks.

Dependency (node)

A list of dependencies for a task. Data object keys for dependencies include:

  • fromId: The ID of the task where the dependency begins.

  • toId: The ID of the task where the dependency ends.

  • type: The type of the dependency. Valid values are start-start, start-finish, finish-finish, finish-start, start-before, start-together, finish-after, and finish-together.

endTime (required)

Date. The end time for all tasks.

icon1

String. The first icon associated with the task bar for all tasks. The icon might change depending on other attributes

icon2

String. The second icon associated with the tasks bar for all tasks.

icon3

String. The third icon associated with the tasks bar for all tasks.

iconPlacement

String. The alignment of the icon in the task bar for all tasks. Valid values are left (default), right, inside, start, end, innerLeft, innerRight, innerCenter, innerStart, innerEnd.

isContainer

Boolean. Specifies whether or not a node definition is a container.

label

String. The label associated with the task bar for all tasks.

labelPlacement

String. The alignment of the label in the task bar for all tasks. Valid values are left (default), right, inside, start, end, innerLeft, innerRight, innerCenter, innerStart, innerEnd.

percentComplete

Integer. Percentage completed for normal and summary tasks.

Recurring tasks (node)

The list of recurring tasks for all tasks.

Split tasks (node)

The list of tasks without a continuous time line for all tasks.

startTime (required)

Date. The starting time for all tasks.

Subtasks (node)

An optional list of subtasks for all tasks.

taskId (required)

String. The unique identifier for all tasks.

type

Sting. The type of the tasks for all tasks.


26.2.2 Data for a Resource Utilization Gantt Chart

The data model for a resource utilization Gantt chart supports hierarchical data and uses TreeModel to access the data in the underlying list. The specific model class is org.apache.myfaces.trinidad.model.TreeModel.

The collection of objects returned by TreeModel must have, at a minimum, the following properties:

  • resourceId: The ID of the task.

  • timeBuckets: A collection of time bucket objects for this resource.

Optionally, the object could implement the oracle.adf.view.faces.bi.model.Resource interface to ensure it provides the correct properties to the Gantt chart.

The collection of objects returned by the timeBuckets property must also have the following properties:

  • time: The date represented by the time bucket.

  • values: A list of metrics for this resource.

When binding the data to an ADF data control, the following node definitions are available in a Resource Utilization Gantt chart:

  • Resource node: Represents a collection of resources. The resource node definition has an optional subResources accessor that returns a collection of subresources for the current resource.

  • Time bucket node: Represents a collection of time slots with metrics defined.

Table 26-2 shows a complete list of data object keys for the resource utilization Gantt chart.

Table 26-2 Data Object Keys for Resource Utilization Gantt

Data Object Key Data Type and Description

label

String. The label associated with the task bar.

labelAlign

String. The alignment of the label in the task bar. Valid values are top (default) and inside.

resourceId (required)

String. The unique identifier of a resource.

timeBuckets (required)

List. The list of tasks associated with a resource.

time (required)

Date. The start time of the time bucket.

values (required)

Double. The values of the metrics.


26.2.3 Data for a Scheduling Gantt Chart

The data model for a scheduling Gantt chart supports hierarchical data and uses TreeModel to access the data in the underlying list. The specific model class is org.apache.myfaces.trinidad.model.TreeModel.

The collection of objects returned by TreeModel must have, at a minimum, the following properties:

  • resourceId: The ID of the task.

  • tasks: A collection of task objects for this resource.

Optionally, the object could implement the oracle.adf.view.faces.bi.model.ResourceTask interface to ensure it provides the correct properties to the Gantt chart.

The collection of objects returned by the tasks property must also have the following properties:

  • taskId: The ID of the task.

  • startTime: The start time of the task.

  • endTime: The end time of the task.

When binding the data to an ADF data control, the scheduling Gantt chart has a Resource node definition. The Resource node has the following types of accessors:

  • subResources: Returns a collection of subresources for the current resource. This accessor is optional.

  • tasks: Returns a collection of tasks for the current resource. This accessor is required. Tasks can also include a splitTask accessor.

Table 26-3 shows a complete list of data object keys for a scheduling Gantt chart.

Table 26-3 Data Object Keys for Scheduling Gantt Chart

Data Object Key Data Type and Description

Dependency (node)

A list of dependencies for a task. Data object keys for dependencies include:

  • fromId: The ID of the task where the dependency begins.

  • toId: The ID of the task where the dependency ends.

  • type: The type of the dependency. Valid values are start-start, start-finish, finish-finish, finish-start, start-before, start-together, finish-after, and finish-together.

endTime (required)

Date. The end time for all the tasks.

icon1

String. The first icon associated with the task bar for all tasks. The icon might change depending on other attributes.

icon2

String. The second icon associated with the task bar for all tasks.

icon3

String. The third icon associated with the task bar for all tasks.

iconPlacement

String. The alignment of the icon in the task bar for all tasks. Valid values are left (default), right, inside, inside_left, inside_right, and inside_center. In bi-directional locales, start and end values are also supported.

isContainer

Boolean. Specifies whether or not a node definition is a container.

label

String. The label associated with the task bar for all tasks.

labelPlacement

String. The alignment of the label in the task bar for all tasks. Valid values are left (default), right, inside, inside_left, inside_right, and inside_center. In bi-directional locales, start and end values are also supported.

Recurring tasks (node)

A list of recurring tasks for all tasks.

resourceId (required)

String. The unique identifier of a resource.

Split tasks (node)

A collection of tasks without a continuous time line for all tasks.

startTime (required)

Date. The start time for all tasks.

startupTime

Date. The startup time before a task begins.

Tasks (node) (required)

A list of tasks associated with a resource.

taskId (required)

String. The unique identifier of the task for all tasks.

taskType

String. The type of the task for all tasks.

workingDaysOfTheWeek

Object. A list of the working days of the week.

workingEndTime

Date. The work end time for the resource.

workingStartTime

Date. The work start time for the resource.


26.2.4 Gantt Chart Tasks

Project and scheduling Gantt charts use predefined tasks with a set of formatting properties that describe how the tasks will be rendered in the chart area. All supported tasks must have a unique identifier. The following describes the supported tasks and how they appear in a Gantt chart:

  • Normal: The basic task type. It is a plain horizontal bar that shows the start time, end time, and duration of the task.

  • Summary: The start and end date for a group of subtasks. A summary task cannot be moved or extended. Instead, it is the responsibility of the application to execute code to recalculate the start and end date for a summary task when the date of a subtask changes. Summary tasks are available only for the project Gantt chart.

  • Milestone: A specific date in the Gantt chart. There is only one date associated with a milestone task. A milestone task cannot be extended but it can be moved. A milestone task is available only for the project Gantt chart.

  • Recurring: A task that is repeated in a Gantt chart, each instance with its own start and end date. Individual recurring tasks can optionally contain a subtype. All other properties of the individual recurring tasks come from the task which they are part of. However, if an individual recurring task has a subtype, this subtype overrides the task type.

  • Split: A task that is split into two horizontal bars, usually linked by a line. The time between the bars represents idle time due to traveling or down time.

  • Scheduled: The basic task type for a scheduling Gantt chart. This task type shows the starting time, ending time, and duration of a task, as well as startup time if one is specified.

For normal, summary, and milestone tasks, additional attributes are supported that would change the appearance and activity of a task. These style attributes include:

  • percentComplete, completedThrough: An extra bar would be drawn to indicate how far the task is completed. This is applicable to normal and summary task types.

  • critical: The color of the bar would be changed to red to mark it as critical. This is applicable to normal, summary, and milestone task types.

  • actualStart and actualEnd: When these attributes are specified, instead of drawing one bar, two bars are drawn. One bar indicates the base start and end date, the other bar indicates the actual start and end date. This is applicable to normal and milestone task types.

Figure 26-7 displays a legend that shows common task types in a project Gantt chart.

Figure 26-7 Project Gantt Chart Legend for Task Types

Gannt chart legend for task types

26.2.5 Configuring Gantt Charts

The three Gantt chart components beginning with the prefix dvt: for each Gantt chart tag name indicates that the tag belongs to the ADF Data Visualization Tools (DVT) tag library:

  • dvt:projectGantt

  • dvt:resourceUtilizationGantt

  • dvt:schedulingGantt

All Gantt chart components support the child tag dvt:ganttLegend to provide an optional legend in the information panel of a Gantt chart. Some menu bar and toolbar functions may or may not be available depending on whether the Gantt legend is specified.

In the Gantt chart table region, the ADF Faces af:column tag is used to specify the header text, icons and alignment for the data, the width of the column, and the data bound to the column. To display data in hierarchical form, a nodeStamp facet specifies the primary identifier of an element in the hierarchy. For example, the "Task Name" column might be used as the nodeStamp facet for a project Gantt chart. Example 26-1 shows sample code for a project Gantt chart with "Task Name" as the nodeStamp facet, with columns for Resource, Start Date, and End Date.

Example 26-1 Sample Code for Project Gantt Chart Columns

<dvt:projectGantt id="projectChart1" startTime="2008-04-12" 
           endTime="2009-04-12" 
           value="#{project.model}" 
           var="task">
  <f:facet name="major">
    <dvt:timeAxis scale="months"/>
  </f:facet>
  <f:facet name="minor">
    <dvt:timeAxis scale="weeks"/>
  </f:facet>
  <f:facet name="nodeStamp">
    <af:column headerText="Task Name">
      <af:outputText value="#{task.taskName}"/>
    </af:column>
  </f:facet>
    <af:column headerText="Resource">
      <af:outputText value="#{task.resourceName}"/>
    </af:column>
    <af:column headerText="Start Date">
      <af:outputText value="#{task.startTime}"/>
    </af:column>
    <af:column headerText="End Date">
      <af:outputText value="#{task.endTime}"/>
    </af:column>
</dvt:projectGantt>

In addition to the nodeStamp facet, other facets are used for customizations by the Gantt chart components. Table 26-4 shows the facets supported by Gantt chart components.

Table 26-4 Facets Supported by Gantt Chart Components



chartPopupMenu

Specifies the component to use to identify additional controls to appear in the context menu of the chart region. Must be an af:popup component.

customPanel

Specifies the component to use to identify controls to appear in the custom tab of the task properties dialog.

major

Specifies the component to use to identify the major time axis. Must be a dvt:timeAxis component.

menuBar

Specifies the component to use to identify additional controls to appear in the Gantt menu bar. Must be an af:menu component

minor

Specifies the component to use to identify the minor time axis. Must be a dvt:timeAxis component.

nodeStamp

Specifies the component to use to stamp each element in the Gantt chart. Only certain types of components are supported, including all components with no activity and most components that implement the EditableValueHolder or ActionSource interfaces. Must be an af:column component.

tablePopupMenu

Specifies the component to use to identify additional controls to appear in the context menu of the table region. Must be an af:popup component.

toolbar

Specifies the component to use to identify additional controls to appear in the Gantt toolbar. Must be an af:toobar component.


26.2.6 How to Add a Gantt Chart to a Page

When you are designing your page using simple UI-first development, you use the Component Palette to drag and drop a project, resource utilization, or scheduling Gantt chart component onto a JSF page.

Once the Gantt chart is added to your page, you can use the Property Inspector to specify data values and configure additional display attributes for the Gantt chart.

In the Property Inspector you can use the dropdown menu for each attribute field to display a property description and options such as displaying an EL Expression Builder or other specialized dialogs. Figure 26-8 shows the dropdown menu for a project Gantt chart component value attribute.

Figure 26-8 Project Gantt Chart Value Attribute Dropdown Menu

Project Gantt Chart Value Attribute Dropdown Menu

Note:

If your application uses the Fusion technology stack, then you can use data controls to create a Gantt chart and the binding will be done for you. For more information, see the "Creating Databound Gantt Charts" section in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework

Before you begin:

It may be helpful to have an understanding of how Gantt chart attributes and Gantt chart child components can affect functionality. For more information, see Section 26.2.5, "Configuring Gantt Charts."

You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 26.1.3, "Additional Functionality for Gantt Chart Components."

To add a Gantt chart to a page:

  1. In the Component Palette, from the ADF Data Visualizations page, in the Gantt chart panel, drag and drop a Project, Resource Utilization, or Scheduling Gantt chart onto the page to open the Create Gantt chart dialog.

    Optionally, use the dialog to bind the Gantt chart by selecting Bind Data Now and entering or navigating to the ADF data control or ADF managed bean that represents the data you wish to display on the Gantt chart. If you choose this option, the data binding fields in the dialog will be available for editing. Otherwise, click OK to add the component to the page.

  2. In the Property Inspector, view the attributes for the Gantt chart. Use the help button to display the complete tag documentation for the projectGantt, resourceUtilizationGantt, or schedulingGantt, component.

  3. Expand the Common section. Use this section to set the following attributes:

    • StartTime: Enter the start time used to render the time period of the Gantt chart.

    • EndTime: Enter the end time used to render the time period of the Gantt chart.

  4. Expand the Gantt Data section. Use this section to set the following attributes:

    • Value: Specify the data model, which must be of type org.apache.myfaces.trinidad.model.TreeModel, using an EL Expression.

    • Var: Specify the variable used to reference each element of the Gantt chart data collection. Once this component has completed rendering, this variable is removed, or reverted back to its previous value.

  5. Expand the Appearance section. Use this section to set the following attributes:

    • ShowMenuBar: Specify whether or not the menu bar should be shown in the Gantt chart. If this attribute is set to false, then any custom menu bar items specified in the menuBar facet will also be hidden.

    • ShowToolbar: Specify whether or not the toolbar should be shown in the Gantt chart. If this attribute is set to false, then any custom toolbar buttons specified in the toolbar facet will also be hidden.

    • Summary: Enter a description of the Gantt chart. This description is accessed by screen reader users

  6. Expand the Behavior section. Use this section to set the following attributes:

    • InitiallyExpandAll: Specifies whether or not all the rows should be initially expanded.

    • FetchSize: Use to specify the number of rows in a data fetch block. The default value for rows is 25. For more information about content delivery to Gantt charts, see Section 21.2.1, "Content Delivery."

    • FeaturesOff: Enter a space delimited list of end user features to disable at runtime. The valid values will depend upon the type of Gantt chart.

26.2.7 What Happens When You Add a Gantt Chart to a Page

When you use the Component Palette to create a Gantt chart, JDeveloper inserts code in the JSF page. Example 26-2 shows the code inserted in the JSF page for a project Gantt chart.

Example 26-2 Code Sample for Project Gantt Chart

<dvt:projectGantt startTime="2011-03-20" endTime="2011-06-19" var="row" id="pg1">
  <f:facet name="major">
    <dvt:timeAxis scale="weeks" id="ta5"/>
  </f:facet>
  <f:facet name="minor">
    <dvt:timeAxis scale="days" id="ta6"/>
  </f:facet>
  <f:facet name="nodeStamp">
    <af:column sortable="false" headerText="col1" id="c11">
      <af:outputText value="#{row.col1}" id="ot11"/>
    </af:column>
  </f:facet>
    <af:column sortable="false" headerText="col2" id="c12">
      <af:outputText value="#{row.col2}" id="ot12"/>
    </af:column>
    <af:column sortable="false" headerText="col3" id="c13">
      <af:outputText value="#{row.col3}" id="ot13"/>
    </af:column>
    <af:column sortable="false" headerText="col4" id="c14">
      <af:outputText value="#{row.col4}" id="ot14"/>
    </af:column>
    <af:column sortable="false" headerText="col5" id="c15">
      <af:outputText value="#{row.col5}" id="ot15"/>
    </af:column>
</dvt:projectGantt>

26.3 Customizing Gantt Chart Legends, Toolbars, and Context Menus

You can modify default Gantt chart features including the information panel and legend that are displayed below the Gantt chart, menu bar options and toolbar buttons, and the popup menu that is displayed when you right-click in the Gantt chart table or chart regions.

26.3.1 How to Customize a Gantt Chart Legend

The optional Gantt chart legend subcomponent includes an area that displays detailed information about the selected task, or metrics about the selected time bucket, and a legend that displays the symbol and color code bar used to represent each type of task in a Gantt chart. At runtime, users can hide or show the information panel using a toolbar button.

The dvt:ganttLegend tag must be added as a child of the Gantt chart tag in order to provide the legend areas. The content of the legend areas is automatically generated based on the properties for each type of task registered with the taskbarFormatManager.

You can customize the information displayed when a task or time bucket is selected by using the keys and label attributes on the Gantt chart legend tag. The keys attribute should specify the data object keys used to retrieve the value to display and the labels attribute should contain the corresponding labels for the values retrieved with the keys. If these attributes are not specified, the legend will use the entire space of the information panel.

You can also add icons to the legend by using the iconKeys and iconLabels attributes on the Gantt chart legend tag. Icons will be automatically resized to 12 by 12 pixels if the icon size is too large.

Example 26-3 show sample code to display information about an On Hold task in the legend of a project Gantt chart.

Example 26-3 Adding a Gantt Chart Legend

<dvt:projectGantt var="task">
   <dvt:ganttLegend id="gl" keys="TaskName StartTime EndTime" labels="Name Start Finish" icons="images/wait.png" iconLabels="OnHold"/>
</dvt:projectGantt>

26.3.2 Customizing Gantt Chart Toolbars

The Gantt chart toolbar subcomponent allows users to perform operations on the Gantt chart. The left section of the toolbar is a menu bar that contains a set of default menu options for each Gantt chart type. The right section of the toolbar displays a set of default action buttons for working with each Gantt chart type.

You can supply your own menu items and toolbar buttons by using the menu and toolbar facets in your Gantt chart. The Gantt chart merges the new menu items with the standard items in the Gantt chart. Example 26-4 shows sample code for specifying a new menu item.

Example 26-4 Sample Code for Custom Menu Item

<dvt:projectGantt var="task">
<f:facet name=”menuBar”>
  <af:menu text=”My Menu”>
    <af:commandMenuItem text="Add..." />
    <af:commandMenuItem text="Create.." />
  </af:menu>
</f:facet>
</dvt:projectGantt>

Example 26-5 shows sample code for specifying a new toolbar button.

Example 26-5 Sample Code for Custom Toolbar Button

<dvt:schedulingGantt var="task">
<f:facet name="toolbar">
  <af:toolbar>
    <af:commandToolbarButton text="Custom" disabled="true"/>
  </af:toolbar>
</dvt:schedulingGantt>

Actions initiated on the menu bar and toolbar buttons are handled through a registered listener, DataChangeListener, on the Gantt chart component. For example, when a user presses the delete button in the toolbar, a DataChangeEvent with the ID of the task selected for deletion would be fired on the server. The registered listener is then responsible for performing the actual deletion of the task, and the Gantt chart data model is refreshed with the updated information.

You can register DataChangeListener by specifying a method binding using the dataChangeListener attribute on the Gantt chart tag. For example, if you put the code in a backing bean in a method called handleDataChange, then the setting for the dataChangeListener attribute becomes: "#{myBackingBean.handleDataChange}".

Example 26-6 shows sample code in a backing bean.

Example 26-6 Backing Bean for Handling Data Change

public void handleDataChanged(DataChangeEvent evt)
{
if (DataChangeEvent.DELETE == evt.getActionType())
            …………
}

26.3.3 Customizing Gantt Chart Context Menus

When users right-click in the Gantt chart table or chart regions, a context menu is displayed to allow users to perform operations on the Gantt chart. A standard set of options is provided for each region.

You can supply your own menu items using the tablePopupMenu and chartPopupMenu facets in your Gantt chart. The Gantt chart merges the new menu items with the standard items in the Gantt chart. Example 26-7 shows sample code for specifying a custom menu item in the table region context menu.

Example 26-7 Sample Code for Custom Context Menu Item

<dvt:projectGantt startTime="#{test.startTime}" endTime="#{test.endTime}"
            value="#{test.treeModel}" var="task">

  <f:facet name="tablePopupMenu">
    <af:popup>
      <af:commandMenuItem text="Custom" disabled="true"/>
    </af:popup>
  </f:facet>
</dvt:projectGantt>

You can also dynamically change the context menu at runtime. Example 26-8 shows sample code to update a custom popup menu on a task bar based on which task is selected in the chart region of a project Gantt chart.

Example 26-8 Sample Code for Dynamic Context Menu

<dvt:projectGantt var="task"
                  taskSelectionListener="#{backing.handleTaskSelected}">
  <f:facet name="chartPopupMenu">
    <af:popup id="p1" contentDelivery="lazyUncached">
      <af:menu>
      </af:menu>
    </af:popup>
  </f:facet>
</dvt:projectGantt>

The handleTaskSelected method is specified in a backing bean. Example 26-9 shows sample code for the backing bean.

Example 26-9 Backing Bean for Handling Task Selection

public void handleTaskSelected(TaskSelectionEvent evt)
{
       JUCtrlHierNodeBinding _task = (JUCtrlHierNodeBinding)evt.getTask();
       String _type = _task.getAttribute("TaskType");
 
       RichPopup _popup = m_gantt.getFacet("chartPopupMenu");
       if (_popup != null)
       {
           RichMenu _menu = (RichMenu)_popup.getChildren().get(0);
           _menu.getChildren().clear();
           if ("Summary".equals(_type))
           {
               RichCommandMenuItem _item = new RichCommandMenuItem();
               _item.setId("i1");
               _item.setText("Custom Action 1");
               _menu.getChildren().add(_item);                          }
           else if ("Normal".equals(_type))
           {
               RichCommandMenuItem _item = new RichCommandMenuItem();
               _item.setId("i1");
               _item.setText("Custom Action 2");
               _menu.getChildren().add(_item);                          }
       }
}

For more information about using the af:popup components see Chapter 15, "Using Popup Dialogs, Menus, and Windows".

26.4 Working with Gantt Chart Tasks and Resources

You can customize Gantt chart tasks to create a new task type, specify a custom data filter, and add a double-click event to a task bar.

26.4.1 How to Create a New Task Type

A task type is represented visually as a bar in the chart region of a Gantt chart. You can create a new task type in one of three ways:

  • Defining the task type style properties in the .jspx file or in a separate CSS file.

  • Defining a TaskbarFormat object and registering the object with the taskbarFormatManager.

  • Modifying the properties of a predefined task type by retrieving the associated TaskbarFormat object and updating its properties through a set method.

The TaskBarFormat object exposes the following properties:

  • Fill color

  • Fill image pattern

  • Border color

  • Images used for a milestone task

  • Images used for the beginning and end of a summary task

For tasks that have more than one bar, such as a split or recurring task, properties are defined for each individual bar.

Example 26-10 shows sample code to define the properties for a custom task type in the .jspx file.

Example 26-10 Sample Code to Define Custom Task Type Properties

<af:document>
  <f:facet name="metaContainer">
    <f:verbatim>
      <![CDATA[
      <style type="text/css">
         .onhold 
{
         background-image:url('images/Bar_Image.png');
         background-repeat:repeat-x;
         height:13px;
         border:solid 1px #000000;
}
      </style>
        ]]>
    </f:verbatim>
  </f:facet>

shows sample code to define a TaskbarFormat object fill and border color and register the object with the taskbarFormatManager.

Example 26-11 Custom TaskbarFormat Object Registered with TaskbarFormat Manager

TaskbarFormat _custom = new TaskbarFormat("Task on hold", null, "onhold", null);
//        _gantt.getTaskbarFormatManager().registerTaskbarFormat("FormatId", _custom);
TaskbarFormat _custom = new TaskbarFormat("Task on hold", "#FF00FF", null, "#00FFDD", 13);
//    _gantt.getTaskbarFormatManager().registerTaskbarFormat("FormatId", _custom);

26.4.2 How to Specify Custom Data Filters

You can change the display of data in a Gantt chart using a data filter dropdown list on the toolbar. Gantt charts manage all predefined and user-specified data filters using a FilterManager. Filter objects contain information including:

  • A unique ID for the filter

  • The label to display for the filter in the dropdown list

  • An optional JavaScript method to invoke when the filter is selected

You can define your own filter by creating a filter object and then registering the object using the addFilter method on the FilterManager. Example 26-12 shows sample code for registering a Resource filter object with the FilterManager.

Example 26-12 Custom Filter Object Registered with FilterManager

FilterManager _manager = m_gantt.getFilterManager();
 
// ID for filter display label   javascript callback (optional)
_manager.addFilter((new Filter(RESOURCE_FILTER, "Resource...", "showResourceDialog")));

When the user selects a filter, a FilterEvent is sent to the registered FilterListener responsible for performing the filter logic. The filterListener attribute on the Gantt chart component is used to register the listener. When implemented by the application, the data model is updated and the Gantt chart component displays the filtered result. Example 26-13 shows sample code for a FilterListener.

Example 26-13 FilterListener for Custom Filter

public void handleFilter(FilterEvent event)
    {
        String _type = event.getType();
        if (FilterEvent.ALL_TASKS.equals(_type))
        {
            // update the gantt model as appropriate
        }
    }

To specify a custom data filter:

  1. In the Structure window, right-click the Gantt chart node and choose Go to Properties.

  2. In the Behavior category of the Property Inspector, in the FilterListener field, enter a method reference to the FilterListener you defined. For example, "#{project.handleFilter}".

26.4.3 How to Add a Double-Click Event to a Task Bar

Gantt chart components support a double-click event on a task bar. For example, you may want to display detailed information about a task in a popup window. Figure 26-9 shows a project Gantt chart with a double-click event on a task bar.

Figure 26-9 Task Bar with Double-Click Event

Gantt chart with double-click on task

Example 26-14 show sample code for adding a double-click event to a task bar.

Example 26-14 Sample Code for Double-Click Event

<dvt:projectGantt id="projectGanttDoubleClick"
    startTime="2008-04-01" endTime="2008-09-30"
    value="#{projectGanttDoubleClick.model}"
    var="task"
    doubleClickListener="#{projectGanttDoubleClick.handleDoubleClick}">
</dvt:projectGantt>

Implement the handleDoubleClick method in a backing bean, for example:

public void handleDoubleClick(DoubleClick event)

26.5 Specifying Nonworking Days, Read-Only Features, and Time Axes

You can customize a Gantt chart to display nonworking days of the week, turn off user interaction features, and specify the time axes.

26.5.1 Identifying Nonworking Days in a Gantt Chart

You can specify nonworking days in a Gantt chart. By default, nonworking days are shaded gray, but you can select a custom color to be used for nonworking days.

26.5.1.1 How to Specify Weekdays as Nonworking Days

If certain weekdays are always nonworking days, then you can indicate the days of the week that fall in this category.

To identify weekdays as nonworking days:

  1. In the Structure window, right-click a Gantt chart node and choose Go to Properties.

  2. In the Appearance category of the Property Inspector, in the NonWorkingDaysOfWeek field, enter the string of days that you want to identify as nonworking days for each week. For example, to specify that Saturday and Sunday are nonworking days, enter the following string: "sat sun".

    Alternatively, you can create a method in a backing bean to programmatically identify the nonworking days. For example, if you put the code in a backing bean in a method called getNonWorkingDaysOfWeek, then the setting for the nonWorkingDaysOfWeek attribute becomes: "#{myBackingBean.nonWorkingDays}". Example 26-15 shows sample code in a backing bean.

    Example 26-15 Backing Bean to Identify Nonworking Days

    public int[] getNonWorkingDaysOfWeek(){  if (locale == Locale.EN_US
        return new int[] {Calendar.SATURDAY, Calendar.SUNDAY};  else    .......}
    
  3. Optionally, specify a custom color in the NonWorkingDaysColor field. The value you enter for this attribute must be a hexadecimal color string.

26.5.1.2 How to Identify Specific Dates as Nonworking Days

You can enter specific dates as nonworking days in a Gantt chart when individual weekdays are not sufficient.

To identify specific dates as nonworking days:

  1. In the Structure Window, right-click a Gantt chart and choose Go to Properties.

  2. In the Property Inspector, select the Appearance attributes category.

  3. In the nonWorkingDays field, enter the string of dates that you want to identify as nonworking days. For example: "2008-07-04 2008-11-28 2008-12-25".

    Alternatively, for more flexibility, you can create a method in a backing bean to programmatically identify the nonworking days. For example, if you put the code in a backing bean in a method called getNonWorkingDays, then the setting for the nonWorkingDays attribute becomes: "#{myBackingBean.nonWorkingDays}".

  4. Optionally, specify a custom color in the nonWorkingDaysColor field. The value you enter for this attribute must be a hexadecimal color string.

26.5.2 How to Apply Read-Only Values to Gantt Chart Features

User interactions with a Gantt chart can be customized to disable features by setting the featuresOff property to specify read-only values. Table 26-5 shows the valid values and the disabled feature for the Gantt chart types.

Table 26-5 Valid Vales for Read-Only Attributes

Value Feature Disabled

clipboard

Cut, copy, and paste tasks for all Gantt charts.

dependcyLines

Hide and show dependency lines for the project and scheduling Gantt charts.

edit

Changes to the data model for all Gantt charts.

filter

Hide the data filter operation on the toolbar.

indenting

Indent and outdent tasks for project and scheduling Gantts charts.

legend

Hide and show legend and task information for all Gantt charts.

linking

Link and unlink tasks for scheduling Gantt charts.

print

Print task for all Gantt charts.

properties

Show property dialogs for all Gantt charts.

split

Split task for project Gantt.

undo

Undo and redo tasks for all Gantt charts.

view

Show as list, Show as hierarchy, Columns, Expand and Collapse tasks for all Gantt charts.

zoom

Changes to the zoom level for all Gantt charts.


To set read-only values on Gantt chart features:

  1. In the Structure window, right-click the Gantt chart node and choose Go to Properties.

  2. In the Behavior attributes category of the Property Inspector, for the featuresOff attribute, enter one or more String values to specify the Gantt chart features to disable.

    For example, to disable user interactions for editing the data model, printing, or changing the zoom level of a Gantt chart, use the following setting for the featuresOff attribute: edit print zoom

    Alternatively, you can create a method in a backing bean to programmatically identify the features to be disabled. For example, if you put the code in a backing bean in a method called whatToTurnOff that returns a String array of the values, then the setting for the featuresOff attribute becomes: "#{BackingBean.whatToTurnOff}".

26.5.3 Customizing the Time Axis of a Gantt Chart

Every Gantt chart is created with a major time axis and a minor time axis. Each time axis has a facet that identifies the level of the axis as major or minor. The default time axis settings for all Gantt charts are:

  • Major time axis: Weeks

  • Minor time axis: Days

You can customize the settings of a time axis. However, the setting of a major axis must be a higher time level than the setting of a minor axis. The following values for setting the scale on a dvt:timeAxis component are listed from highest to lowest:

  • twoyears

  • year

  • halfyears

  • quarters

  • twomonths

  • months

  • twoweeks

  • weeks

  • days

  • sixhours

  • threehours

  • hours

  • halfhours

  • quarterhours

Example 26-19 shows sample code to set the time axis of a Gantt chart to use months as a major time axis and weeks as the minor time axis.

Example 26-16 Gantt Chart Time Axis Set to Months and Weeks

<f:facet name="major">
  <dvt:timeAxis scale="months"/>
</f:facet>
<f:facet name="minor">
  <dvt:timeAxis scale="weeks"/>
</f:facet>

The time units you specify for the major and minor axes apply only to the initial display of the Gantt chart. At runtime, the user can zoom in or out on a time axis to display the time unit level at a different level.

26.5.3.1 How to Create and Use a Custom Time Axis

You can create a custom time axis for the Gantt chart and specify that axis in the scale attribute of dvt:timeAxis. The custom time axis will be added to the Time Scale dialog at runtime.

To create and use a custom time axis:

  1. Implement the CustomTimescale.java interface to call the method getNextDate(Date currentDate) in a loop to build the time axis. Example 26-17 show sample code for the interface.

    Example 26-17 Interface to Build Custom Dates

    public interface CustomTimescale
    {
        public String getScaleName();
        public Date getPreviousDate(Date ganttStartDate);
        public Date getNextDate(Date currentDate);
        public String getLabel(Date date);
    }
    
  2. In the Structure window, right-click a Gantt chart node and choose Go to Properties.

  3. In the Other attributes category of the Property Inspector, for the CustomTimeScales attribute, register the implementation of the interface for the custom time axis.

    The customTimeScales attribute's value is a java.util.Map object. The specified map object contains pairs of key/values. The key is the time scale name (fiveyears), and the value is the implementation of the CustomTimeScale.java interface. For example:

    customTimesScales="#{project.customTimescales}"
    
  4. Also in the Property Inspector, set the Scale attribute for major and minor time axis, and specify the ZoomOrder attribute to zoom to the custom times scales. Example 26-18 shows sample code for setting a threeyears minor time axis and a fiveyears major time axis.

    Example 26-18 Custom Time Axis

    <f:facet name="major">
      <dvt:timeAxis scale="fiveyears" id="ta1" zoomOrder="fiveyears threeyears years halfyears quarters months weeks days hours"/>
    </f:facet>
    <f:facet name="minor">
      <dvt:timeAxis scale="threeyears" id="ta2"/>
    </f:facet>
    

26.6 Printing a Gantt Chart

The ADF Gantt chart provides a helper class (GanttPrinter) that can generate a Formatted Object (FO) for use with XML Publisher to produce PDF files.

26.6.1 Print Options

In general, the GanttPrinter class prints the Gantt chart content as it appears on your screen. For example, if you hide the legend in the Gantt chart, then the legend will not be printed. Similarly, if you deselect a column in the List Pane section of the View Menu, then that column will not be visible in the Gantt chart and will not appear in the printed copy unless you take advantage of the column visibility print option.

You can use the following print options in the GanttPrinter class:

  • Column visibility: The setColumnVisible method lets you control whether individual columns in the list region of the Gantt chart will appear in the printed output.

    For example, to hide the first column in the list region of a Gantt chart, use the following code, where the first parameter of the method is the zero-based index of the column and the second parameter indicates if the column should be visible in the printed Gantt chart: _printer.setColumnVisible(o, false);

  • Margins: The setMargin method of the GanttPrinter lets you specify the top, bottom, left, and right margins in pixels as shown in the following code, where _printer is an instance of the GanttPrinter class:

    _printer.setMargin(25, 16, 66, 66);

  • Page size: The setPageSize method of the GanttPrinter class lets you specify the height and width of the printed page in pixels as shown in the following code, where _printer is an instance of the GanttPrinter class:

    _printer.setPageSize (440, 600);

  • Time period: The setStartTime and setEndTime methods of the GanttPrinter class let you identify the time period of the Gantt chart that you want to print.

    Example 26-19 shows sample code for setting a specific time period in the Gantt chart for printing, where startDate and endDate are variables that represent the desired dates and _printer is an instance of the GanttPrinter class.

Example 26-19 Code for Setting the Time Period Option for Printing a Gantt Chart

_printer.setStartTime(startDate);
_printer.setEndTime(endDate);

26.6.2 Action Listener to Handle the Print Event

The Gantt chart toolbar includes a print button that initiates a print action. To print a Gantt chart, you must create an ActionListener to handle the print event. The code in the ActionListener should include the following processes:

  1. Access the servlet's output stream.

  2. Generate the FO. This process includes creating an instance of the GanttPrinter class and entering the code for any print options that you want to use.

  3. Generate the PDF.

Example 26-20 shows the code for an ActionListener that handles the print event. This listener includes settings for all the print options available in the GanttPrinter helper class.

Example 26-20 Sample ActionListener for Handling the Gantt Chart Print Event

public void handleAction(GanttActionEvent evt)
{
  if (GanttActionEvent.PRINT == evt.getActionType()) 
  { 
     FacesContext _context = FacesContext.getCurrentInstance();
     ServletResponse _response = (ServletResponse) 
              _context.getExternalContext().getResponse();
     _response.setContentType("application/pdf");
     ServletOutputStream _sos = _response.getOutputStream();
     // Generate FO.
     GanttPrinter _printer = new GanttPrinter(m_gantt); 
            // Set column visibility by column index.
     _printer.setColumnVisible(0, false);
            // Set start and end date.
     _printer.setStartTime(startDate);
     _printer.setEndTime(endDate);
            // Set top, bottom, left, and right margins in pixels.
     _printer.setMargin(25, 16, 66, 66);
            // Set height and width in pixels.
     _printer.setPageSize(440, 660);
     File _file = File.createTempFile("gantt", "fo");
     OutputStream _out = new FileOutputStream(_file);
     _printer.print(_out); 
     _out.close(); 
     // generate PDF. 
     FOProcessor _processor = new FOProcessor();
     _processor.setData(new FileInputStream(_file),"UTF-8"));
     _processor.setOutputFormat(FOProcessor.FORMAT_PDF);
     _processor.setOutput(_sos);
     _processor.generate();
     _context.responseComplete();
     response.setHeader("Cache-Control", "no-cache");
   } 
} 

26.7 Using Gantt Charts as a Drop Target or Drag Source

You can add drag and drop functionality that allows users to drag an item from a collection, for example, a row from a table, and drop it into another collection component, such as a tree. Project and scheduling Gantt chart components can be enabled as drag sources as well as drop targets for ADF table or tree table components. A resource utilization Gantt chart component can be enabled only as a drop target.

The application must register the Gantt chart component as a drag source or drop target by adding the af:collectionDragSource or af:collectionDropTarget behavior tags respectively as a child to the Gantt tag. For example, you can use the af:collectionDragSource to register a drop listener that would be invoked when a project Gantt chart task is dragged from a table region onto a separate table. shows a project Gantt chart with tasks dragged from the table region onto a table of tasks.

Figure 26-10 Project Gantt Chart as Drag Source

project Gantt chart as drag source

Example 26-21 shows sample code for adding drag and drop functionality to a scheduling Gantt chart.

Example 26-21 Sample Code for Adding Drag and Drop Functionality

<dvt:schedulingGantt value="#{test.treeModel}"
    .............
    <af:schedulingDragSource actions="COPY MOVE" modelName="treeModel"  />
</dvt:projectGantt>

Example 26-22 shows sample code for the listener method for handling the drop event.

Example 26-22 Event Handler Code for a dropListener for a Collection

public DnDAction onTableDrop(DropEvent evt)
{
    Transferable _transferable = evt.getTransferable();
 
    // Get the drag source, which is a row key, to identify which row has been dragged.
    RowKeySetImpl _rowKey = (RowKeySetImpl)_transferable.getTransferData(DataFlavor.ROW_KEY_SET_FLAVOR).getData();
 
    // Set the row key on the table model (source) to get the data.
    // m_tableModel is the model for the Table (the drag source).
    object _key = _rowKey.iterator().next();
    m_tableModel.setRowKey(_key);
 
    // See on which resource this is dropped (specific for scheduling Gantt chart).
    String _resourceId = _transferable.getData(String.class);
    Resource _resource = findResourceById(_resourceId);
 
    // See on what time slot did this dropped.
    Date _date = _transferable.getData(Date.class);
 
    // Add code to update your model here.
 
    // Refresh the table and the Gantt chart.
    RequestContext.getCurrentInstance().addPartialTarget(_evt.getDragComponent());
    RequestContext.getCurrentInstance().addPartialTarget(m_gantt);
 
    // Indicate the drop is successful.
    return DnDAction.COPY;
}

For a detailed procedure about adding drag and drop functionality for collections, see Section 33.4, "Adding Drag and Drop Functionality for Collections".