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

Commit

Permalink
Fix bug: % completed should be calculated with words, not messages:ht…
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Sep 29, 2011
1 parent c1d65c2 commit 7845948
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 11 deletions.
Expand Up @@ -2,6 +2,9 @@

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TransUnitWords implements Serializable
{
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -102,4 +105,18 @@ public int getNotApproved()
{
return untranslated + needReview;
}

public int getPer()
{
int total = getTotal();
if (total <= 0)
{
return 0;
}
else
{
double per = 100 * approved / total;
return (int) Math.ceil(per);
}
}
}
Expand Up @@ -94,7 +94,7 @@ public DocumentListView(Resources resources, WebTransMessages messages, UiMessag
this.messages = messages;
filterTextBox = new ClearableTextBox(resources, uiMessages);
nodes = new HashMap<DocumentId, DocumentNode>();
transUnitCountBar = new TransUnitCountBar(messages);
transUnitCountBar = new TransUnitCountBar(messages, true);
dataProvider = new ListDataProvider<DocumentNode>();
this.dispatcher = dispatcher;
this.eventBus = eventBus;
Expand Down
Expand Up @@ -15,6 +15,7 @@
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
Expand Down Expand Up @@ -54,11 +55,14 @@ interface TransUnitCountBarUiBinder extends UiBinder<Widget, TransUnitCountBar>

private boolean isGraph = false;

private boolean statsByWords = false;


@Inject
public TransUnitCountBar(WebTransMessages messages)
public TransUnitCountBar(WebTransMessages messages, boolean statsByWords)
{
this.messages = messages;
this.statsByWords = statsByWords;
tooltipPanel.setStyleName("transUnitCountGraphTooltipPanel");
initWidget(uiBinder.createAndBindUi(this));
initLayoutPanelHandler();
Expand Down Expand Up @@ -87,11 +91,12 @@ public void onMouseOut(MouseOutEvent event)
layoutPanel.sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT);
}

public TransUnitCountBar(WebTransMessages messages, boolean isGraph)
public TransUnitCountBar(WebTransMessages messages, boolean isGraph, boolean statsByWords)
{
tooltipPanel.setStyleName("transUnitCountGraphTooltipPanel");
this.isGraph = isGraph;
this.messages = messages;
this.statsByWords = statsByWords;
}

private void setupLayoutPanel(double undefinedLeft, double undefinedWidth, double approvedLeft, double approvedWidth, double needReviewLeft, double needReviewWidth, double untranslatedLeft, double untranslatedWidth)
Expand All @@ -105,10 +110,21 @@ private void setupLayoutPanel(double undefinedLeft, double undefinedWidth, doubl

public void refresh()
{
int approved = getUnitApproved();
int needReview = getUnitNeedReview();
int untranslated = getUnitUntranslated();
int total = getUnitTotal();
int approved, needReview, untranslated, total;
if (statsByWords)
{
approved = getWordsApproved();
needReview = getWordsNeedReview();
untranslated = getWordsUntranslated();
total = getWordsTotal();
}
else
{
approved = getUnitApproved();
needReview = getUnitNeedReview();
untranslated = getUnitUntranslated();
total = getUnitTotal();
}
int width = getOffsetWidth();
if (total == 0)
{
Expand Down
Expand Up @@ -16,7 +16,7 @@ interface TransUnitCountGraphUiBinder extends UiBinder<Widget, TransUnitCountGra
@Inject
public TransUnitCountGraph(WebTransMessages messages)
{
super(messages, true);
super(messages, true, true);
this.labelFormat = LabelFormat.PERCENT_COMPLETE;
initWidget(uiBinder.createAndBindUi(this));
}
Expand Down
Expand Up @@ -61,7 +61,7 @@ interface TranslationEditorViewUiBinder extends UiBinder<Widget, TranslationEdit
public TranslationEditorView(final WebTransMessages messages, final Resources resources)
{
this.resources = resources;
this.transUnitCountBar = new TransUnitCountBar(messages);
this.transUnitCountBar = new TransUnitCountBar(messages, true);
this.pager = new Pager(messages, resources);

initWidget(uiBinder.createAndBindUi(this));
Expand Down
Expand Up @@ -22,8 +22,8 @@
<div class="translationStatusBar statusBar_needReview" style="width:#{wFuzzy}px;"></div>
<div class="translationStatusBar statusBar_untranslated" style="width:#{wUntranslated}px;"></div>
</div>
<h:outputText value="#{pComplete/100}" rendered="#{status.total > 0}" class="statusBar_percentage">
<f:convertNumber type="percent" />
<h:outputText value="#{status.per/100}" rendered="#{status.total > 0}" class="statusBar_percentage">
<f:convertNumber type="percent"/>
</h:outputText>
<h:outputText rendered="#{status.total eq 0}" class="statusBar_percentage">#{messages['jsf.NoContent']}</h:outputText>
</div>

0 comments on commit 7845948

Please sign in to comment.