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

Commit

Permalink
Merge pull request #217 from zanata/fix-stats-ui
Browse files Browse the repository at this point in the history
fix statistics display after api change
  • Loading branch information
Alex Eng committed Oct 8, 2013
2 parents a94da4d + 6ed82d9 commit 6905843
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Expand Up @@ -21,16 +21,13 @@ public interface WebTransMessages extends Messages {
@DefaultMessage("(No Content)")
String noContent();

@DefaultMessage("{0}% ({1,number,#.#}hrs) {2}")
String statusBarPercentageHrs(double approved, double remainingHours,
@DefaultMessage("{0} ({1,number,#.#}hrs) {2}")
String statusBarPercentageHrs(String approved, double remainingHours,
String by);

@DefaultMessage("{0,number,#.#}")
String statusBarLabelHours(double remainingHours);

@DefaultMessage("{0}%")
String statusBarLabelPercentage(double approved);

@DefaultMessage("http://zanata.org/")
String hrefHelpLink();

Expand Down
@@ -1,5 +1,6 @@
package org.zanata.webtrans.client.ui;

import com.google.gwt.i18n.client.NumberFormat;
import org.zanata.common.LocaleId;
import org.zanata.rest.dto.stats.ContainerTranslationStatistics;
import org.zanata.rest.dto.stats.TranslationStatistics;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class TransUnitCountBar extends Composite implements

protected final TooltipPopupPanel tooltipPanel;
private static final int TOTAL_WIDTH = 100;
private final NumberFormat percentFormat = NumberFormat.getPercentFormat();

interface TransUnitCountBarUiBinder extends
UiBinder<Widget, TransUnitCountBar> {
Expand Down Expand Up @@ -169,31 +171,35 @@ public void refresh() {
}

private void setLabelText() {
// TODO rhbz953734 - remaining hours
switch (labelFormat) {
case PERCENT_COMPLETE_HRS:
TranslationStatistics wordStats =
stats.getStats(localeId.getId(), StatUnit.WORD);
if (statsByWords) {
label.setText(messages.statusBarPercentageHrs(
wordStats.getPercentTranslated(),
percentFormat.format(
wordStats.getPercentTranslated() / 100),
wordStats.getRemainingHours(), "Words"));
} else {
TranslationStatistics msgStats =
stats.getStats(localeId.getId(), StatUnit.MESSAGE);
label.setText(messages.statusBarPercentageHrs(
msgStats.getPercentTranslated(),
percentFormat.format(
msgStats.getPercentTranslated() / 100),
wordStats.getRemainingHours(), "Msg"));
}
break;
case PERCENT_COMPLETE:
if (statsByWords) {
label.setText(messages.statusBarLabelPercentage(stats.getStats(
localeId.getId(), StatUnit.WORD).getPercentTranslated()));
double wordTranslatedProportion = stats
.getStats(localeId.getId(), StatUnit.WORD)
.getPercentTranslated() / 100;
label.setText(percentFormat.format(wordTranslatedProportion));
} else {
label.setText(messages.statusBarLabelPercentage(stats.getStats(
localeId.getId(), StatUnit.MESSAGE)
.getPercentTranslated()));
double messageTranslatedProportion = stats
.getStats(localeId.getId(), StatUnit.MESSAGE)
.getPercentTranslated() / 100;
label.setText(percentFormat.format(messageTranslatedProportion));
}
break;
default:
Expand Down

0 comments on commit 6905843

Please sign in to comment.