Search in sources :

Example 21 with TaskAttribute

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());
    }
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) Date(java.util.Date)

Example 22 with TaskAttribute

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);
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) GridLayout(org.eclipse.swt.layout.GridLayout) TaskAttributeMetaData(org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo)

Example 23 with TaskAttribute

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);
            }
        }
    }
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) TaskAttributeMetaData(org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData)

Example 24 with TaskAttribute

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;
}
Also used : TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) TaskAttributeMetaData(org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData) ArrayList(java.util.ArrayList)

Example 25 with TaskAttribute

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;
}
Also used : ITaskComment(org.eclipse.mylyn.tasks.core.ITaskComment) TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) CommentGroup(org.eclipse.mylyn.internal.tasks.ui.editors.CommentGroupStrategy.CommentGroup) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point)

Aggregations

TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)36 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)13 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)13 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)12 Test (org.junit.Test)12 AbstractTaskDataHandler (org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler)11 TaskAttributeMapper (org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper)11 NullOperationMonitor (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor)10 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)10 RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)10 FileReader (java.io.FileReader)7 OSIORestTaskSchema (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskSchema)5 TaskAttributeMetaData (org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData)5 JsonWriter (com.google.gson.stream.JsonWriter)3 StringWriter (java.io.StringWriter)3 ArrayList (java.util.ArrayList)3 LinkedHashSet (java.util.LinkedHashSet)3 TreeSet (java.util.TreeSet)3 Space (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space)3 TaskCommentMapper (org.eclipse.mylyn.tasks.core.data.TaskCommentMapper)3