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

Commit

Permalink
unify display of list of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Oct 16, 2012
1 parent 341c714 commit 5a8cbec
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 47 deletions.
Expand Up @@ -3,11 +3,13 @@
import java.util.List;

import org.zanata.webtrans.client.resources.UiMessages;
import org.zanata.webtrans.client.ui.TranslationDisplay;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
Expand All @@ -19,6 +21,7 @@
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
Expand Down Expand Up @@ -51,9 +54,9 @@ interface TMIUiBinder extends UiBinder<DialogBox, TransMemoryDetailsView>
@UiField
ListBox documentListBox;
@UiField
HTMLPanel sourceTextContainer;
SimplePanel sourceTextContainer;
@UiField
HTMLPanel targetTextContainer;
SimplePanel targetTextContainer;

@Inject
public TransMemoryDetailsView(UiMessages messages)
Expand Down Expand Up @@ -125,21 +128,15 @@ public void clearSourceAndTarget()
@Override
public void setSource(List<String> sourceContents)
{
for (String sourceContent : sourceContents)
{
InlineHTML source = new InlineHTML(sourceContent);
sourceTextContainer.add(source);
}
SafeHtml safeHtml = TranslationDisplay.asSyntaxHighlight(sourceContents).toSafeHtml();
sourceTextContainer.setWidget(new InlineHTML(safeHtml));
}

@Override
public void setTarget(List<String> targetContents)
{
for (String targetContent : targetContents)
{
InlineHTML target = new InlineHTML(targetContent);
targetTextContainer.add(target);
}
SafeHtml safeHtml = TranslationDisplay.asSyntaxHighlight(targetContents).toSafeHtml();
targetTextContainer.setWidget(new InlineHTML(safeHtml));
}

@UiHandler("dismissButton")
Expand Down
Expand Up @@ -12,10 +12,8 @@
float: right;
}

.content span {
display: block;
border: thin dotted #808080;
margin-top: 5px;
.content {
background-color: #ffffff;
padding: 2px;
}

Expand Down Expand Up @@ -63,7 +61,7 @@
<g:Label styleName="headerLabel" text="Source:"/>
</g:customCell>
<g:customCell>
<g:HTMLPanel ui:field="sourceTextContainer" styleName="{style.content}" />
<g:SimplePanel ui:field="sourceTextContainer" styleName="{style.content}" />
</g:customCell>
</g:row>
<g:row>
Expand All @@ -79,7 +77,7 @@
<g:Label styleName="headerLabel" text="Target:"/>
</g:customCell>
<g:customCell>
<g:HTMLPanel ui:field="targetTextContainer" styleName="{style.content}"/>
<g:SimplePanel ui:field="targetTextContainer" styleName="{style.content}"/>
</g:customCell>
</g:row>
<g:row>
Expand Down
Expand Up @@ -11,9 +11,12 @@
import org.zanata.webtrans.client.ui.EnumListBox;
import org.zanata.webtrans.client.ui.HighlightingLabel;
import org.zanata.webtrans.client.ui.SearchTypeRenderer;
import org.zanata.webtrans.client.ui.TranslationDisplay;
import org.zanata.webtrans.shared.model.TransMemoryResultItem;
import org.zanata.webtrans.shared.rpc.HasSearchType.SearchType;

import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.ClickEvent;
Expand All @@ -22,6 +25,7 @@
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
Expand All @@ -32,8 +36,10 @@
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.InlineHTML;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.ValueListBox;
import com.google.gwt.user.client.ui.Widget;
Expand Down Expand Up @@ -82,8 +88,6 @@ interface Styles extends CssResource
private final UiMessages messages;
private final DiffColorLegendPanel diffLegendPanel;

private final InlineLabel diffLegendInfo;

private TranslationMemoryDisplay.Listener listener;

private final static int SOURCE_COL = 0;
Expand All @@ -94,7 +98,7 @@ interface Styles extends CssResource
private final static int DETAILS_COL = 5;

@Inject
public TransMemoryView(final UiMessages messages, SearchTypeRenderer searchTypeRenderer, final Resources resources, final DiffColorLegendPanel diffLegendPanel)
public TransMemoryView(final UiMessages messages, SearchTypeRenderer searchTypeRenderer, final DiffColorLegendPanel diffLegendPanel)
{
this.messages = messages;
this.diffLegendPanel = diffLegendPanel;
Expand All @@ -113,7 +117,7 @@ public TransMemoryView(final UiMessages messages, SearchTypeRenderer searchTypeR
formatter.setStyleName(0, SIMILARITY_COL, "th centered similarityCol");
formatter.setStyleName(0, DETAILS_COL, "th centered detailCol");

diffLegendInfo = new InlineLabel();
InlineLabel diffLegendInfo = new InlineLabel();
diffLegendInfo.setStyleName("icon-info-circle-2 details");
diffLegendInfo.setTitle(messages.colorLegend());

Expand Down Expand Up @@ -229,44 +233,55 @@ public void clearTableContent()
}
}

private FlowPanel getSourcePanel(TransMemoryResultItem object, List<String> queries)
private SimplePanel getSourcePanel(TransMemoryResultItem object, List<String> queries)
{
FlowPanel panel = new FlowPanel();
SimplePanel panel = new SimplePanel();
panel.setSize("100%", "100%");
ArrayList<String> sourceContents = object.getSourceContents();

// display multiple source strings
ArrayList<String> queriesPadded = Lists.newArrayList();
for (int i = 0; i < sourceContents.size(); i++)
{
String sourceContent = sourceContents.get(i);
String query;
if (queries.size() > i)
{
query = queries.get(i);
queriesPadded.add(queries.get(i));
}
else
{
query = queries.get(0);
queriesPadded.add(queries.get(0));
}
DiffMatchPatchLabel label = new DiffMatchPatchLabel();
label.setOriginal(query);
label.setText(sourceContent);
panel.add(label);
}
SafeHtml safeHtml = TranslationDisplay.asDiff(queriesPadded, sourceContents).toSafeHtml();
panel.setWidget(new InlineHTML(safeHtml));
//
// for (int i = 0; i < sourceContents.size(); i++)
// {
// String sourceContent = sourceContents.get(i);
// String query;
// if (queries.size() > i)
// {
// query = queries.get(i);
// }
// else
// {
// query = queries.get(0);
// }
// DiffMatchPatchLabel label = new DiffMatchPatchLabel();
// label.setOriginal(query);
// label.setText(sourceContent);
// panel.add(label);
// }
return panel;
}

private FlowPanel getTargetPanel(TransMemoryResultItem object)
private SimplePanel getTargetPanel(TransMemoryResultItem object)
{
FlowPanel panel = new FlowPanel();
SimplePanel panel = new SimplePanel();
panel.setSize("100%", "100%");
// display multiple target strings
for (String targetContent : object.getTargetContents())
{
HighlightingLabel label = new HighlightingLabel();
label.setText(targetContent);
panel.add(label);
}
SafeHtml safeHtml = TranslationDisplay.asSyntaxHighlight(object.getTargetContents()).toSafeHtml();
panel.setWidget(new InlineHTML(safeHtml));
return panel;
}

Expand Down
Expand Up @@ -553,13 +553,6 @@ td.ApprovedStateDecoration div div div
background:#F3F7FB;
}

.translationContainer .resultTable pre {
border: 1px dotted #C9C9C9;
margin-top: 2px;
padding: 2px;
margin-bottom: 2px;
}

.resultTable tr:first-child:hover
{
background:none;
Expand Down

0 comments on commit 5a8cbec

Please sign in to comment.