use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestConnector method inferCompletionDate.
private void inferCompletionDate(ITask task, TaskData taskData, TaskMapper scheme, boolean isComplete) {
if (isComplete) {
Date completionDate = null;
List<TaskAttribute> taskComments = taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_COMMENT);
if (taskComments != null && taskComments.size() > 0) {
// comments are in reverse order
TaskAttribute lastComment = taskComments.get(0);
if (lastComment != null) {
TaskAttribute attributeCommentDate = lastComment.getMappedAttribute(TaskAttribute.COMMENT_DATE);
if (attributeCommentDate != null) {
completionDate = new Date(Long.parseLong(attributeCommentDate.getValue()));
}
}
}
if (completionDate == null) {
// Use last modified date
TaskAttribute attributeLastModified = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION);
if (attributeLastModified != null && attributeLastModified.getValue().length() > 0) {
completionDate = taskData.getAttributeMapper().getDateValue(attributeLastModified);
}
}
task.setCompletionDate(completionDate);
} else {
task.setCompletionDate(null);
}
// OSIO Specific Attributes
// Space
TaskAttribute attrDelta = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SPACE.getKey());
if (attrDelta != null && !attrDelta.getValue().equals("")) {
// $NON-NLS-1$
task.setAttribute(OSIORestTaskSchema.getDefault().SPACE.getKey(), attrDelta.getValue());
}
// Date Modification
attrDelta = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().DATE_MODIFICATION.getKey());
if (attrDelta != null && !attrDelta.getValue().equals("")) {
// $NON-NLS-1$
task.setAttribute(OSIORestTaskSchema.getDefault().DATE_MODIFICATION.getKey(), attrDelta.getValue());
}
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIOAddLinksAttributeEditor method createControl.
@Override
public void createControl(Composite parent, FormToolkit toolkit) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(2, true));
attrAddLink = getModel().getTaskData().getRoot().getMappedAttribute(OSIORestTaskSchema.getDefault().ADD_LINK.getKey());
typeCombo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
toolkit.adapt(typeCombo, true, true);
typeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
typeCombo.setFont(JFaceResources.getDefaultFont());
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(typeCombo);
typeCombo.setToolTipText(getDescription());
typeCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = typeCombo.getSelectionIndex();
String linkType = typeCombo.getItem(index);
TaskAttribute attr = getTaskAttribute();
// $NON-NLS-1$
attr.setValue(linkType + " " + workitemCombo.getText());
TaskAttributeMetaData metadata = attr.getMetaData();
// $NON-NLS-1$
String linkid = linkTypes.containsKey(linkType) ? linkTypes.get(linkType) : "";
metadata.putValue("linkid", linkid);
if (index % 2 == 1) {
// $NON-NLS-1$ //$NON-NLS-2$
metadata.putValue("direction", "forward");
} else {
// $NON-NLS-1$ //$NON-NLS-2$
metadata.putValue("direction", "reverse");
}
getModel().attributeChanged(attrAddLink);
}
});
workitemCombo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
toolkit.adapt(workitemCombo, true, true);
workitemCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
workitemCombo.setFont(JFaceResources.getDefaultFont());
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(workitemCombo);
workitemCombo.setToolTipText(getDescription());
workitemCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = workitemCombo.getSelectionIndex();
String workitem = workitemCombo.getItem(index);
TaskAttribute attr = getTaskAttribute();
// $NON-NLS-1$
attr.setValue(typeCombo.getText() + " " + workitem);
TaskAttributeMetaData metadata = attr.getMetaData();
metadata.putValue("targetWidName", workitem);
// $NON-NLS-1$
metadata.putValue("targetWid", workitems.get(workitem).getId());
getModel().attributeChanged(attrAddLink);
}
});
populateFromAttribute();
setControl(comp);
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIOLinksAttributeEditor method copyLinkMetaData.
// Copy link meta data from Links attribute to RemoveLinks attribute
// (a map of link strings to their link uuids which is needed to delete them)
private void copyLinkMetaData() {
TaskAttribute attrLinks = getTaskAttribute();
if (attrLinks != null) {
TaskAttributeMetaData metadata = attrLinks.getMetaData();
TaskAttributeMetaData removeMetaData = attrRemoveLinks.getMetaData();
if (metadata != null) {
for (String link : attrLinks.getValues()) {
String metaValue = metadata.getValue(link);
removeMetaData.putValue(link, metaValue);
}
}
}
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIORestTaskEditorPeoplePart method getAttributes.
@Override
protected Collection<TaskAttribute> getAttributes() {
Map<String, TaskAttribute> allAttributes = getTaskData().getRoot().getAttributes();
List<TaskAttribute> attributes = new ArrayList<TaskAttribute>(allAttributes.size());
attributes.add(getTaskData().getRoot().getMappedAttribute(OSIORestTaskSchema.getDefault().ASSIGNEES.getKey()));
for (TaskAttribute attribute : allAttributes.values()) {
TaskAttributeMetaData properties = attribute.getMetaData();
if (TaskAttribute.KIND_PEOPLE.equals(properties.getKind())) {
if (!attributes.contains(attribute)) {
attributes.add(attribute);
}
}
}
return attributes;
}
use of org.eclipse.mylyn.tasks.core.data.TaskAttribute in project linuxtools by eclipse.
the class OSIOWorkitemLinkAttributeEditor method getCommentGroupViewers.
public List<CommentGroupViewer> getCommentGroupViewers() {
if (commentGroupViewers != null) {
return commentGroupViewers;
}
// group comments
List<ITaskComment> comments = new ArrayList<ITaskComment>();
for (TaskAttribute commentAttribute : this.commentAttributes) {
comments.add(convertToTaskComment(getModel(), commentAttribute));
}
String currentPersonId = getModel().getTaskRepository().getUserName();
List<CommentGroup> commentGroups = getCommentGroupStrategy().groupComments(comments, currentPersonId);
commentGroupViewers = new ArrayList<CommentGroupViewer>(commentGroups.size());
if (commentGroups.size() > 0) {
for (int i = 0; i < commentGroups.size(); i++) {
CommentGroupViewer viewer = new CommentGroupViewer(commentGroups.get(i));
boolean isLastGroup = i == commentGroups.size() - 1;
viewer.setRenderedInSubSection(!isLastGroup);
commentGroupViewers.add(viewer);
}
}
return commentGroupViewers;
}
Aggregations