Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement enhancement for swithable navigation modes: https://bugzill…

  • Loading branch information...
commit 82a9ca16ca7744b26401d1e6a27bbb58392f9873 1 parent de1ba99
@aeng aeng authored
View
1  server/zanata-war/src/main/java/org/zanata/webtrans/client/TransUnitNavigationView.java
@@ -24,7 +24,6 @@
import org.zanata.common.ContentState;
import org.zanata.webtrans.client.editor.table.NavigationMessages;
-import org.zanata.webtrans.client.editor.table.TableConstants;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
View
14 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java
@@ -466,23 +466,23 @@ public void savePendingChange(boolean cancelIfUnchanged)
}
}
- private boolean fuzzyMode = true, newMode = true;
+ private boolean newMode = true, fuzzyMode = true;
public void saveAndMoveNextState(NavigationType nav)
{
savePendingChange(true);
- if (fuzzyMode && !newMode)
+ if (newMode && fuzzyMode)
{
- gotoFuzzyRow(nav);
+ gotoFuzzyAndNewRow(nav);
}
- else if (fuzzyMode && !newMode)
+ else if (newMode)
{
gotoNewRow(nav);
}
- else
+ else if (fuzzyMode)
{
- gotoFuzzyAndNewRow(nav);
+ gotoFuzzyRow(nav);
}
}
@@ -612,7 +612,7 @@ public void autoSize()
public void setNavMode(Map<ContentState, Boolean> configMap)
{
- fuzzyMode = configMap.get(ContentState.NeedReview);
newMode = configMap.get(ContentState.New);
+ fuzzyMode = configMap.get(ContentState.NeedReview);
}
}
View
4 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/NavigationCacheCallback.java
@@ -23,7 +23,7 @@
public interface NavigationCacheCallback
{
- void nextFuzzy();
+ void next(boolean isNewState, boolean isFuzzyState);
- void prevFuzzy();
+ void prev(boolean isNewState, boolean isFuzzyState);
}
View
186 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorPresenter.java
@@ -143,9 +143,15 @@
private final Identity identity;
private TransUnit selectedTransUnit;
// private int lastRowNum;
+ private List<Long> transIdNextNewFuzzyCache = new ArrayList<Long>();
+ private List<Long> transIdPrevNewFuzzyCache = new ArrayList<Long>();
+
private List<Long> transIdNextFuzzyCache = new ArrayList<Long>();
private List<Long> transIdPrevFuzzyCache = new ArrayList<Long>();
+ private List<Long> transIdNextNewCache = new ArrayList<Long>();
+ private List<Long> transIdPrevNewCache = new ArrayList<Long>();
+
private int curRowIndex;
private int curPage;
@@ -293,10 +299,10 @@ public void onTransUnitUpdated(TransUnitUpdatedEvent event)
if (documentId != null && documentId.equals(event.getDocumentId()))
{
// Clear the cache
- if (!transIdNextFuzzyCache.isEmpty())
- transIdNextFuzzyCache.clear();
- if (!transIdPrevFuzzyCache.isEmpty())
- transIdPrevFuzzyCache.clear();
+ if (!transIdNextNewFuzzyCache.isEmpty())
+ transIdNextNewFuzzyCache.clear();
+ if (!transIdPrevNewFuzzyCache.isEmpty())
+ transIdPrevNewFuzzyCache.clear();
// TODO this test never succeeds
if (selectedTransUnit != null && selectedTransUnit.getId().equals(event.getTransUnit().getId()))
{
@@ -652,7 +658,7 @@ public void nextFuzzyNewIndex(int row)
{
updatePageAndRowIndex(row);
if (curRowIndex < display.getTableModel().getRowCount())
- gotoNextState();
+ gotoNextState(true, true);
}
@Override
@@ -660,43 +666,39 @@ public void prevFuzzyNewIndex(int row)
{
updatePageAndRowIndex(row);
if (curRowIndex > 0)
- gotoPrevState();
+ gotoPrevState(true, true);
}
@Override
public void nextFuzzyIndex(int row)
{
- // TODO: ALEX
updatePageAndRowIndex(row);
if (curRowIndex < display.getTableModel().getRowCount())
- gotoNextState();
+ gotoNextState(false, true);
}
@Override
public void prevFuzzyIndex(int row)
{
- // TODO: ALEX
updatePageAndRowIndex(row);
if (curRowIndex > 0)
- gotoPrevState();
+ gotoPrevState(false, true);
}
@Override
public void nextNewIndex(int row)
{
- // TODO: ALEX
updatePageAndRowIndex(row);
if (curRowIndex < display.getTableModel().getRowCount())
- gotoNextState();
+ gotoNextState(true, false);
}
@Override
public void prevNewIndex(int row)
{
- // TODO: ALEX
updatePageAndRowIndex(row);
if (curRowIndex > 0)
- gotoPrevState();
+ gotoPrevState(true, false);
}
@Override
@@ -743,10 +745,10 @@ public void onFailure(Throwable caught)
boolean isReqComplete = true;
- private void cacheNextFuzzy(final NavigationCacheCallback callBack)
+ private void cacheNextState(final NavigationCacheCallback callBack, final List<Long> cacheList, final boolean isNewState, final boolean isFuzzyState)
{
isReqComplete = false;
- dispatcher.execute(new GetTransUnitsNavigation(selectedTransUnit.getId().getId(), 3, false, findMessage, true, true), new AsyncCallback<GetTransUnitsNavigationResult>()
+ dispatcher.execute(new GetTransUnitsNavigation(selectedTransUnit.getId().getId(), 3, false, findMessage, isNewState, isFuzzyState), new AsyncCallback<GetTransUnitsNavigationResult>()
{
@Override
public void onSuccess(GetTransUnitsNavigationResult result)
@@ -756,9 +758,9 @@ public void onSuccess(GetTransUnitsNavigationResult result)
{
for (Long offset : result.getUnits())
{
- transIdNextFuzzyCache.add(offset + curRowIndex);
+ cacheList.add(offset + curRowIndex);
}
- callBack.nextFuzzy();
+ callBack.next(isNewState, isFuzzyState);
}
}
@@ -770,10 +772,10 @@ public void onFailure(Throwable caught)
});
}
- private void cachePrevFuzzy(final NavigationCacheCallback callBack)
+ private void cachePrevState(final NavigationCacheCallback callBack, final List<Long> cacheList, final boolean isNewState, final boolean isFuzzyState)
{
isReqComplete = false;
- dispatcher.execute(new GetTransUnitsNavigation(selectedTransUnit.getId().getId(), 3, true, findMessage, true, true), new AsyncCallback<GetTransUnitsNavigationResult>()
+ dispatcher.execute(new GetTransUnitsNavigation(selectedTransUnit.getId().getId(), 3, true, findMessage, isNewState, isFuzzyState), new AsyncCallback<GetTransUnitsNavigationResult>()
{
@Override
public void onSuccess(GetTransUnitsNavigationResult result)
@@ -783,9 +785,9 @@ public void onSuccess(GetTransUnitsNavigationResult result)
{
for (Long offset : result.getUnits())
{
- transIdPrevFuzzyCache.add(curRowIndex - offset);
+ cacheList.add(curRowIndex - offset);
}
- callBack.prevFuzzy();
+ callBack.prev(isNewState, isFuzzyState);
}
}
@@ -797,93 +799,135 @@ public void onFailure(Throwable caught)
});
}
- private void gotoPrevState()
+ NavigationCacheCallback cacheCallback = new NavigationCacheCallback()
+ {
+ @Override
+ public void next(boolean isNewState, boolean isFuzzyState)
+ {
+ gotoNextState(isNewState, isFuzzyState);
+ }
+
+ @Override
+ public void prev(boolean isNewState, boolean isFuzzyState)
+ {
+ gotoPrevState(isNewState, isFuzzyState);
+ }
+
+ };
+
+ private void gotoNextState(boolean isNewState, boolean isFuzzyState)
+ {
+ if (isNewState && isFuzzyState)
+ {
+ Log.info("go to Next Fuzzy Or Untranslated State");
+ transIdPrevNewFuzzyCache.clear();
+ gotoNextState(transIdNextNewFuzzyCache, true, true);
+ }
+ else if (isNewState)
+ {
+ Log.info("go to Next Untranslated State");
+ transIdPrevNewCache.clear();
+ gotoNextState(transIdNextNewCache, true, false);
+ }
+ else if (isFuzzyState)
+ {
+ Log.info("go to Next Fuzzy State");
+ transIdPrevFuzzyCache.clear();
+ gotoNextState(transIdNextFuzzyCache, false, true);
+ }
+ }
+
+ private void gotoPrevState(boolean isNewState, boolean isFuzzyState)
{
- Log.info("Previous FuzzyOrUntranslated State");
+ if (isNewState && isFuzzyState)
+ {
+ Log.info("go to Prev Fuzzy Or Untranslated State");
+ // Clean the cache for Next Fuzzy to avoid issues about cache is
+ // obsolete
+ transIdNextNewFuzzyCache.clear();
+ gotoPrevState(transIdPrevNewFuzzyCache, true, true);
+ }
+ else if (isNewState)
+ {
+ Log.info("go to Prev Untranslated State");
+ // Clean the cache for Next Fuzzy to avoid issues about cache is
+ // obsolete
+ transIdNextNewCache.clear();
+ gotoPrevState(transIdPrevNewCache, true, false);
+ }
+ else if (isFuzzyState)
+ {
+ Log.info("go to Prev Fuzzy State");
+ // Clean the cache for Next Fuzzy to avoid issues about cache is
+ // obsolete
+ transIdNextFuzzyCache.clear();
+ gotoPrevState(transIdPrevFuzzyCache, false, true);
+ }
+ }
- // Clean the cache for Next Fuzzy to avoid issues about cache is
- // obsolete
- transIdNextFuzzyCache.clear();
- // If the catch of fuzzy row is empty and request is complete, generate
+ private void gotoPrevState(List<Long> transIdPrevCache, boolean isNewState, boolean isFuzzyState)
+ {
+ // If the catch of row is empty and request is complete, generate
// one
- if (transIdPrevFuzzyCache.isEmpty())
+ if (transIdPrevCache.isEmpty())
{
if (isReqComplete)
- cachePrevFuzzy(cacheCallback);
+ cachePrevState(cacheCallback, transIdPrevCache, isNewState, isFuzzyState);
}
else
{
- int size = transIdPrevFuzzyCache.size();
- int offset = transIdPrevFuzzyCache.get(size - 1).intValue();
+ int size = transIdPrevCache.size();
+ int offset = transIdPrevCache.get(size - 1).intValue();
if (curRowIndex > offset)
{
for (int i = 0; i < size; i++)
{
- int fuzzyRowIndex = transIdPrevFuzzyCache.get(i).intValue();
- if (curRowIndex > fuzzyRowIndex)
+ int newRowIndex = transIdPrevCache.get(i).intValue();
+ if (curRowIndex > newRowIndex)
{
display.getTargetCellEditor().cancelEdit();
- tableModelHandler.gotoRow(fuzzyRowIndex);
+ tableModelHandler.gotoRow(newRowIndex);
break;
}
}
}
else
{
- transIdPrevFuzzyCache.clear();
- cachePrevFuzzy(cacheCallback);
+ transIdPrevCache.clear();
+ cachePrevState(cacheCallback, transIdPrevCache, isNewState, isFuzzyState);
}
}
}
- NavigationCacheCallback cacheCallback = new NavigationCacheCallback()
- {
- @Override
- public void nextFuzzy()
- {
- gotoNextState();
- }
-
- @Override
- public void prevFuzzy()
- {
- gotoPrevState();
- }
-
- };
-
- private void gotoNextState()
+ private void gotoNextState(List<Long> transIdNextCache, boolean isNewState, boolean isFuzzyState)
{
- Log.info("go to Next FuzzyOrUntranslated State");
-
- transIdPrevFuzzyCache.clear();
- // If the cache of next fuzzy is empty, generate one
- if (transIdNextFuzzyCache.isEmpty())
+ // If the cache of next is empty, generate one
+ if (transIdNextCache.isEmpty())
{
if (isReqComplete)
- cacheNextFuzzy(cacheCallback);
+ cacheNextState(cacheCallback, transIdNextCache, isNewState, isFuzzyState);
}
else
{
- int size = transIdNextFuzzyCache.size();
- int offset = transIdNextFuzzyCache.get(size - 1).intValue();
+ int size = transIdNextCache.size();
+ int offset = transIdNextCache.get(size - 1).intValue();
if (curRowIndex < offset)
{
for (int i = 0; i < size; i++)
{
- int fuzzyRowIndex = transIdNextFuzzyCache.get(i).intValue();
- if (curRowIndex < fuzzyRowIndex)
+ int newRowIndex = transIdNextCache.get(i).intValue();
+ if (curRowIndex < newRowIndex)
{
display.getTargetCellEditor().cancelEdit();
- tableModelHandler.gotoRow(fuzzyRowIndex);
+ tableModelHandler.gotoRow(newRowIndex);
break;
}
}
}
else
{
- transIdNextFuzzyCache.clear();
- cacheNextFuzzy(cacheCallback);
+ transIdNextCache.clear();
+ cacheNextState(cacheCallback, transIdNextCache, isNewState, isFuzzyState);
}
}
}
@@ -960,10 +1004,10 @@ public void selectTransUnit(TransUnit transUnit)
selectedTransUnit = transUnit;
Log.info("SelectedTransUnit " + selectedTransUnit.getId());
// Clean the cache when we click the new entry
- if (!transIdNextFuzzyCache.isEmpty())
- transIdNextFuzzyCache.clear();
- if (!transIdPrevFuzzyCache.isEmpty())
- transIdPrevFuzzyCache.clear();
+ if (!transIdNextNewFuzzyCache.isEmpty())
+ transIdNextNewFuzzyCache.clear();
+ if (!transIdPrevNewFuzzyCache.isEmpty())
+ transIdPrevNewFuzzyCache.clear();
eventBus.fireEvent(new TransUnitSelectionEvent(selectedTransUnit));
}
View
19 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/ShortcutConfigPanel.java
@@ -28,6 +28,7 @@
import org.zanata.common.ContentState;
import org.zanata.webtrans.client.events.NavConfigChangeEvent;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.CheckBox;
@@ -58,7 +59,7 @@ public ShortcutConfigPanel(boolean autoHide, EventBus eventBus)
this.eventBus = eventBus;
init();
bindEvent();
- setButtonValue(true, true);
+ setDefaultValue();
}
private void init()
@@ -84,12 +85,13 @@ public void onValueChange(ValueChangeEvent<Boolean> event)
{
if (event.getValue() == false && untranslatedChk.getValue() == false)
{
- setButtonValue(true, true);
+ setDefaultValue();
}
else
{
configMap.put(ContentState.NeedReview, event.getValue());
}
+ Log.info("Navigation mode changed: Untranslated-" + untranslatedChk.getValue() + " Fuzzy-" + fuzzyChk.getValue());
eventBus.fireEvent(new NavConfigChangeEvent(configMap));
}
});
@@ -101,25 +103,26 @@ public void onValueChange(ValueChangeEvent<Boolean> event)
{
if (event.getValue() == false && fuzzyChk.getValue() == false)
{
- setButtonValue(true, true);
+ setDefaultValue();
}
else
{
configMap.put(ContentState.New, event.getValue());
}
+ Log.info("Navigation mode changed: Untranslated-" + untranslatedChk.getValue() + " Fuzzy-" + fuzzyChk.getValue());
eventBus.fireEvent(new NavConfigChangeEvent(configMap));
}
});
}
- private void setButtonValue(boolean fuzzyValue, boolean untranslatedValue)
+ private void setDefaultValue()
{
- fuzzyChk.setValue(fuzzyValue);
- untranslatedChk.setValue(untranslatedValue);
+ fuzzyChk.setValue(true);
+ untranslatedChk.setValue(true);
- configMap.put(ContentState.NeedReview, fuzzyValue);
- configMap.put(ContentState.New, untranslatedValue);
+ configMap.put(ContentState.NeedReview, true);
+ configMap.put(ContentState.New, true);
}
public void toggleDisplay(final UIObject target)
View
11 server/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTransUnitNavigationHandler.java
@@ -94,7 +94,7 @@ public GetTransUnitsNavigationResult execute(GetTransUnitsNavigation action, Exe
step++;
HTextFlow textFlow = textFlowDAO.findById(textFlowId, false);
HTextFlowTarget textFlowTarget = textFlow.getTargets().get(hLocale);
- if (checkStateAndValidate(action.isFuzzyState(), action.isNewState(), textFlowTarget))
+ if (checkStateAndValidate(action.isNewState(), action.isFuzzyState(), textFlowTarget))
{
results.add(step);
log.info("add navigation step: " + step);
@@ -118,7 +118,8 @@ public GetTransUnitsNavigationResult execute(GetTransUnitsNavigation action, Exe
{
step++;
HTextFlowTarget textFlowTarget = textFlow.getTargets().get(hLocale);
- if (checkStateAndValidate(action.isFuzzyState(), action.isNewState(), textFlowTarget))
+ log.info(action.isNewState() + ":" + action.isFuzzyState() + ":" + checkStateAndValidate(action.isNewState(), action.isFuzzyState(), textFlowTarget));
+ if (checkStateAndValidate(action.isNewState(), action.isFuzzyState(), textFlowTarget))
{
results.add(step);
log.info("add navigation step: " + step);
@@ -140,9 +141,9 @@ public void rollback(GetTransUnitsNavigation action, GetTransUnitsNavigationResu
{
}
- private boolean checkStateAndValidate(boolean isFuzzyState, boolean isNewState, HTextFlowTarget textFlowTarget)
+ private boolean checkStateAndValidate(boolean isNewState, boolean isFuzzyState, HTextFlowTarget textFlowTarget)
{
- if (isFuzzyState && isNewState)
+ if (isNewState && isFuzzyState)
{
return isNewFuzzyState(textFlowTarget);
}
@@ -159,7 +160,7 @@ else if (isNewState)
private boolean isNewFuzzyState(HTextFlowTarget textFlowTarget)
{
- return isNewState(textFlowTarget) || isFuzzyState(textFlowTarget);
+ return textFlowTarget == null || textFlowTarget.getState() == ContentState.New || textFlowTarget.getState() == ContentState.NeedReview;
}
private boolean isFuzzyState(HTextFlowTarget textFlowTarget)
View
4 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitsNavigation.java
@@ -38,14 +38,14 @@ private GetTransUnitsNavigation()
{
}
- public GetTransUnitsNavigation(Long id, int count, boolean reverse, String phrase, boolean isFuzzyState, boolean isNewState)
+ public GetTransUnitsNavigation(Long id, int count, boolean reverse, String phrase, boolean isNewState, boolean isFuzzyState)
{
this.id = id;
this.count = count;
this.setReverse(reverse);
this.phrase = phrase;
- this.isFuzzyState = isFuzzyState;
this.isNewState = isNewState;
+ this.isFuzzyState = isFuzzyState;
}
Please sign in to comment.
Something went wrong with that request. Please try again.