Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mylyn » Howto programmatically add a comment
Howto programmatically add a comment [message #53554] Sat, 19 July 2008 19:37 Go to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

This is a multi-part message in MIME format.
--------------090503030200090300000409
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

After a long trial and error phase I managed to list all comments of a
selected task:

| ITaskDataManager taskDataManager = TasksUi.getTaskDataManager();
IRepositoryManager repositoryManager = TasksUi.getRepositoryManager();

ITask task = (ITask)((IStructuredSelection)selection).getFirstElement();
ITaskDataWorkingCopy taskDataState = taskDataManager.getWorkingCopy(task);
TaskRepository taskRepository = repositoryManager.getRepository(taskDataState.getConnectorKi nd(), taskDataState
.getRepositoryUrl());

TaskDataModel model = *new *TaskDataModel(taskRepository, task, taskDataState);
TaskData taskData = model.getTaskData();
TaskAttributeMapper attributeMapper = taskData.getAttributeMapper();

List<TaskAttribute> comments = attributeMapper.getAttributesByType(taskData, TaskAttribute.TYPE_COMMENT);
*for *(TaskAttribute commentAttribute : comments)
{
System.out.println(commentAttribute.getId());
TaskAttribute textAttribute = commentAttribute.getMappedAttribute(TaskAttribute.COMMENT_TE XT);
System.out.println(textAttribute.getValue());
}|


How can I programmatically add a comment?

Cheers
/Eike



--------------090503030200090300000409
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
After a long trial and error phase I managed to list all comments of a
selected task:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">
Re: Howto programmatically add a comment [message #53608 is a reply to message #53554] Sun, 20 July 2008 07:12 Go to previous message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

This is a multi-part message in MIME format.
--------------050403080400020903000101
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

I'm so happy that I found it myself:

| TaskAttribute root = taskData.getRoot();
TaskAttribute commentAttribute = root.createMappedAttribute(TaskAttribute.COMMENT_NEW);
commentAttribute.setValue("HURRAH!!!");|


Thanks for your great tool ;-)
/Eike


Eike Stepper schrieb:
> Hi,
>
> After a long trial and error phase I managed to list all comments of a
> selected task:
>
> | ITaskDataManager taskDataManager = TasksUi.getTaskDataManager();
> IRepositoryManager repositoryManager = TasksUi.getRepositoryManager();
>
> ITask task = (ITask)((IStructuredSelection)selection).getFirstElement();
> ITaskDataWorkingCopy taskDataState = taskDataManager.getWorkingCopy(task);
> TaskRepository taskRepository = repositoryManager.getRepository(taskDataState.getConnectorKi nd(), taskDataState
> .getRepositoryUrl());
>
> TaskDataModel model = *new *TaskDataModel(taskRepository, task, taskDataState);
> TaskData taskData = model.getTaskData();
> TaskAttributeMapper attributeMapper = taskData.getAttributeMapper();
>
> List<TaskAttribute> comments = attributeMapper.getAttributesByType(taskData, TaskAttribute.TYPE_COMMENT);
> *for *(TaskAttribute commentAttribute : comments)
> {
> System.out.println(commentAttribute.getId());
> TaskAttribute textAttribute = commentAttribute.getMappedAttribute(TaskAttribute.COMMENT_TE XT);
> System.out.println(textAttribute.getValue());
> }|
>
>
> How can I programmatically add a comment?
>
> Cheers
> /Eike
>
>

--------------050403080400020903000101
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I'm so happy that I found it myself:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">
Re: Howto programmatically add a comment [message #591533 is a reply to message #53554] Sun, 20 July 2008 07:12 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050403080400020903000101
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

I'm so happy that I found it myself:

| TaskAttribute root = taskData.getRoot();
TaskAttribute commentAttribute = root.createMappedAttribute(TaskAttribute.COMMENT_NEW);
commentAttribute.setValue("HURRAH!!!");|


Thanks for your great tool ;-)
/Eike


Eike Stepper schrieb:
> Hi,
>
> After a long trial and error phase I managed to list all comments of a
> selected task:
>
> | ITaskDataManager taskDataManager = TasksUi.getTaskDataManager();
> IRepositoryManager repositoryManager = TasksUi.getRepositoryManager();
>
> ITask task = (ITask)((IStructuredSelection)selection).getFirstElement();
> ITaskDataWorkingCopy taskDataState = taskDataManager.getWorkingCopy(task);
> TaskRepository taskRepository = repositoryManager.getRepository(taskDataState.getConnectorKi nd(), taskDataState
> .getRepositoryUrl());
>
> TaskDataModel model = *new *TaskDataModel(taskRepository, task, taskDataState);
> TaskData taskData = model.getTaskData();
> TaskAttributeMapper attributeMapper = taskData.getAttributeMapper();
>
> List<TaskAttribute> comments = attributeMapper.getAttributesByType(taskData, TaskAttribute.TYPE_COMMENT);
> *for *(TaskAttribute commentAttribute : comments)
> {
> System.out.println(commentAttribute.getId());
> TaskAttribute textAttribute = commentAttribute.getMappedAttribute(TaskAttribute.COMMENT_TE XT);
> System.out.println(textAttribute.getValue());
> }|
>
>
> How can I programmatically add a comment?
>
> Cheers
> /Eike
>
>

--------------050403080400020903000101
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I'm so happy that I found it myself:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">


Previous Topic:don't work
Next Topic:Customize or disable color decorations
Goto Forum:
  


Current Time: Fri Nov 08 23:20:58 GMT 2024

Powered by FUDForum. Page generated in 0.03076 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top