Skip to main content
summaryrefslogtreecommitdiffstats
blob: 00f07e474249b6814bd17f1fa11881cb256c88d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*******************************************************************************
 * Copyright (c) 2017 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.bugzilla.rest.ui;

import org.eclipse.jface.viewers.StyledString;
import org.eclipse.mylyn.internal.bugzilla.rest.core.IBugzillaRestConstants;
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;

public class BugzillaRestAttachmentTableLabelProvider extends AttachmentTableLabelProvider {

	@Override
	public StyledString buildTextFromEventIndex(int index, ITaskAttachment attachment) {
		if (index == 6) {
			return getAttachmentFlags(attachment);
		} else {
			return super.buildTextFromEventIndex(index, attachment);
		}
	}

	public static StyledString getAttachmentFlags(ITaskAttachment attachment) {
		StyledString text = new StyledString();

		for (TaskAttribute taskAttribute : attachment.getTaskAttribute().getAttributes().values()) {
			if (taskAttribute.getId().startsWith(IBugzillaRestConstants.KIND_FLAG)) {
				TaskAttribute stateAttribute = taskAttribute.getAttribute("state");
				if (text.length() > 0) {
					text.append("\n");
				}
				text.append(stateAttribute.getMetaData().getLabel());
				text.append(": ");
				text.append(stateAttribute.getValue());
				TaskAttribute requesteeAttribute = taskAttribute.getAttribute("requestee");
				if (!requesteeAttribute.getValue().isEmpty()) {
					text.append(" ");
					text.append(requesteeAttribute.getValue(), StyledString.COUNTER_STYLER);
				}

			}
		}
		return text;
	}

}

Back to the top