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.
Merge branch 'integration/master' of github.com:zanata/zanata into in…
…tegration/master
- Loading branch information
Showing
13 changed files
with
618 additions
and
94 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
19 changes: 19 additions & 0 deletions
19
zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TransHistoryDataProvider.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,19 @@ | ||
package org.zanata.webtrans.client.presenter; | ||
|
||
import org.zanata.webtrans.client.ui.TranslationHistoryDisplay; | ||
import org.zanata.webtrans.shared.model.TransHistoryItem; | ||
|
||
import com.google.gwt.view.client.ListDataProvider; | ||
import com.google.inject.Singleton; | ||
|
||
/** | ||
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a> | ||
*/ | ||
@Singleton | ||
public class TransHistoryDataProvider extends ListDataProvider<TransHistoryItem> | ||
{ | ||
public TransHistoryDataProvider() | ||
{ | ||
super(TranslationHistoryDisplay.HISTORY_ITEM_PROVIDES_KEY); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ta-war/src/main/java/org/zanata/webtrans/client/presenter/TransHistorySelectionModel.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,18 @@ | ||
package org.zanata.webtrans.client.presenter; | ||
|
||
import org.zanata.webtrans.client.ui.TranslationHistoryDisplay; | ||
import org.zanata.webtrans.shared.model.TransHistoryItem; | ||
import com.google.gwt.view.client.MultiSelectionModel; | ||
import com.google.inject.Singleton; | ||
|
||
/** | ||
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a> | ||
*/ | ||
@Singleton | ||
public class TransHistorySelectionModel extends MultiSelectionModel<TransHistoryItem> | ||
{ | ||
public TransHistorySelectionModel() | ||
{ | ||
super(TranslationHistoryDisplay.HISTORY_ITEM_PROVIDES_KEY); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...war/src/main/java/org/zanata/webtrans/client/presenter/TransHistoryVersionComparator.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,57 @@ | ||
package org.zanata.webtrans.client.presenter; | ||
|
||
import java.util.Comparator; | ||
|
||
import org.zanata.webtrans.shared.model.TransHistoryItem; | ||
|
||
/** | ||
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a> | ||
*/ | ||
public enum TransHistoryVersionComparator implements Comparator<TransHistoryItem> | ||
{ | ||
COMPARATOR; | ||
|
||
@Override | ||
public int compare(TransHistoryItem one, TransHistoryItem two) | ||
{ | ||
if (itemIsOldVersion(one) && itemIsOldVersion(two)) | ||
{ | ||
Integer verOne = Integer.parseInt(one.getVersionNum()); | ||
Integer verTwo = Integer.parseInt(two.getVersionNum()); | ||
return verOne.compareTo(verTwo); | ||
} | ||
if (itemIsCurrentValue(one)) | ||
{ | ||
//first is current value | ||
return 1; | ||
} | ||
if (itemIsLatestVersion(one) && itemIsCurrentValue(two)) | ||
{ | ||
//first is latest version but second is current value | ||
return -1; | ||
} | ||
if (itemIsLatestVersion(one) && itemIsOldVersion(two)) | ||
{ | ||
return 1; | ||
} | ||
//else first is old/digit version and second is not | ||
return -1; | ||
} | ||
|
||
private static boolean itemIsOldVersion(TransHistoryItem one) | ||
{ | ||
return one.getVersionNum().matches("\\d+"); | ||
} | ||
|
||
private static boolean itemIsLatestVersion(TransHistoryItem one) | ||
{ | ||
//digit following non-digit characters | ||
return one.getVersionNum().matches("\\d+\\D+"); | ||
} | ||
|
||
private static boolean itemIsCurrentValue(TransHistoryItem one) | ||
{ | ||
//anything except digit | ||
return one.getVersionNum().matches("\\D+"); | ||
} | ||
} |
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
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.