-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JENKINS-8958 Code coverage color scheme not suited for color blind users #95
base: master
Are you sure you want to change the base?
Changes from 1 commit
cfe6252
c0d3644
76846bd
5ee28ba
63ba458
7a93266
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
package hudson.plugins.cobertura.targets; | ||
|
||
import hudson.model.AbstractBuild; | ||
import hudson.model.Api; | ||
import hudson.model.Item; | ||
import hudson.model.Run; | ||
import hudson.plugins.cobertura.BuildUtils; | ||
import hudson.plugins.cobertura.Chartable; | ||
import hudson.plugins.cobertura.CoberturaBuildAction; | ||
import hudson.plugins.cobertura.CoverageChart; | ||
import hudson.plugins.cobertura.Ratio; | ||
import hudson.model.*; | ||
import hudson.plugins.cobertura.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is generally preferable to avoid it in the production code, because there is a risk of ambiguity if one of the packages introduces a competing class. |
||
import hudson.util.Graph; | ||
import hudson.util.TextFile; | ||
|
||
|
@@ -29,6 +22,7 @@ | |
import java.util.TreeMap; | ||
import java.util.TreeSet; | ||
|
||
import jenkins.model.Jenkins; | ||
import org.jfree.chart.JFreeChart; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import org.kohsuke.stapler.StaplerResponse; | ||
|
@@ -47,6 +41,9 @@ | |
@ExportedBean(defaultVisibility = 2) | ||
public class CoverageResult implements Serializable, Chartable { | ||
|
||
private static final String DEFAULT_CSS_FILE = "style.css"; | ||
private static final String COLOR_BLIND_CSS_FILE = "style-color-blind.css"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think these two constants are being used anymore |
||
|
||
/** | ||
* Generated | ||
*/ | ||
|
@@ -504,4 +501,19 @@ public Map<String, CoveragePaint> getPaintedSources() { | |
public Api getApi() { | ||
return new Api(this); | ||
} | ||
|
||
/** | ||
* | ||
* @return css file name according to the config of color blind mode | ||
*/ | ||
public String getCssFileName() { | ||
Descriptor descriptor = Jenkins.getInstance().getDescriptor(CoberturaPublisher.class); | ||
if(descriptor instanceof CoberturaPublisher.DescriptorImpl) { | ||
CoberturaPublisher.DescriptorImpl d = (CoberturaPublisher.DescriptorImpl) descriptor; | ||
if(d.getColorBlindMode()) { | ||
return COLOR_BLIND_CSS_FILE; | ||
} | ||
} | ||
return DEFAULT_CSS_FILE; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form"> | ||
|
||
<f:section title="${%Cobertura}"> | ||
<f:entry title="${%Color Blind Mode}" field="cobertura.colorBlindMode"> | ||
<f:checkbox checked="${instance.colorBlindMode}"/> | ||
</f:entry> | ||
</f:section> | ||
|
||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
table.source { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern with duplicating the entire css file is that anyone wanting to change the layout would have to change in two places (and might miss this one). Looking at the layout control https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/lib/layout/layout.jelly#L46-L49 I see the This suggests a slightly different approach, which would be to move the css path into a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, You are right. Thanks for your advice :) |
||
border-style: solid; | ||
border-color: #bbb; | ||
border-spacing: 0; | ||
border-collapse: collapse; | ||
border-width: 1px; | ||
width: 100%; | ||
} | ||
|
||
table.source td { | ||
border-style: solid; | ||
border-color: #bbb; | ||
border-spacing: 0; | ||
border-collapse: collapse; | ||
border-width: 0px 0px 0px 0px; | ||
padding-left: 0.2em; | ||
padding-right: 0.2em; | ||
font-family: monospace; | ||
} | ||
|
||
table.source .text { | ||
margin-top: -1px; | ||
} | ||
|
||
table.source td.line { | ||
text-align: right; | ||
border-width: 0px 1px 0px 0px; | ||
} | ||
|
||
table.source td.hits { | ||
text-align: right; | ||
border-width: 0px 1px 0px 0px; | ||
} | ||
|
||
table.source th { | ||
padding-left: 0.5em; | ||
font-weight: bold; | ||
font-family: serif; | ||
background-color: #f0f0f0; | ||
border-width: 1px 1px 1px 1px; | ||
text-align: left; | ||
} | ||
|
||
table.source tr.coverFull { | ||
background-color: #dfd; | ||
} | ||
|
||
table.source tr.coverPart { | ||
background-color: #ffd; | ||
} | ||
|
||
table.source tr.coverPart td.hits, table.source tr.coverNone td.hits { | ||
font-weight: bold; | ||
} | ||
|
||
table.source tr.coverNone { | ||
background-color: #fdd; | ||
} | ||
|
||
table.source tr.noCover { | ||
background-color: #fff; | ||
} | ||
|
||
div.percentgraph { | ||
background-color: #f0e442; | ||
border: #808080 1px solid; | ||
height: 1.3em; | ||
margin: 0px; | ||
padding: 0px; | ||
width: 100px; | ||
} | ||
|
||
div.percentgraph div.greenbar { | ||
background-color: #0072b2; | ||
height: 1.3em; | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
|
||
div.percentgraph div.na { | ||
background-color: #eaeaea; | ||
height: 1.3em; | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
|
||
div.percentgraph span.text { | ||
display: block; | ||
text-align: center; | ||
position: absolute; | ||
width: 100px; | ||
color: #000 | ||
} | ||
|
||
table.percentgraph { | ||
border: 0px; | ||
font-size: 130%; | ||
margin: 0px; | ||
margin-left: 0px; | ||
margin-right: 0px; | ||
padding: 0px; | ||
text-align: left; | ||
} | ||
|
||
table.percentgraph tr.percentgraph { | ||
border: 0px; | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
|
||
table.percentgraph td.percentgraph { | ||
border: 0px; | ||
margin: 0px; | ||
padding: 0px; | ||
padding-left: 4px; | ||
} | ||
|
||
table.percentgraph td.data { | ||
text-align: right; | ||
} | ||
.center { | ||
text-align: center; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it actually used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment of
Descriptor
saidDescriptor can persist data just by storing them in fields. However, it is the responsibility of the derived type to properly invoke save() and load().
So I call
save()
inconfigure()
to persist global configuration. And the comment ofload()
saidThe constructor of the derived class must call this method. (If we do that in the base class, the derived class won't get a chance to set default values.)
. So I follow the comment to implemented its two constructors and call load method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It provides a config setting on the Jenkins global settings page: