How to Identify Specific Dates as Nonworking Days

Using ADF Gantt Chart Components 28-23

28.9.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.setColumnVisibleo, 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.setMargin25, 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 28–18 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 28–18 Code for Setting the Time Period Option for Printing a Gantt Chart _printer.setStartTimestartDate; _printer.setEndTimeendDate;

28.9.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 28–19 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. 28-24 Web User Interface Developers Guide for Oracle Application Development Framework Example 28–19 Sample ActionListener for Handling the Gantt Chart Print Event public void handleActionGanttActionEvent evt { if GanttActionEvent.PRINT == evt.getActionType { FacesContext _context = FacesContext.getCurrentInstance; ServletResponse _response = ServletResponse _context.getExternalContext.getResponse; _response.setContentTypeapplicationpdf; ServletOutputStream _sos = _response.getOutputStream; Generate FO. GanttPrinter _printer = new GanttPrinterm_gantt; Set column visibility by column index. _printer.setColumnVisible0, false; Set start and end date. _printer.setStartTimestartDate; _printer.setEndTimeendDate; Set top, bottom, left, and right margins in pixels. _printer.setMargin25, 16, 66, 66; Set height and width in pixels. _printer.setPageSize440, 660; File _file = File.createTempFilegantt, fo; OutputStream _out = new FileOutputStream_file; _printer.print_out; _out.close; generate PDF. FOProcessor _processor = new FOProcessor; _processor.setDatanew FileInputStream_file,UTF-8; _processor.setOutputFormatFOProcessor.FORMAT_PDF; _processor.setOutput_sos; _processor.generate; _context.responseComplete; } }

28.10 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.