Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rhbz844820 - change source content panel to use code mirror

  • Loading branch information...
commit bdcd6e33f6e7ce30762c9884813693fab3744c78 1 parent 0c655dd
Patrick Huang huangp authored
1  zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/SourceContentsDisplay.java
View
@@ -23,4 +23,5 @@
void setSourceSelectionHandler(ClickHandler clickHandler);
+ void refresh();
}
9 zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/SourceContentsView.java
View
@@ -121,6 +121,15 @@ public void setSourceSelectionHandler(ClickHandler clickHandler)
}
@Override
+ public void refresh()
+ {
+ for (HasSelectableSource hasSelectableSource : sourcePanelList)
+ {
+ hasSelectableSource.refresh();
+ }
+ }
+
+ @Override
public TransUnitId getId()
{
return transUnitId;
64 zanata-war/src/main/java/org/zanata/webtrans/client/ui/CodeMirrorReadOnlyWidget.java
View
@@ -0,0 +1,64 @@
+package org.zanata.webtrans.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.TextAreaElement;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.HasText;
+import com.google.gwt.user.client.ui.Widget;
+
+public class CodeMirrorReadOnlyWidget extends Composite implements HasText
+{
+ private static CodeMirrorWidgetUiBinder ourUiBinder = GWT.create(CodeMirrorWidgetUiBinder.class);
+
+ @UiField
+ TextAreaElement textArea;
+
+ private JavaScriptObject codeMirror;
+ private String content;
+
+ public CodeMirrorReadOnlyWidget()
+ {
+ initWidget(ourUiBinder.createAndBindUi(this));
+ }
+
+ // see http://codemirror.net/doc/manual.html#usage
+ public native JavaScriptObject initCodeMirror(Element element) /*-{
+ var self = this;
+ var codeMirrorEditor = $wnd.CodeMirror.fromTextArea(element, {
+ lineNumbers: true,
+ lineWrapping: true,
+ mode: "htmlmixed",
+ readOnly: "nocursor"
+ });
+ return codeMirrorEditor;
+
+ }-*/;
+
+ @Override
+ public String getText()
+ {
+ return content;
+ }
+
+ @Override
+ public void setText(String text)
+ {
+ textArea.setValue(text);
+ codeMirror = initCodeMirror(textArea);
+ content = text;
+ }
+
+ public native void refresh() /*-{
+ var codeMirror = this.@org.zanata.webtrans.client.ui.CodeMirrorReadOnlyWidget::codeMirror;
+ codeMirror.refresh();
+ }-*/;
+
+ interface CodeMirrorWidgetUiBinder extends UiBinder<Widget, CodeMirrorReadOnlyWidget>
+ {
+ }
+}
6 zanata-war/src/main/java/org/zanata/webtrans/client/ui/CodeMirrorReadOnlyWidget.ui.xml
View
@@ -0,0 +1,6 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel width="100%">
+ <textarea ui:field="textArea" rows="0" cols="0" />
+ </g:HTMLPanel>
+</ui:UiBinder>
2  zanata-war/src/main/java/org/zanata/webtrans/client/ui/HasSelectableSource.java
View
@@ -7,4 +7,6 @@
String getSource();
void setSelected(boolean selected);
+
+ void refresh();
}
17 zanata-war/src/main/java/org/zanata/webtrans/client/ui/SourcePanel.java
View
@@ -54,9 +54,6 @@
HorizontalPanel container;
@UiField
- HighlightingLabel highlightingLabel;
-
- @UiField
RadioButton selectButton;
@UiField
@@ -64,6 +61,8 @@
@UiField
Styles style;
+ @UiField
+ CodeMirrorReadOnlyWidget sourceContent;
private String source = "";
@@ -77,8 +76,8 @@ public void setValue(String source, String sourceComment, boolean isPlural)
{
this.source = source;
- highlightingLabel.setText(source);
- highlightingLabel.setTitle(messages.sourceCommentLabel(sourceComment));
+ sourceContent.setText(source);
+ sourceContent.setTitle(messages.sourceCommentLabel(sourceComment));
if (!isPlural)
{
@@ -112,8 +111,14 @@ public void setSelected(boolean selected)
}
}
+ @Override
+ public void refresh()
+ {
+ sourceContent.refresh();
+ }
+
public void highlightSearch(String search)
{
- highlightingLabel.highlightSearch(search);
+ // TODO need to highlight search term
}
}
17 zanata-war/src/main/java/org/zanata/webtrans/client/ui/SourcePanel.ui.xml
View
@@ -7,23 +7,24 @@
<ui:style type="org.zanata.webtrans.client.ui.SourcePanel.Styles">
.selectedRow {
- border: 1px solid #E0E8EE;
- padding-top: 3px;
- padding-bottom: 3px;
+ background-color: #add8e6;
+ padding: 3px;
}
.nonSelectedRow {
- border: 0px;
- padding-top: 3px;
- padding-bottom: 3px;
+ background-color: inherit;
+ padding: 3px;
}
</ui:style>
<g:HorizontalPanel width="100%" height="100%" styleName="{style.nonSelectedRow}" ui:field="container">
<g:cell horizontalAlignment="ALIGN_LEFT">
- <fui:HighlightingLabel ui:field="highlightingLabel"
- stylePrimaryName="TableEditorContent" />
+ <g:HTMLPanel>
+ <!--<fui:HighlightingLabel ui:field="highlightingLabel" stylePrimaryName="TableEditorContent"/>-->
+
+ <fui:CodeMirrorReadOnlyWidget ui:field="sourceContent" />
+ </g:HTMLPanel>
</g:cell>
<g:cell horizontalAlignment="ALIGN_RIGHT">
<g:RadioButton ui:field="selectButton" name="selectSourceButton" />
5 zanata-war/src/main/java/org/zanata/webtrans/client/view/TransUnitEditView.java
View
@@ -115,6 +115,11 @@ public void buildTable(List<SourceContentsDisplay> sourceDisplays, List<TargetCo
}
applyRowStyle();
+
+ for (SourceContentsDisplay sourceDisplay : sourceDisplays)
+ {
+ sourceDisplay.refresh();
+ }
}
private void showEmptyContentIfNoData(int dataSize)
1  zanata-war/src/main/java/org/zanata/webtrans/client/view/TransUnitEditView.ui.xml
View
@@ -13,6 +13,7 @@
.cellFormat {
border-bottom: 1px solid silver;
+ padding-bottom: 8px;
}
.table {
Please sign in to comment.
Something went wrong with that request. Please try again.