提交 8e9a8d90 编写于 作者: K kohsuke

improving the UI.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3588 71c3de6d-444a-0410-be80-ed276b4c234a
上级 6a0366e4
......@@ -9,6 +9,8 @@ import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
/**
* A particular combination of {@link Axis} values.
......@@ -98,6 +100,39 @@ public final class Combination extends TreeMap<String,String> implements Compara
return new Combination(m);
}
/**
* Creates compact string representataion suitable for display purpose.
*
* <p>
* The string is made compact by looking for {@link Axis} whose values
* are unique, and omit the axis name.
*/
public String toCompactString(AxisList axes) {
Set<String> nonUniqueAxes = new HashSet<String>();
Map<String,Axis> axisByValue = new HashMap<String,Axis>();
for (Axis a : axes) {
for (String v : a.values) {
Axis old = axisByValue.put(v,a);
if(old!=null) {
// these two axes have colliding values
nonUniqueAxes.add(old.name);
nonUniqueAxes.add(a.name);
}
}
}
StringBuilder buf = new StringBuilder();
for (Map.Entry<String,String> e : entrySet()) {
if(buf.length()>0) buf.append(',');
if(nonUniqueAxes.contains(e.getKey()))
buf.append(e.getKey()).append('=');
buf.append(e.getValue());
}
if(buf.length()==0) buf.append("default"); // special case to avoid 0-length name.
return buf.toString();
}
// read-only
public void clear() {
throw new UnsupportedOperationException();
......
......@@ -20,6 +20,8 @@ import hudson.model.Descriptor;
import java.io.IOException;
import java.util.Map;
import org.kohsuke.stapler.export.Exported;
/**
* One configuration of {@link MatrixProject}.
*
......@@ -58,6 +60,11 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
return nb;
}
@Override
public String getDisplayName() {
return combination.toCompactString(getParent().getAxes());
}
public MatrixProject getParent() {
return (MatrixProject)super.getParent();
}
......@@ -116,6 +123,11 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
return Hudson.getInstance().getLabel(combination.get("label"));
}
@Override
public String getPronoun() {
return "Configuration";
}
@Override
public JDK getJDK() {
return Hudson.getInstance().getJDK(combination.get("jdk"));
......
......@@ -33,7 +33,7 @@ import java.util.Collection;
* @author Kohsuke Kawaguchi
* @see Items
*/
public interface Item extends PersistenceRoot {
public interface Item extends PersistenceRoot, ModelObject {
/**
* Gets the parent that contains this item.
*/
......@@ -70,6 +70,20 @@ public interface Item extends PersistenceRoot {
*/
String getFullName();
/**
* Gets the human readable short name of this item.
*
* <p>
* This method should try to return a short concise human
* readable string that describes this item.
* The string need not be unique.
*
* <p>
* The returned string should not include the display names
* of {@link #getParent() ancestor items}.
*/
String getDisplayName();
/**
* Returns the URL of this item relative to the context root of the application.
*
......
......@@ -502,7 +502,7 @@ public class Queue {
* to collapse two tasks into one. This is used to avoid infinite
* queue backlog.
*/
public interface Task {
public interface Task extends ModelObject {
/**
* If this task needs to be run on a node with a particular label,
* return that {@link Label}. Otherwise null, indicating
......@@ -531,8 +531,8 @@ public class Queue {
String getWhyBlocked();
/**
* Human readable name of this task.
* Used for display purpose.
* Unique name of this task.
* @see hudson.model.Item#getName()
*/
String getName();
......
......@@ -31,7 +31,7 @@
<tr>
<td class="pane" width="100%" tooltip="${item.why}">
<a href="${rootURL}/${item.task.url}">
${item.task.name}
${item.task.displayName}
</a>
</td>
<td class="pane" width="16" align="center" valign="middle">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册