Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix wrong indent in file, extract statistic util to seperate class
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 31, 2013
1 parent e071060 commit 7cb9d06
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
46 changes: 46 additions & 0 deletions zanata-war/src/main/java/org/zanata/ui/StatisticBar.java
@@ -0,0 +1,46 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.ui;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.zanata.util.StatisticsUtil;

/**
* Handles formatting of statistic bar for remaining hours and percentage
*
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
*/
@Name("statisticBar")
@Scope(ScopeType.STATELESS)
@AutoCreate
public class StatisticBar {

public String formatPercentage(double percentage) {
return StatisticsUtil.formatPercentage(percentage);
}

public String formatHours(double hours) {
return StatisticsUtil.formatHours(hours);
}
}
9 changes: 1 addition & 8 deletions zanata-war/src/main/java/org/zanata/util/StatisticsUtil.java
@@ -1,20 +1,13 @@
package org.zanata.util;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.zanata.common.AbstractTranslationCount;
import org.zanata.common.ContentState;

import java.io.Serializable;

/**
* @author Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
@Name("statisticsUtil")
@Scope(ScopeType.APPLICATION)
public class StatisticsUtil implements Serializable {
public class StatisticsUtil {

public static int calculateUntranslated(Long totalCount,
AbstractTranslationCount translationCount) {
Expand Down
Expand Up @@ -251,8 +251,8 @@ String replacedTextInMultipleTextFlows(String searchText,
"other|=0", "Items can not be undone"
// @formatter:on
})
String undoUnsuccessful(@PluralCount int unsuccessfulCount,
@PluralCount int successfulCount);
String undoUnsuccessful(@PluralCount int unsuccessfulCount,
@PluralCount int successfulCount);

@DefaultMessage("Undo failed")
String undoFailure();
Expand Down
13 changes: 3 additions & 10 deletions zanata-war/src/main/webapp/WEB-INF/layout/statsbar.xhtml
Expand Up @@ -4,14 +4,7 @@
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.org/schema/seam/taglib">
<script>
function formatPercentage(percent) {
return Math.floor(percent);
}
function formatHours(hours) {
return Math.ceil(hours * 100) / 100;
}
</script>


<ui:param name="approved" value="#{status.approved}"/>
<ui:param name="translated" value="#{status.translatedOnly}"/>
Expand Down Expand Up @@ -53,11 +46,11 @@
<span class="statusBar_percentage">

<h:outputText
value="#{statisticsUtil.formatPercentage(status.percentTranslated)}%"
value="#{statisticBar.formatPercentage(status.percentTranslated)}%"
rendered="#{status.total > 0}"/>
(
<h:outputText
value="#{statisticsUtil.formatHours(status.remainingHours)}"/>
value="#{statisticBar.formatHours(status.remainingHours)}"/>
#{messages['jsf.stats.ShortHoursSuffix']}
)
</span>
Expand Down

0 comments on commit 7cb9d06

Please sign in to comment.