mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-29 12:35:19 +00:00
[FIXED JENKINS-17715] Display Name is not shown
This commit is contained in:
1 parent
d477296ffd
commit
55a68acca9
4 files changed
+103
-37
No files matched your search
@@ -974,6 +974,67 @@ public class Functions {
|
||||
return Items.getAllItems(root, TopLevelItem.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relative name or display name to the given item from the specified group.
|
||||
*
|
||||
* @since 1.515
|
||||
* @param p the Item we want the relative display name
|
||||
* @param g the ItemGroup used as point of reference for the item
|
||||
* @param useDisplayName if true, returns a display name, otherwise returns a name
|
||||
* @return
|
||||
* String like "foo » bar"
|
||||
*/
|
||||
public static String getRelativeNameFrom(Item p, ItemGroup g, boolean useDisplayName) {
|
||||
if (p == null) return null;
|
||||
if (g == null) return useDisplayName ? p.getFullDisplayName() : p.getFullName();
|
||||
String separationString = useDisplayName ? " » " : "/";
|
||||
|
||||
// first list up all the parents
|
||||
Map<ItemGroup,Integer> parents = new HashMap<ItemGroup,Integer>();
|
||||
int depth=0;
|
||||
while (g!=null) {
|
||||
parents.put(g, depth++);
|
||||
if (g instanceof Item)
|
||||
g = ((Item)g).getParent();
|
||||
else
|
||||
g = null;
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Item i=p;
|
||||
while (true) {
|
||||
if (buf.length()>0) buf.insert(0,separationString);
|
||||
buf.insert(0,useDisplayName ? i.getDisplayName() : i.getName());
|
||||
ItemGroup gr = i.getParent();
|
||||
|
||||
Integer d = parents.get(gr);
|
||||
if (d!=null) {
|
||||
String s="";
|
||||
for (int j=d; j>0; j--)
|
||||
s+=".." + separationString;
|
||||
return s+buf;
|
||||
}
|
||||
|
||||
if (gr instanceof Item)
|
||||
i = (Item)gr;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name to the given item relative to given group.
|
||||
*
|
||||
* @since 1.515
|
||||
* @param p the Item we want the relative display name
|
||||
* @param g the ItemGroup used as point of reference for the item
|
||||
* @return
|
||||
* String like "foo » bar"
|
||||
*/
|
||||
public static String getRelativeNameFrom(Item p, ItemGroup g) {
|
||||
return getRelativeNameFrom(p, g, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the relative display name to the given item from the specified group.
|
||||
@@ -985,10 +1046,7 @@ public class Functions {
|
||||
* String like "foo » bar"
|
||||
*/
|
||||
public static String getRelativeDisplayNameFrom(Item p, ItemGroup g) {
|
||||
if (p == null) return null;
|
||||
String relativeName = p.getRelativeNameFrom(g);
|
||||
if (relativeName == null) return null;
|
||||
return relativeName.replace("/", " » ");
|
||||
return getRelativeNameFrom(p, g, true);
|
||||
}
|
||||
|
||||
public static Map<Thread,StackTraceElement[]> dumpAllThreads() {
|
||||
|
||||
Reference in new issue
Block a user