Creating a Task Link
Contents
[
Hide
Show
]Create New Task Links
A task link is created using the default constructor of TaskLink class which accepts three parameters:
- The first parameter defines the predecessor Task,
- the second parameter defines the successor Task and, finally,
- the third parameter defines the task link type from values specified by the TaskLinkType enumeration type.
The following example creates a link between two tasks with Task1 as predecessor.
1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
2// The path to the documents directory.
3String dataDir = Utils.getDataDir(CreateTaskLink.class);
4
5Project project = new Project();
6Task pred = project.getRootTask().getChildren().add("Task 1");
7Task succ = project.getRootTask().getChildren().add("Task 2");
8TaskLink link = project.getTaskLinks().add(pred, succ);