blob: 2eec74aac3fcf089de30c7f6f9dea1c15918a764 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*******************************************************************************
* Copyright (c) 2013 Boeing.
* 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:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ats.util;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osee.ats.api.IAtsConfigObject;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.api.version.IAtsVersion;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.search.ui.text.Match;
import org.eclipse.swt.graphics.Image;
/**
* @author Donald G. Dunne
*/
public class AtsObjectLabelProvider extends LabelProvider {
private final boolean showActive;
public AtsObjectLabelProvider() {
this(false);
}
public AtsObjectLabelProvider(boolean showActive) {
super();
this.showActive = showActive;
}
@Override
public Image getImage(Object element) {
if (element instanceof Artifact) {
return ArtifactImageManager.getImage((Artifact) element);
} else if (element instanceof IAtsActionableItem) {
return ArtifactImageManager.getImage(AtsArtifactTypes.ActionableItem);
} else if (element instanceof IAtsTeamDefinition) {
return ArtifactImageManager.getImage(AtsArtifactTypes.TeamDefinition);
} else if (element instanceof IAtsVersion) {
return ArtifactImageManager.getImage(AtsArtifactTypes.Version);
} else if (element instanceof Match && ((Match) element).getElement() instanceof Artifact) {
return ArtifactImageManager.getImage((Artifact) ((Match) element).getElement());
}
return ImageManager.getImage(ImageManager.MISSING);
}
@Override
public String getText(Object element) {
String result = "";
if (element != null) {
if (element instanceof Match) {
element = ((Match) element).getElement();
}
if (element instanceof IAtsObject) {
IAtsObject artifact = (IAtsObject) element;
List<String> extraInfo = new ArrayList<String>();
String name = artifact.getName();
extraInfo.add(name != null ? name : "");
result = Collections.toString(" ", extraInfo);
} else {
result = element.toString();
}
}
result = getActiveTag(element, result);
return result;
}
private String getActiveTag(Object element, String result) {
if (showActive && (element instanceof IAtsConfigObject)) {
IAtsConfigObject iAtsObject = (IAtsConfigObject) element;
result = String.format("%s (%s)", result, iAtsObject.isActive() ? "Active" : "InActive");
}
return result;
}
}
|