Mercurial > hg > release > icedtea-web-1.4
changeset 690:c5db48847b93
Splashscreen now strip commit id from released versions
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Thu, 25 Apr 2013 14:20:19 +0200 |
parents | 5c5709590a9d |
children | ca33c41c9f69 |
files | ChangeLog netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java |
diffstat | 3 files changed, 43 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Apr 24 11:06:49 2013 -0400 +++ b/ChangeLog Thu Apr 25 14:20:19 2013 +0200 @@ -1,3 +1,14 @@ +2013-04-19 Jiri Vanek <jvanek@redhat.com> + + Splashscreen now strip commit id from released versions + * netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java: + (stripCommitFromVersion) new method responsible for cutting + (drawBase) now using stripCommitFromVersion before printing drawing version + to splashscreen + * tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java: + (stripCommitFromVersion) new test for + + 2013-04-24 Adam Domurad <adomurad@redhat.com> * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java:
--- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java Wed Apr 24 11:06:49 2013 -0400 +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java Thu Apr 25 14:20:19 2013 +0200 @@ -371,6 +371,17 @@ return tt; } + static String stripCommitFromVersion(String version) { + if (version.contains("pre+")) { + return version; + } + int i = version.indexOf("+"); + if (i < 0) { + return version; + } + return version.substring(0, version.indexOf("+")); + } + private final class MovingTextRunner extends Observable implements Runnable { private static final int MAX_ANIMATION_VALUE = 10000; @@ -499,11 +510,12 @@ g2d.setColor(plainTextColor); FontMetrics fm = g2d.getFontMetrics(); if (version != null) { - int y = master.getSplashWidth() - fm.stringWidth(version + " "); + String niceVersion=stripCommitFromVersion(version); + int y = master.getSplashWidth() - fm.stringWidth(niceVersion + " "); if (y < 0) { y = 0; } - g2d.drawString(version, y, fm.getHeight()); + g2d.drawString(niceVersion, y, fm.getHeight()); } return fm; }
--- a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java Wed Apr 24 11:06:49 2013 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java Thu Apr 25 14:20:19 2013 +0200 @@ -105,4 +105,22 @@ } + + @Test + public void stripCommitFromVersion() { + Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4")); + Assert.assertEquals("1.4.2", BasePainter.stripCommitFromVersion("1.4.2")); + Assert.assertEquals("1.4pre", BasePainter.stripCommitFromVersion("1.4pre")); + Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+657tgkhyu4iy5")); + Assert.assertEquals("1.4.2", BasePainter.stripCommitFromVersion("1.4.2+887tgjh07tftvhjj")); + Assert.assertEquals("1.4pre+0977tyugg", BasePainter.stripCommitFromVersion("1.4pre+0977tyugg")); + + Assert.assertEquals("1.4pre+", BasePainter.stripCommitFromVersion("1.4pre+")); + Assert.assertEquals("1.4pre+foo+", BasePainter.stripCommitFromVersion("1.4pre+foo+")); + Assert.assertEquals("1.4pre+foo+bar", BasePainter.stripCommitFromVersion("1.4pre+foo+bar")); + + Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+")); + Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+foo+")); + Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+foo+bar")); + } }