Skip to main content
summaryrefslogtreecommitdiffstats
blob: 01c78513770f6a106e6b82bae4c38c069fb9698a (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
/*******************************************************************************
 * Copyright (c) 2017 Frank Becker 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:
 *     Frank Becker - initial API and implementation
 *******************************************************************************/

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

import java.util.Arrays;

import org.eclipse.jface.viewers.StyledString;
import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.commons.ui.TableColumnDescriptor;
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttachmentPart;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.swt.SWT;

public class BugzillaRestTaskEditorAttachmentPart extends TaskEditorAttachmentPart {

	@Override
	protected TableColumnDescriptor[] createColumnDescriptors() {
		TableColumnDescriptor[] defined = super.createColumnDescriptors();

		TableColumnDescriptor[] result = Arrays.copyOf(defined, defined.length + 1);
		result[defined.length] = new TableColumnDescriptor(100, "Flags", SWT.LEFT, false, SWT.DOWN, true);
		return result;
	}

	@Override
	protected AttachmentTableLabelProvider createTableProvider() {
		return new BugzillaRestAttachmentTableLabelProvider();
	}

	@Override
	protected int compareColumn(ITaskAttachment attachment1, ITaskAttachment attachment2, int propertyIndex) {
		if (propertyIndex == 6) {
			StyledString flags1 = BugzillaRestAttachmentTableLabelProvider.getAttachmentFlags(attachment1);
			StyledString flags2 = BugzillaRestAttachmentTableLabelProvider.getAttachmentFlags(attachment2);
			String flags1String = flags1 != null ? flags1.getString() : null;
			String flags2String = flags1 != null ? flags2.getString() : null;
			return CoreUtil.compare(flags1String, flags2String);
		} else {
			return super.compareColumn(attachment1, attachment2, propertyIndex);
		}
	}

}

Back to the top