Hi ,
As my last post i had posted the basis explanation of Gantt Chart in adf.In this post i will try to explain the creation of the new Task Type and apply those newly created task type in to Project Gantt Chart task.
And same time i also want to incorporate the following point on GanttChartProjectBean class which is maintained on oracle site
Under section 26.2.1 Data for a Project Gantt Chart
"Optionally, the object could implement the
i have implemented the Task interface on the GanttChartProjectBean class.
Code is following
Using Task Bar Format we can customize the bar which is render in the chart region of the Gantt Chart.
1-Fill color
1-Canceled
On the basis of user requirement ,developer should have to pass the current instance of taskbarFormatManager Object and type of task it's may be any one of three of them .
If you apply the Invalid Task it will look like following :
If you apply the CANCELED Task it will look like following :
If you apply the COMPLETE Task it will look like following :
The following code is used to create the new task and applying the newly task type on task
*I am still on working on the Model(GanttChartProjectBean) class to make it generic.
Download project from following link
http://www.4shared.com/rar/4JAz5xfQ/GanttChartV20.html
Thanks
Prateek Shaw
As my last post i had posted the basis explanation of Gantt Chart in adf.In this post i will try to explain the creation of the new Task Type and apply those newly created task type in to Project Gantt Chart task.
And same time i also want to incorporate the following point on GanttChartProjectBean class which is maintained on oracle site
Under section 26.2.1 Data for a Project Gantt Chart
"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."i have implemented the Task interface on the GanttChartProjectBean class.
Code is following
package com.prateek.oracle.adf.view.bean;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import oracle.adf.view.faces.bi.model.Dependency;
import oracle.adf.view.faces.bi.model.RecurringTask;
import oracle.adf.view.faces.bi.model.SplitTask;
import oracle.adf.view.faces.bi.model.Task;
public class GanttChartProjectBean implements Task {
public GanttChartProjectBean() {
}
// Date. The actual end time for normal and milestone tasks.
private Date actualEnd;
//Date. The actual start time for normal and milestone tasks.
private Date actualStart;
//Date. Completed through for normal and summary tasks.
private Date completedThrough;
//Boolean. Specifies whether or not the task is critical for all tasks.
private Boolean critical;
//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.
// Dependency (node)
//Date. The end time for all tasks. (required)
private Date endTime;
//String. The first icon associated with the task bar for all tasks.
//The icon might change depending on other attributes
private String icon1;
//String. The second icon associated with the tasks bar for all tasks.
private String icon2;
//String. The third icon associated with the tasks bar for all tasks.
private String icon3;
//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.
private String iconPlacement;
//Boolean. Specifies whether or not a node definition is a container.
private Boolean isContainer;
//String. The label associated with the task bar for all tasks.
private String label;
//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.
private String labelPlacement;
//Integer. Percentage completed for normal and summary tasks.
private Integer percentComplete;
// 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.
//Date. The starting time for all tasks.(required)
private Date startTime;
// Subtasks (node)
// An optional list of subtasks for all tasks.
//String. The unique identifier for all tasks.
private String taskId;
//Sting. The type of the tasks for all tasks.
private String type;
//not in the documnet but still adding because gantt is throwing exception
private String taskType;
//split task
private List<SplitTask> splitTasks;
private List<Dependency> dependencies;
private List<RecurringTask> recurringTask;
private String recurringTaskId;
public void setActualEnd(Date actualEnd) {
this.actualEnd = actualEnd;
}
public Date getActualEnd() {
return actualEnd;
}
public void setActualStart(Date actualStart) {
this.actualStart = actualStart;
}
public Date getActualStart() {
return actualStart;
}
public void setCompletedThrough(Date completedThrough) {
this.completedThrough = completedThrough;
}
public Date getCompletedThrough() {
return completedThrough;
}
public void setCritical(Boolean critical) {
this.critical = critical;
}
public Boolean getCritical() {
return critical;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Date getEndTime() {
return endTime;
}
public void setIcon1(String icon1) {
this.icon1 = icon1;
}
public String getIcon1() {
return icon1;
}
public void setIcon2(String icon2) {
this.icon2 = icon2;
}
public String getIcon2() {
return icon2;
}
public void setIcon3(String icon3) {
this.icon3 = icon3;
}
public String getIcon3() {
return icon3;
}
public void setIconPlacement(String iconPlacement) {
this.iconPlacement = iconPlacement;
}
public String getIconPlacement() {
return iconPlacement;
}
public void setIsContainer(Boolean isContainer) {
this.isContainer = isContainer;
}
public Boolean getIsContainer() {
return isContainer;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public void setLabelPlacement(String labelPlacement) {
this.labelPlacement = labelPlacement;
}
public String getLabelPlacement() {
return labelPlacement;
}
public void setPercentComplete(Integer percentComplete) {
this.percentComplete = percentComplete;
}
public Integer getPercentComplete() {
return percentComplete;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getStartTime() {
return startTime;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskId() {
return taskId;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getTaskType() {
return taskType;
}
public String toString() {
return taskId;
}
public int getLabelAlign() {
return 0;
}
public int getIconAlign() {
return 0;
}
public List<RecurringTask> getRecurringTasks() {
return Collections.emptyList();
}
public void setSplitTasks(List<SplitTask> splitTasks) {
this.splitTasks = splitTasks;
}
public List<SplitTask> getSplitTasks() {
return splitTasks;
}
public void setDependencies(List<Dependency> dependencies) {
this.dependencies = dependencies;
}
public List<Dependency> getDependencies() {
return dependencies;
}
public void setRecurringTaskId(String recurringTaskId) {
this.recurringTaskId = recurringTaskId;
}
public String getRecurringTaskId() {
return recurringTaskId;
}
public void setRecurringTask(List<RecurringTask> recurringTask) {
this.recurringTask = recurringTask;
}
public List<RecurringTask> getRecurringTask() {
return recurringTask;
}
}
import java.util.Collections;
import java.util.Date;
import java.util.List;
import oracle.adf.view.faces.bi.model.Dependency;
import oracle.adf.view.faces.bi.model.RecurringTask;
import oracle.adf.view.faces.bi.model.SplitTask;
import oracle.adf.view.faces.bi.model.Task;
public class GanttChartProjectBean implements Task {
public GanttChartProjectBean() {
}
// Date. The actual end time for normal and milestone tasks.
private Date actualEnd;
//Date. The actual start time for normal and milestone tasks.
private Date actualStart;
//Date. Completed through for normal and summary tasks.
private Date completedThrough;
//Boolean. Specifies whether or not the task is critical for all tasks.
private Boolean critical;
//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.
// Dependency (node)
//Date. The end time for all tasks. (required)
private Date endTime;
//String. The first icon associated with the task bar for all tasks.
//The icon might change depending on other attributes
private String icon1;
//String. The second icon associated with the tasks bar for all tasks.
private String icon2;
//String. The third icon associated with the tasks bar for all tasks.
private String icon3;
//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.
private String iconPlacement;
//Boolean. Specifies whether or not a node definition is a container.
private Boolean isContainer;
//String. The label associated with the task bar for all tasks.
private String label;
//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.
private String labelPlacement;
//Integer. Percentage completed for normal and summary tasks.
private Integer percentComplete;
// 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.
//Date. The starting time for all tasks.(required)
private Date startTime;
// Subtasks (node)
// An optional list of subtasks for all tasks.
//String. The unique identifier for all tasks.
private String taskId;
//Sting. The type of the tasks for all tasks.
private String type;
//not in the documnet but still adding because gantt is throwing exception
private String taskType;
//split task
private List<SplitTask> splitTasks;
private List<Dependency> dependencies;
private List<RecurringTask> recurringTask;
private String recurringTaskId;
public void setActualEnd(Date actualEnd) {
this.actualEnd = actualEnd;
}
public Date getActualEnd() {
return actualEnd;
}
public void setActualStart(Date actualStart) {
this.actualStart = actualStart;
}
public Date getActualStart() {
return actualStart;
}
public void setCompletedThrough(Date completedThrough) {
this.completedThrough = completedThrough;
}
public Date getCompletedThrough() {
return completedThrough;
}
public void setCritical(Boolean critical) {
this.critical = critical;
}
public Boolean getCritical() {
return critical;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Date getEndTime() {
return endTime;
}
public void setIcon1(String icon1) {
this.icon1 = icon1;
}
public String getIcon1() {
return icon1;
}
public void setIcon2(String icon2) {
this.icon2 = icon2;
}
public String getIcon2() {
return icon2;
}
public void setIcon3(String icon3) {
this.icon3 = icon3;
}
public String getIcon3() {
return icon3;
}
public void setIconPlacement(String iconPlacement) {
this.iconPlacement = iconPlacement;
}
public String getIconPlacement() {
return iconPlacement;
}
public void setIsContainer(Boolean isContainer) {
this.isContainer = isContainer;
}
public Boolean getIsContainer() {
return isContainer;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public void setLabelPlacement(String labelPlacement) {
this.labelPlacement = labelPlacement;
}
public String getLabelPlacement() {
return labelPlacement;
}
public void setPercentComplete(Integer percentComplete) {
this.percentComplete = percentComplete;
}
public Integer getPercentComplete() {
return percentComplete;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getStartTime() {
return startTime;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskId() {
return taskId;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getTaskType() {
return taskType;
}
public String toString() {
return taskId;
}
public int getLabelAlign() {
return 0;
}
public int getIconAlign() {
return 0;
}
public List<RecurringTask> getRecurringTasks() {
return Collections.emptyList();
}
public void setSplitTasks(List<SplitTask> splitTasks) {
this.splitTasks = splitTasks;
}
public List<SplitTask> getSplitTasks() {
return splitTasks;
}
public void setDependencies(List<Dependency> dependencies) {
this.dependencies = dependencies;
}
public List<Dependency> getDependencies() {
return dependencies;
}
public void setRecurringTaskId(String recurringTaskId) {
this.recurringTaskId = recurringTaskId;
}
public String getRecurringTaskId() {
return recurringTaskId;
}
public void setRecurringTask(List<RecurringTask> recurringTask) {
this.recurringTask = recurringTask;
}
public List<RecurringTask> getRecurringTask() {
return recurringTask;
}
}
Creating a New Task Type :
Using Task Bar Format we can customize the bar which is render in the chart region of the Gantt Chart.
Task Bat Format contains following properties
1-Fill color
2-Fill image pattern
3-Border color
4-Images used for a milestone task
5-Images used for the beginning and end of a summary task
we can override these properties according over business requirement and create new task.
I have created the a method in Utils class which we will create new type of the task and it will register the newly created task in Task Bar Manager .However in backing bean we need to apply newly created task type to Task using setTaskType method.
Code is following :
public static void createNewTask(TaskbarFormatManager taskbarFormatManager,
String taskName) {
TaskbarFormat taskbarFormat = null;
if (taskName.equals(GanttChartConstantsBean.NEW_TASK_CANCELED)) {
taskbarFormat =
new TaskbarFormat(taskName, GanttChartConstantsBean.CANCELED_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.NULL,
GanttChartConstantsBean.CANCELED_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.HEIGHT);
} else if (taskName.equals(GanttChartConstantsBean.NEW_TASK_COMPLETE)) {
taskbarFormat =
new TaskbarFormat(taskName, GanttChartConstantsBean.COMPLETE_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.NULL,
GanttChartConstantsBean.COMPLETE_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.HEIGHT);
} else if (taskName.equals(GanttChartConstantsBean.NEW_TASK_INVALID)) {
taskbarFormat =
new TaskbarFormat(taskName, GanttChartConstantsBean.INVALID_TASK_COLOR_INVALID_VALUE,
GanttChartConstantsBean.NULL,
GanttChartConstantsBean.INVALID_TASK_COLOR_INVALID_VALUE,
GanttChartConstantsBean.HEIGHT);
} else {
//No need to do any things
}
taskbarFormatManager.registerTaskbarFormat(taskName, taskbarFormat);
}
String taskName) {
TaskbarFormat taskbarFormat = null;
if (taskName.equals(GanttChartConstantsBean.NEW_TASK_CANCELED)) {
taskbarFormat =
new TaskbarFormat(taskName, GanttChartConstantsBean.CANCELED_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.NULL,
GanttChartConstantsBean.CANCELED_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.HEIGHT);
} else if (taskName.equals(GanttChartConstantsBean.NEW_TASK_COMPLETE)) {
taskbarFormat =
new TaskbarFormat(taskName, GanttChartConstantsBean.COMPLETE_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.NULL,
GanttChartConstantsBean.COMPLETE_TASK_COLOR_HEXADECIMAL_VALUE,
GanttChartConstantsBean.HEIGHT);
} else if (taskName.equals(GanttChartConstantsBean.NEW_TASK_INVALID)) {
taskbarFormat =
new TaskbarFormat(taskName, GanttChartConstantsBean.INVALID_TASK_COLOR_INVALID_VALUE,
GanttChartConstantsBean.NULL,
GanttChartConstantsBean.INVALID_TASK_COLOR_INVALID_VALUE,
GanttChartConstantsBean.HEIGHT);
} else {
//No need to do any things
}
taskbarFormatManager.registerTaskbarFormat(taskName, taskbarFormat);
}
In this class i have created three different type of task which are
1-Canceled
2-Complete
3-Invalid
On the basis of user requirement ,developer should have to pass the current instance of taskbarFormatManager Object and type of task it's may be any one of three of them .If you apply the Invalid Task it will look like following :
If you apply the CANCELED Task it will look like following :
If you apply the COMPLETE Task it will look like following :
The following code is used to create the new task and applying the newly task type on task
ganttChartProjectBean.setCritical(false);
ganttChartProjectBean.setEndTime(GanttChartUtil.addMonth(3));
ganttChartProjectBean.setStartTime(GanttChartUtil.addMonth(1));
ganttChartProjectBean.setTaskId("1");
ganttChartProjectBean.setType("firstwork");
ganttChartProjectBean.setLabel("Project One");
ganttChartProjectBean.setTaskType("Normal");
ganttChartProjectBean.setLabelPlacement("end");
ganttChartProjectBean.setIconPlacement("right");
GanttChartUtil.createNewTask(_ganttChartBinding.getTaskbarFormatManager(),
GanttChartConstantsBean.NEW_TASK_INVALID);
ganttChartProjectBean.setTaskType(GanttChartConstantsBean.NEW_TASK_INVALID);
ganttChartProjectBean.setEndTime(GanttChartUtil.addMonth(3));
ganttChartProjectBean.setStartTime(GanttChartUtil.addMonth(1));
ganttChartProjectBean.setTaskId("1");
ganttChartProjectBean.setType("firstwork");
ganttChartProjectBean.setLabel("Project One");
ganttChartProjectBean.setTaskType("Normal");
ganttChartProjectBean.setLabelPlacement("end");
ganttChartProjectBean.setIconPlacement("right");
GanttChartUtil.createNewTask(_ganttChartBinding.getTaskbarFormatManager(),
GanttChartConstantsBean.NEW_TASK_INVALID);
ganttChartProjectBean.setTaskType(GanttChartConstantsBean.NEW_TASK_INVALID);
*I am still on working on the Model(GanttChartProjectBean) class to make it generic.
Download project from following link
http://www.4shared.com/rar/4JAz5xfQ/GanttChartV20.html
Thanks
Prateek Shaw