-
Notifications
You must be signed in to change notification settings - Fork 4
/
Tags.java
117 lines (98 loc) · 2.88 KB
/
Tags.java
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*******************************************************************************************************
*
* Tags.java, in ummisco.gama.ui.navigator, is part of the source code of the GAMA modeling and simulation platform
* (v.1.8.2).
*
* (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
********************************************************************************************************/
package ummisco.gama.ui.navigator.contents;
import java.util.Map;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import one.util.streamex.StreamEx;
import ummisco.gama.ui.resources.GamaColors;
import ummisco.gama.ui.resources.GamaColors.GamaUIColor;
import ummisco.gama.ui.resources.GamaIcons;
import ummisco.gama.ui.resources.IGamaColors;
/**
* Class ImportFolder.
*
* @author drogoul
* @since 5 févr. 2015
*
*/
public class Tags extends VirtualContent<WrappedFile> {
/** The tags. */
final Map<String, String> tags;
/** The search. */
final boolean search;
/**
* @param root
* @param name
*/
public Tags(final WrappedFile root, final Map<String, String> object, final String name,
final boolean doubleClickForSearching) {
super(root, name);
tags = object;
search = doubleClickForSearching;
}
/**
* Method hasChildren()
*
* @see ummisco.gama.ui.navigator.contents.VirtualContent#hasChildren()
*/
@Override
public boolean hasChildren() {
return !tags.isEmpty();
}
/**
* Method getNavigatorChildren()
*
* @see ummisco.gama.ui.navigator.contents.VirtualContent#getNavigatorChildren()
*/
@Override
public Object[] getNavigatorChildren() {
if (tags.isEmpty()) return EMPTY;
return StreamEx.ofKeys(tags).map(each -> new Tag(this, each, tags.get(each), search)).toArray();
}
/**
* Method getImage()
*
* @see ummisco.gama.ui.navigator.contents.VirtualContent#getImage()
*/
@Override
public Image getImage() { return GamaIcons.create("gaml/_attributes").image(); }
/**
* Method getColor()
*
* @see ummisco.gama.ui.navigator.contents.VirtualContent#getColor()
*/
@Override
public Color getColor() {
for (String s : tags.values()) {
if (s.contains("built-in attribute")) return GamaColors.system(SWT.COLOR_DARK_RED);
}
return null;
}
@Override
public void getSuffix(final StringBuilder sb) {}
@Override
public int findMaxProblemSeverity() {
return 0;
}
@Override
public ImageDescriptor getOverlay() { return null; }
@Override
public VirtualContentType getType() { return VirtualContentType.CATEGORY; }
@Override
public String getStatusMessage() { return "Tags"; }
@Override
public GamaUIColor getStatusColor() { return IGamaColors.GRAY_LABEL; }
@Override
public Image getStatusImage() { return getImage(); }
}