diff --git a/core/src/main/java/hudson/slaves/OfflineCause.java b/core/src/main/java/hudson/slaves/OfflineCause.java index b427b713316757096f144e0c46c8cf9f73130c7c..41319f01e92a1b60f34aa827db30f5208b21f11c 100644 --- a/core/src/main/java/hudson/slaves/OfflineCause.java +++ b/core/src/main/java/hudson/slaves/OfflineCause.java @@ -29,10 +29,11 @@ import hudson.Functions; import hudson.model.Computer; import hudson.model.User; -import org.acegisecurity.Authentication; import org.jvnet.localizer.Localizable; import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.export.Exported; + +import javax.annotation.Nonnull; import java.util.Date; /** @@ -42,32 +43,51 @@ import java.util.Date; *

* {@link OfflineCause} must have cause.jelly that renders a cause * into HTML. This is used to tell users why the node is put offline. - * This view should render a block element like DIV. + * This view should render a block element like DIV. * * @author Kohsuke Kawaguchi * @since 1.320 */ @ExportedBean public abstract class OfflineCause { + protected final long timestamp = System.currentTimeMillis(); + + /** + * Timestamp in which the event happened. + * + * @since 1.612 + */ + @Exported + public long getTimestamp() { + return timestamp; + } + + /** + * Same as {@link #getTimestamp()} but in a different type. + * + * @since 1.612 + */ + public final @Nonnull Date getTime() { + return new Date(timestamp); + } + /** * {@link OfflineCause} that renders a static text, * but without any further UI. */ public static class SimpleOfflineCause extends OfflineCause { public final Localizable description; - public final Date timestamp; /** * @since 1.571 */ protected SimpleOfflineCause(Localizable description) { this.description = description; - this.timestamp = new Date(); } @Exported(name="description") @Override public String toString() { - return "[" + timestamp.toString() + "] " + description.toString(); + return description.toString(); } } diff --git a/core/src/main/resources/hudson/slaves/OfflineCause/cause.jelly b/core/src/main/resources/hudson/slaves/OfflineCause/cause.jelly index 414f642c0cc865bc5b6f85ee08de64bbbecd6419..a6676efe9f1f099762779b6bb4e093f15d6f58cb 100644 --- a/core/src/main/resources/hudson/slaves/OfflineCause/cause.jelly +++ b/core/src/main/resources/hudson/slaves/OfflineCause/cause.jelly @@ -23,6 +23,13 @@ THE SOFTWARE. --> - -

+ +
+
+ +
+
+ +
+