This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
rhbz804871 - checkbox selection;new version entries in table...
- add checkbox for row selection - add compare button to compare - add latest version to history table - add current editor value if it is different from latest version - add flip button to flip entry comparison - update comparison UI
- Loading branch information
Patrick Huang
committed
Aug 10, 2012
1 parent
b7358a5
commit 852fcd1
Showing
11 changed files
with
325 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
zanata-war/src/main/java/org/zanata/webtrans/client/ui/HistoryEntryComparisonPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package org.zanata.webtrans.client.ui; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.zanata.webtrans.client.resources.WebTransMessages; | ||
| import org.zanata.webtrans.shared.model.TransHistoryItem; | ||
| import com.google.gwt.core.client.GWT; | ||
| import com.google.gwt.event.dom.client.ClickEvent; | ||
| import com.google.gwt.resources.client.CssResource; | ||
| import com.google.gwt.uibinder.client.UiBinder; | ||
| import com.google.gwt.uibinder.client.UiField; | ||
| import com.google.gwt.uibinder.client.UiHandler; | ||
| import com.google.gwt.user.client.ui.Composite; | ||
| import com.google.gwt.user.client.ui.Grid; | ||
| import com.google.gwt.user.client.ui.PushButton; | ||
| import com.google.gwt.user.client.ui.ScrollPanel; | ||
| import com.google.gwt.user.client.ui.VerticalPanel; | ||
|
|
||
| public class HistoryEntryComparisonPanel extends Composite | ||
| { | ||
| private static ComparisonPanelUiBinder ourUiBinder = GWT.create(ComparisonPanelUiBinder.class); | ||
| public static final int ITEM_ONE_ROW = 2; | ||
| public static final int ITEM_TWO_ROW = 3; | ||
|
|
||
| @UiField | ||
| Grid grid; | ||
| @UiField | ||
| WebTransMessages messages; | ||
| @UiField | ||
| VerticalPanel itemTwoPanel; | ||
| @UiField | ||
| VerticalPanel itemOnePanel; | ||
| @UiField | ||
| PushButton flipButton; | ||
| @UiField | ||
| Styles style; | ||
| private TransHistoryItem itemOne; | ||
| private TransHistoryItem itemTwo; | ||
|
|
||
| public HistoryEntryComparisonPanel() | ||
| { | ||
| initWidget(ourUiBinder.createAndBindUi(this)); | ||
| } | ||
|
|
||
| public void compare(TransHistoryItem itemOne, TransHistoryItem itemTwo) | ||
| { | ||
| clear(); | ||
| this.itemOne = itemOne; | ||
| this.itemTwo = itemTwo; | ||
|
|
||
| grid.setText(ITEM_ONE_ROW, 0, itemOne.getVersionNum()); | ||
| List<String> itemOneContents = itemOne.getContents(); | ||
| for (String content : itemOneContents) | ||
| { | ||
| HighlightingLabel label = new HighlightingLabel(content); | ||
| label.addStyleName(style.historyEntry()); | ||
| itemOnePanel.add(label); | ||
| } | ||
|
|
||
| grid.setText(ITEM_TWO_ROW, 0, itemTwo.getVersionNum()); | ||
| List<String> itemTwoContents = itemTwo.getContents(); | ||
| for (int i = 0; i < itemOneContents.size(); i++) | ||
| { | ||
| String content1 = itemOneContents.get(i); | ||
| String content2 = itemTwoContents.get(i); | ||
| DiffMatchPatchLabel label = new DiffMatchPatchLabel(content1, content2); | ||
| label.addStyleName(style.historyEntry()); | ||
| itemTwoPanel.add(label); | ||
| } | ||
| } | ||
|
|
||
| public void clear() | ||
| { | ||
| itemOne = null; | ||
| itemTwo = null; | ||
| grid.setText(ITEM_ONE_ROW, 0, ""); | ||
| grid.setText(ITEM_TWO_ROW, 0, ""); | ||
| itemOnePanel.clear(); | ||
| itemTwoPanel.clear(); | ||
| } | ||
|
|
||
| @UiHandler("flipButton") | ||
| public void onFlipButtonClick(ClickEvent event) | ||
| { | ||
| if (itemOne != null && itemTwo != null) | ||
| { | ||
| compare(itemTwo, itemOne); | ||
| } | ||
| } | ||
|
|
||
| interface ComparisonPanelUiBinder extends UiBinder<ScrollPanel, HistoryEntryComparisonPanel> | ||
| { | ||
| } | ||
|
|
||
| interface Styles extends CssResource | ||
| { | ||
|
|
||
| String historyEntry(); | ||
|
|
||
| String versionLabel(); | ||
|
|
||
| String header(); | ||
| } | ||
| } |
55 changes: 55 additions & 0 deletions
55
zanata-war/src/main/java/org/zanata/webtrans/client/ui/HistoryEntryComparisonPanel.ui.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' | ||
| xmlns:g='urn:import:com.google.gwt.user.client.ui'> | ||
| <ui:with field="messages" type="org.zanata.webtrans.client.resources.WebTransMessages" /> | ||
|
|
||
| <ui:style field="style" type="org.zanata.webtrans.client.ui.HistoryEntryComparisonPanel.Styles"> | ||
|
|
||
| .historyEntry { | ||
| padding-left: 5px; | ||
| border-bottom: 1px dotted grey; | ||
| } | ||
|
|
||
| .versionLabel { | ||
| width: 15%; | ||
| background-color: #d3d3d3; | ||
| padding-left: 10px; | ||
| } | ||
|
|
||
| .header { | ||
| /* copy from cell table header */ | ||
| border-bottom: 2px solid #6F7277; | ||
| padding: 3px 15px; | ||
| text-align: left; | ||
| color: #4B4A4A; | ||
| text-shadow: #DDF 1px 1px 0; | ||
| overflow: hidden; | ||
| } | ||
| </ui:style> | ||
|
|
||
| <g:ScrollPanel> | ||
| <g:Grid width="100%" height="100%" ui:field="grid"> | ||
| <g:row> | ||
| <g:customCell> | ||
| <g:PushButton ui:field="flipButton" text="{messages.flipComparingEntries}"/> | ||
| </g:customCell> | ||
| <g:cell/> | ||
| </g:row> | ||
| <g:row> | ||
| <g:cell styleName="{style.header}">Version</g:cell> | ||
| <g:cell styleName="{style.header}">Contents</g:cell> | ||
| </g:row> | ||
| <g:row> | ||
| <g:cell styleName="{style.versionLabel}"/> | ||
| <g:customCell> | ||
| <g:VerticalPanel ui:field="itemOnePanel" width="100%" /> | ||
| </g:customCell> | ||
| </g:row> | ||
| <g:row> | ||
| <g:cell styleName="{style.versionLabel}" /> | ||
| <g:customCell> | ||
| <g:VerticalPanel ui:field="itemTwoPanel" width="100%" /> | ||
| </g:customCell> | ||
| </g:row> | ||
| </g:Grid> | ||
| </g:ScrollPanel> | ||
| </ui:UiBinder> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.