Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-13491] Center the affected source line in source view.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Apr 27, 2012
1 parent bfc36fa commit 735e374
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
Expand Up @@ -314,6 +314,15 @@ public final int getPrimaryLineNumber() {
return primaryLineNumber;
}

/**
* Returns the line number that should be shown on top of the source code view.
*
* @return the line number
*/
public final int getLinkLineNumber() {
return Math.max(1, primaryLineNumber - 10);
}

/**
* Adds another line range to this annotation.
*
Expand Down
@@ -1,17 +1,12 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:local="local">
xmlns:i="jelly:fmt" xmlns:local="local" xmlns:u="/util">
<st:header name="Content-Type" value="text/html;charset=UTF-8" />
<j:forEach var="warning" items="${annotations.sortedAnnotations}">
<table class="pane" id="details">
<tr>
<td class="pane-header">
<j:choose>
<j:when test="${warning.canDisplayFile(it.owner)}">
<a href="source.${warning.key}/#${warning.primaryLineNumber}">${warning.shortFileName}:${warning.primaryLineNumber}</a>
</j:when>
<j:otherwise>${warning.shortFileName}:${warning.primaryLineNumber}</j:otherwise>
</j:choose>,
<u:sourceLink it="${it}" warning="${warning}"/>,
${warning.type}, ${%Priority}: ${warning.priority.localizedString}
<j:if test="${h.size2(warning.category) > 0}">
, ${%Category}: ${warning.category}
Expand Down
@@ -1,5 +1,5 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util"
xmlns:i="jelly:fmt" xmlns:local="local">
<st:header name="Content-Type" value="text/html;charset=UTF-8" />
<table class="pane sortable" id="warnings">
Expand All @@ -21,12 +21,7 @@
<tr>
<td class="pane">
<div tooltip="${warning.message}">
<j:choose>
<j:when test="${warning.canDisplayFile(it.owner)}">
<a href="source.${warning.key}/#${warning.primaryLineNumber}">${warning.shortFileName}</a>
</j:when>
<j:otherwise>${warning.shortFileName}</j:otherwise>
</j:choose>
<u:sourceLink it="${it}" warning="${warning}"/>
</div>
</td>
<j:if test="${it.container.modules.size() > 1}">
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/util/sourceLink.jelly
@@ -0,0 +1,19 @@
<!--
Section header
<%@attribute name="it" required="true" %>
<%@attribute name="warning" required="true" %>
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"
xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson"
xmlns:f="/lib/form" xmlns:u="/util">

<j:choose>
<j:when test="${warning.canDisplayFile(it.owner)}">
<a href="source.${warning.key}/#${warning.linkLineNumber}">${warning.shortFileName}:${warning.primaryLineNumber}</a>
</j:when>
<j:otherwise>${warning.shortFileName}:${warning.primaryLineNumber}</j:otherwise>
</j:choose>

</j:jelly>

0 comments on commit 735e374

Please sign in to comment.