提交 c27f8733 编写于 作者: K kohsuke

improved the formatting


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6721 71c3de6d-444a-0410-be80-ed276b4c234a
上级 05d9d634
package hudson;
import hudson.model.TaskListener;
import hudson.model.Hudson;
import hudson.util.IOException2;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.taskdefs.Chmod;
import org.apache.tools.ant.taskdefs.Copy;
import org.kohsuke.stapler.Stapler;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
......@@ -610,6 +612,17 @@ public class Util {
return createFileSet(baseDir,includes,null);
}
/**
* Wraps with the error icon and the CSS class to render error message.
* @since 1.173
*/
public static String wrapToErrorSpan(String s) {
s = "<span class=error><img src='"+
Stapler.getCurrentRequest().getContextPath()+ Hudson.RESOURCE_PATH+
"/images/none.gif' height=16 width=1>"+s+"</span>";
return s;
}
public static final SimpleDateFormat XS_DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// Note: RFC822 dates must not be localized!
......
package hudson.node_monitors;
import hudson.FilePath;
import hudson.Util;
import hudson.FilePath.FileCallable;
import hudson.model.Computer;
import hudson.model.Descriptor;
......@@ -35,7 +36,7 @@ public class DiskSpaceMonitor extends NodeMonitor {
space/=1024L; // convert to MB
if(space<1024) {
// less than a GB
return "<span class=error>"+new BigDecimal(space).scaleByPowerOfTen(-3).toPlainString()+"GB<span>";
return Util.wrapToErrorSpan(new BigDecimal(space).scaleByPowerOfTen(-3).toPlainString());
}
return space/1024+"GB";
......
......@@ -2,9 +2,12 @@ package hudson.util;
import hudson.Util;
import hudson.model.Node;
import hudson.model.Hudson;
import java.io.IOException;
import org.kohsuke.stapler.Stapler;
/**
* Represents a clock difference. Immutable.
*
......@@ -57,7 +60,8 @@ public final class ClockDifference {
public String toHtml() {
String s = toString();
if(isDangerous()) s = "<span class=error>"+s+"</span>";
if(isDangerous())
s = Util.wrapToErrorSpan(s);
return s;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册