Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'rhbz773459'

Conflicts:
	server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorPresenter.java
	server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorTableDefinition.java
	server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorView.java
  • Loading branch information...
commit 89a0609c8c18e4737e21669be1ac0b7ad2e6656a 2 parents 6c9f901 + 72b9238
@aeng aeng authored
Showing with 932 additions and 242 deletions.
  1. +1 −1  server/zanata-war/eclipse/launch/webtrans-dummy.launch
  2. +1 −1  server/zanata-war/eclipse/launch/webtrans-jboss.launch
  3. +26 −35 server/zanata-war/src/main/java/org/zanata/dao/TextFlowDAO.java
  4. +130 −23 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorPresenter.java
  5. +50 −1 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorView.java
  6. +69 −0 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/FilterViewEvent.java
  7. +8 −0 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/FilterViewEventHandler.java
  8. +8 −1 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/TransUnitUpdatedEvent.java
  9. +1 −1  server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/DocumentListPresenter.java
  10. +115 −4 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/SidePanelPresenter.java
  11. +21 −1 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TransUnitNavigationPresenter.java
  12. +5 −0 server/zanata-war/src/main/java/org/zanata/webtrans/client/resources/EditorConfigConstants.java
  13. +51 −79 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorOptionsPanel.java
  14. +30 −1 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorOptionsPanel.ui.xml
  15. +107 −0 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/FilterViewConfirmationPanel.java
  16. +7 −0 server/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransUnitNavigationView.java
  17. +65 −53 server/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTransUnitListHandler.java
  18. +2 −2 server/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/UpdateTransUnitHandler.java
  19. +20 −30 server/zanata-war/src/main/java/org/zanata/webtrans/shared/model/TransUnit.java
  20. +29 −2 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitList.java
  21. +10 −5 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitListResult.java
  22. +2 −0  server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/HasTransUnitUpdatedData.java
  23. +8 −1 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/TransUnitUpdated.java
  24. +37 −0 server/zanata-war/src/main/java/org/zanata/webtrans/shared/util/TextFlowFilter.java
  25. +120 −0 server/zanata-war/src/main/java/org/zanata/webtrans/shared/util/TextFlowFilterImpl.java
  26. +8 −0 server/zanata-war/src/main/resources/org/zanata/webtrans/public/Application.css
  27. +1 −1  server/zanata-war/src/test/java/org/zanata/webtrans/client/rpc/DummyGetTransUnitCommand.java
View
2  server/zanata-war/eclipse/launch/webtrans-dummy.launch
@@ -20,7 +20,7 @@
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gwt.eclipse.core.moduleClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -startupUrl webtrans/Application.html?project=sample-project&amp;iteration=1.0&amp;localeId=de -logLevel INFO -port 48881 -codeServerPort 9998 -war &quot;${project_loc:/zanata-war}/src/main/webapp&quot; org.zanata.webtrans.ApplicationDummy"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="zanata-war"/>
View
2  server/zanata-war/eclipse/launch/webtrans-jboss.launch
@@ -21,7 +21,7 @@
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gwt.eclipse.core.moduleClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -startupUrl http://localhost:8080/zanata/webtrans/Application.html?project=sample-project&amp;iteration=1.0&amp;localeId=de -logLevel INFO -noserver -codeServerPort 9997 -war &quot;${deploy.zanata}&quot; org.zanata.webtrans.Application"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="zanata-war"/>
View
61 server/zanata-war/src/main/java/org/zanata/dao/TextFlowDAO.java
@@ -20,6 +20,7 @@
*/
package org.zanata.dao;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@@ -39,14 +40,24 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.log.Log;
import org.zanata.common.ContentState;
import org.zanata.common.LocaleId;
import org.zanata.hibernate.search.DefaultNgramAnalyzer;
import org.zanata.model.HDocument;
+import org.zanata.model.HLocale;
import org.zanata.model.HTextFlow;
+import org.zanata.model.HTextFlowTarget;
+import org.zanata.webtrans.server.rpc.CommentsUtil;
+import org.zanata.webtrans.shared.model.DocumentId;
+import org.zanata.webtrans.shared.model.TransUnit;
+import org.zanata.webtrans.shared.model.TransUnitId;
+import org.zanata.webtrans.shared.rpc.GetTransUnitListResult;
import org.zanata.webtrans.shared.rpc.GetTranslationMemory.SearchType;
+import org.zanata.webtrans.shared.util.TextFlowFilter;
@Name("textFlowDAO")
@AutoCreate
@@ -56,6 +67,11 @@
@In
private FullTextEntityManager entityManager;
+ @In
+ LocaleDAO localeDAO;
+
+ @Logger
+ Log log;
public TextFlowDAO()
{
@@ -67,11 +83,6 @@ public TextFlowDAO(Session session)
super(HTextFlow.class, session);
}
- /**
- * @param document
- * @param id
- * @return
- */
public HTextFlow getById(HDocument document, String id)
{
return (HTextFlow) getSession().createCriteria(HTextFlow.class).add(Restrictions.naturalId().set("resId", id).set("document", document)).setCacheable(true).setComment("TextFlowDAO.getById").uniqueResult();
@@ -173,48 +184,28 @@ public HTextFlow getObsoleteById(HDocument document, String id)
// @formatter:on
}
- @SuppressWarnings({ "unchecked" })
- public List<HTextFlow> getByDocument(Long documentId)
+ public int getCountByDocument(Long documentId)
{
- Query query = getSession().createQuery("from HTextFlow tf where tf.obsolete=0 and tf.document.id = :id order by tf.pos").setParameter("id", documentId);
- return query.list();
+ Long totalCount = (Long) getSession().createQuery("select count(*) from HTextFlow tf where tf.obsolete=0 and tf.document.id = :id order by tf.pos").setParameter("id", documentId).uniqueResult();
+ if (totalCount == null)
+ return 0;
+ return totalCount.intValue();
}
@SuppressWarnings("unchecked")
- public List<HTextFlow> getOffsetListByDocument(Long documentId, int offset, int count)
+ public List<HTextFlow> getTransUnitList(Long documentId, int offset, int count)
{
Query query = getSession().createQuery("from HTextFlow tf where tf.obsolete=0 and tf.document.id = :id order by tf.pos").setParameter("id", documentId);
return query.setFirstResult(offset).setMaxResults(count).list();
}
-
-
+
@SuppressWarnings("unchecked")
- // TODO: use hibernate search
- public Set<Object[]> getIdsBySearch(Long documentId, int offset, int count, String search, LocaleId localeId)
+ public List<HTextFlow> getTransUnitList(Long documentId)
{
- Query textFlowQuery = getSession().createQuery("select tf.id, tf.pos from HTextFlow tf where tf.obsolete=0 and tf.document.id = :id and lower(tf.content) like :content order by tf.pos");
- textFlowQuery.setParameter("id", documentId);
- textFlowQuery.setParameter("content", "%" + search + "%");
- List<Object[]> ids1 = textFlowQuery.list();
- Query textFlowTargetQuery = getSession().createQuery("select tft.textFlow.id, tft.textFlow.pos from HTextFlowTarget tft where tft.textFlow.obsolete=0 and tft.textFlow.document.id = :id and lower(tft.content) like :content and tft.locale.localeId = :localeId order by tft.textFlow.pos");
- textFlowTargetQuery.setParameter("id", documentId);
- textFlowTargetQuery.setParameter("content", "%" + search + "%");
- textFlowTargetQuery.setParameter("localeId", localeId);
- List<Object[]> ids2 = textFlowTargetQuery.list();
- Set<Object[]> idSet = new TreeSet<Object[]>(new Comparator<Object[]>()
- {
- @Override
- public int compare(Object[] arg0, Object[] arg1)
- {
- return ((Integer) arg0[1]).compareTo((Integer) arg1[1]);
- }
- });
- idSet.addAll(ids1);
- idSet.addAll(ids2);
- return idSet;
+ Query query = getSession().createQuery("from HTextFlow tf where tf.obsolete=0 and tf.document.id = :id order by tf.pos").setParameter("id", documentId);
+ return query.list();
}
-
// TODO: use hibernate search
@SuppressWarnings("unchecked")
public Set<Object[]> getNavigationBy(Long documentId, String search, int offset, LocaleId localeId, boolean reverse)
View
153 ...anata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorPresenter.java
@@ -39,6 +39,8 @@
import org.zanata.webtrans.client.events.CopySourceEventHandler;
import org.zanata.webtrans.client.events.DocumentSelectionEvent;
import org.zanata.webtrans.client.events.DocumentSelectionHandler;
+import org.zanata.webtrans.client.events.FilterViewEvent;
+import org.zanata.webtrans.client.events.FilterViewEventHandler;
import org.zanata.webtrans.client.events.FindMessageEvent;
import org.zanata.webtrans.client.events.FindMessageHandler;
import org.zanata.webtrans.client.events.NavTransUnitEvent;
@@ -62,6 +64,7 @@
import org.zanata.webtrans.client.events.UpdateValidationWarningsEventHandler;
import org.zanata.webtrans.client.resources.TableEditorMessages;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
+import org.zanata.webtrans.client.ui.FilterViewConfirmationPanel;
import org.zanata.webtrans.shared.auth.AuthenticationError;
import org.zanata.webtrans.shared.auth.AuthorizationError;
import org.zanata.webtrans.shared.auth.Identity;
@@ -78,6 +81,8 @@
import org.zanata.webtrans.shared.rpc.UpdateTransUnitResult;
import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
@@ -142,6 +147,8 @@
int getSelectedRowNumber();
void setTransUnitDetails(TransUnit selectedTransUnit);
+
+ boolean isProcessing();
}
private DocumentId documentId;
@@ -151,6 +158,7 @@
private final CachingDispatchAsync dispatcher;
private final Identity identity;
private TransUnit selectedTransUnit;
+ private TransUnitId targetTransUnitId;
// private int lastRowNum;
private List<Long> transIdNextNewFuzzyCache = new ArrayList<Long>();
private List<Long> transIdPrevNewFuzzyCache = new ArrayList<Long>();
@@ -170,6 +178,10 @@
private UndoableTransUnitUpdateAction inProcessing;
+ private final FilterViewConfirmationPanel filterViewConfirmationPanel = new FilterViewConfirmationPanel();
+
+ private boolean filterTranslated, filterNeedReview, filterUntranslated;
+
private final UndoableTransUnitUpdateHandler undoableTransUnitUpdateHandler = new UndoableTransUnitUpdateHandler()
{
@Override
@@ -262,11 +274,97 @@ private void clearCacheList()
transIdPrevFuzzyCache.clear();
}
+ /**
+ * Clear all current transUnit list and re-query from server. Force to run
+ * requestRows@TableModelHandler
+ */
+ private void initialiseTransUnitList()
+ {
+ display.getTableModel().clearCache();
+ display.getTableModel().setRowCount(TableModel.UNKNOWN_ROW_COUNT);
+ display.gotoPage(0, true);
+ }
+
@Override
protected void onBind()
{
display.setTableModelHandler(tableModelHandler);
display.setPageSize(TableConstants.PAGE_SIZE);
+ registerHandler(filterViewConfirmationPanel.getSaveChangesAndFilterButton().addClickHandler(new ClickHandler()
+ {
+ @Override
+ public void onClick(ClickEvent event)
+ {
+ Log.info("Save changes and filter");
+ filterViewConfirmationPanel.updateFilter(filterTranslated, filterNeedReview, filterUntranslated);
+ filterViewConfirmationPanel.hide();
+
+ display.getTargetCellEditor().savePendingChange(true);
+ if (selectedTransUnit != null)
+ {
+ targetTransUnitId = selectedTransUnit.getId();
+ }
+ initialiseTransUnitList();
+ }
+ }));
+
+ registerHandler(filterViewConfirmationPanel.getDiscardChangesAndFilterButton().addClickHandler(new ClickHandler()
+ {
+ @Override
+ public void onClick(ClickEvent event)
+ {
+ Log.info("Discard changes and filter");
+ filterViewConfirmationPanel.updateFilter(filterTranslated, filterNeedReview, filterUntranslated);
+ filterViewConfirmationPanel.hide();
+
+ display.getTargetCellEditor().cancelEdit();
+ if (selectedTransUnit != null)
+ {
+ targetTransUnitId = selectedTransUnit.getId();
+ }
+ initialiseTransUnitList();
+ }
+ }));
+
+ registerHandler(filterViewConfirmationPanel.getCancelFilterButton().addClickHandler(new ClickHandler()
+ {
+ @Override
+ public void onClick(ClickEvent event)
+ {
+ Log.info("Cancel filter");
+ eventBus.fireEvent(new FilterViewEvent(filterViewConfirmationPanel.isFilterTranslated(), filterViewConfirmationPanel.isFilterNeedReview(), filterViewConfirmationPanel.isFilterUntranslated(), true));
+ filterViewConfirmationPanel.hide();
+ }
+ }));
+
+ registerHandler(eventBus.addHandler(FilterViewEvent.getType(), new FilterViewEventHandler()
+ {
+ @Override
+ public void onFilterView(FilterViewEvent event)
+ {
+ if (!event.isCancelFilter())
+ {
+ filterTranslated = event.isFilterTranslated();
+ filterNeedReview = event.isFilterNeedReview();
+ filterUntranslated = event.isFilterUntranslated();
+
+ if (display.getTargetCellEditor().isOpened() && display.getTargetCellEditor().isEditing())
+ {
+ filterViewConfirmationPanel.center();
+ }
+ else
+ {
+ filterViewConfirmationPanel.updateFilter(filterTranslated, filterNeedReview, filterUntranslated);
+ if (selectedTransUnit != null)
+ {
+ targetTransUnitId = selectedTransUnit.getId();
+ }
+ initialiseTransUnitList();
+ }
+ }
+ }
+ }));
+
registerHandler(display.getSelectionHandlers().addSelectionHandler(new SelectionHandler<TransUnit>()
{
@Override
@@ -306,10 +404,11 @@ public void onFindMessage(FindMessageEvent event)
display.startProcessing();
findMessage = event.getMessage();
display.setFindMessage(findMessage);
- display.getTableModel().clearCache();
- display.getTableModel().setRowCount(TableModel.UNKNOWN_ROW_COUNT);
- display.gotoPage(0, true);
- display.stopProcessing();
+ if (selectedTransUnit != null)
+ {
+ targetTransUnitId = selectedTransUnit.getId();
+ }
+ initialiseTransUnitList();
}
}));
@@ -330,18 +429,18 @@ public void onTransUnitUpdated(TransUnitUpdatedEvent event)
eventBus.fireEvent(new RunValidationEvent(event.getTransUnit().getId(), event.getTransUnit().getSource(), event.getTransUnit().getTarget()));
}
- Integer row = getRow(event.getTransUnit());
+ Integer rowIndex = getRowIndex(event.getTransUnit());
// - add TU index to model
- if (row != null)
+ if (rowIndex != null)
{
- Log.info("onTransUnitUpdated - update row:" + row);
- display.getTableModel().setRowValueOverride(row, event.getTransUnit());
+ Log.info("onTransUnitUpdated - update row:" + rowIndex);
+ display.getTableModel().setRowValueOverride(rowIndex, event.getTransUnit());
if (inProcessing != null)
{
if (inProcessing.getAction().getTransUnitId().equals(event.getTransUnit().getId()))
{
- tableModelHandler.gotoRow(row, true);
+ tableModelHandler.gotoRow(rowIndex, true);
eventBus.fireEvent(new UndoRedoFinishEvent(inProcessing));
inProcessing = null;
}
@@ -357,14 +456,14 @@ public void onTransUnitUpdated(TransUnitUpdatedEvent event)
{
int pageNum = inProcessing.getCurrentPage();
int rowNum = inProcessing.getRowNum();
- row = pageNum * display.getPageSize() + rowNum;
- tableModelHandler.gotoRow(row, true);
+ rowIndex = pageNum * display.getPageSize() + rowNum;
+ tableModelHandler.gotoRow(rowIndex, true);
eventBus.fireEvent(new UndoRedoFinishEvent(inProcessing));
inProcessing = null;
}
}
}
- if (selectedTransUnit != null && selectedTransUnit.getId().equals(event.getTransUnit().getId()))
+ if (!display.isProcessing() && event.getUsername().equals(identity.getPerson().getId().toString()) && selectedTransUnit != null && selectedTransUnit.getId().equals(event.getTransUnit().getId()))
{
tableModelHandler.gotoRow(curRowIndex, true);
}
@@ -472,10 +571,10 @@ public void onTransMemoryCopy(TransMemoryCopyEvent event)
@Override
public void onCopySource(CopySourceEvent event)
{
- Integer row = getRow(event.getTransUnit());
- if (row != null)
+ Integer rowIndex = getRowIndex(event.getTransUnit());
+ if (rowIndex != null)
{
- tableModelHandler.gotoRow(row, true);
+ tableModelHandler.gotoRow(rowIndex, true);
display.getTargetCellEditor().setText(event.getTransUnit().getSource());
display.getTargetCellEditor().autoSize();
}
@@ -509,10 +608,10 @@ public void onUpdate(UpdateValidationWarningsEvent event)
public boolean isFiltering()
{
- return findMessage != null && !findMessage.isEmpty();
+ return (findMessage != null && !findMessage.isEmpty()) || (filterViewConfirmationPanel.isFilterTranslated() || filterViewConfirmationPanel.isFilterNeedReview() || filterViewConfirmationPanel.isFilterUntranslated());
}
- public Integer getRow(TransUnit tu)
+ public Integer getRowIndex(TransUnit tu)
{
if (!isFiltering())
{
@@ -553,7 +652,7 @@ public void requestRows(final Request request, final Callback<TransUnit> callbac
display.startProcessing();
- dispatcher.execute(new GetTransUnitList(documentId, startRow, numRows, findMessage), new AsyncCallback<GetTransUnitListResult>()
+ dispatcher.execute(new GetTransUnitList(documentId, startRow, numRows, findMessage, filterViewConfirmationPanel.isFilterTranslated(), filterViewConfirmationPanel.isFilterNeedReview(), filterViewConfirmationPanel.isFilterUntranslated(), targetTransUnitId), new AsyncCallback<GetTransUnitListResult>()
{
@Override
@@ -564,7 +663,17 @@ public void onSuccess(GetTransUnitListResult result)
callback.onRowsReady(request, response);
display.getTableModel().setRowCount(result.getTotalCount());
display.stopProcessing();
- tableModelHandler.gotoRow(curRowIndex, false);
+
+ int gotoRow = curRowIndex;
+
+ if (result.getUnits().size() > 0)
+ {
+ if (result.getGotoRow() != -1)
+ {
+ gotoRow = result.getGotoRow();
+ }
+ tableModelHandler.gotoRow(gotoRow, false);
+ }
}
@Override
@@ -586,6 +695,7 @@ else if (caught instanceof AuthorizationError)
display.stopProcessing();
}
});
+ targetTransUnitId = null;
}
@Override
@@ -1053,10 +1163,7 @@ private void loadDocument(DocumentId selectDocId)
{
display.startProcessing();
documentId = selectDocId;
- display.getTableModel().clearCache();
- display.getTableModel().setRowCount(TableModel.UNKNOWN_ROW_COUNT);
- display.gotoPage(0, true);
- display.stopProcessing();
+ initialiseTransUnitList();
}
}
}
View
51 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorView.java
@@ -32,7 +32,10 @@
import org.zanata.webtrans.shared.auth.Identity;
import org.zanata.webtrans.shared.auth.Permission;
import org.zanata.webtrans.shared.model.TransUnit;
+import org.zanata.webtrans.shared.model.TransUnitId;
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
@@ -154,6 +157,12 @@ public void stopProcessing()
loadingPanel.hide();
}
+ @Override
+ public boolean isProcessing()
+ {
+ return loadingPanel.isShowing();
+ }
+
@Override
public HandlerRegistration addSelectionHandler(SelectionHandler<TransUnit> handler)
{
@@ -211,7 +220,7 @@ public void gotoRow(int row, boolean andEdit)
if (row < getDataTable().getRowCount())
{
getDataTable().selectRow(row, true);
- DOM.scrollIntoView(getDataTable().getWidget(row, TableEditorTableDefinition.TARGET_COL).getElement());
+ scrollIntoView(getDataTable().getWidget(row, TableEditorTableDefinition.TARGET_COL).getElement());
if (andEdit)
{
editCell(row, TableEditorTableDefinition.TARGET_COL);
@@ -258,4 +267,44 @@ public void setTransUnitDetails(TransUnit selectedTransUnit)
this.tableDefinition.setTransUnitDetails(selectedTransUnit);
}
+
+ /*
+ * Overrides DOM.scrollIntoView() - focus on element's bottom right corner
+ * This implementation focus on element's top left corner
+ */
+ public native void scrollIntoView(Element elem) /*-{
+ var left = elem.offsetLeft, top = elem.offsetTop;
+ var width = elem.offsetWidth, height = elem.offsetHeight;
+
+ if (elem.parentNode != elem.offsetParent) {
+ left -= elem.parentNode.offsetLeft;
+ top -= elem.parentNode.offsetTop;
+ }
+
+ var cur = elem.parentNode;
+ while (cur && (cur.nodeType == 1)) {
+ if (left + width > cur.scrollLeft + cur.clientWidth) {
+ cur.scrollLeft = (left + width) - cur.clientWidth;
+ }
+ if (left < cur.scrollLeft) {
+ cur.scrollLeft = left;
+ }
+ if (top + height > cur.scrollTop + cur.clientHeight) {
+ cur.scrollTop = (top + height) - cur.clientHeight;
+ }
+ if (top < cur.scrollTop) {
+ cur.scrollTop = top;
+ }
+
+ var offsetLeft = cur.offsetLeft, offsetTop = cur.offsetTop;
+ if (cur.parentNode != cur.offsetParent) {
+ offsetLeft -= cur.parentNode.offsetLeft;
+ offsetTop -= cur.parentNode.offsetTop;
+ }
+
+ left += offsetLeft - cur.scrollLeft;
+ top += offsetTop - cur.scrollTop;
+ cur = cur.parentNode;
+ }
+ }-*/;
}
View
69 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/FilterViewEvent.java
@@ -0,0 +1,69 @@
+package org.zanata.webtrans.client.events;
+
+import com.google.gwt.event.shared.GwtEvent;
+
+public class FilterViewEvent extends GwtEvent<FilterViewEventHandler>
+{
+ /**
+ * Handler type.
+ */
+ private static Type<FilterViewEventHandler> TYPE;
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the handler type
+ */
+ public static Type<FilterViewEventHandler> getType()
+ {
+ if (TYPE == null)
+ {
+ TYPE = new Type<FilterViewEventHandler>();
+ }
+ return TYPE;
+ }
+
+ private boolean filterTranslated, filterNeedReview, filterUntranslated;
+ private boolean cancelFilter;
+
+ public FilterViewEvent(boolean filterTranslated, boolean filterNeedReview, boolean filterUntranslated, boolean cancelFilter)
+ {
+ this.filterTranslated = filterTranslated;
+ this.filterNeedReview = filterNeedReview;
+ this.filterUntranslated = filterUntranslated;
+ this.cancelFilter = cancelFilter;
+ }
+
+ @Override
+ protected void dispatch(FilterViewEventHandler handler)
+ {
+ handler.onFilterView(this);
+ }
+
+ @Override
+ public Type<FilterViewEventHandler> getAssociatedType()
+ {
+ return getType();
+ }
+
+ public boolean isFilterTranslated()
+ {
+ return filterTranslated;
+ }
+
+ public boolean isFilterNeedReview()
+ {
+ return filterNeedReview;
+ }
+
+ public boolean isFilterUntranslated()
+ {
+ return filterUntranslated;
+ }
+
+ public boolean isCancelFilter()
+ {
+ return cancelFilter;
+ }
+
+}
View
8 ...er/zanata-war/src/main/java/org/zanata/webtrans/client/events/FilterViewEventHandler.java
@@ -0,0 +1,8 @@
+package org.zanata.webtrans.client.events;
+
+import com.google.gwt.event.shared.EventHandler;
+
+public interface FilterViewEventHandler extends EventHandler
+{
+ void onFilterView(FilterViewEvent event);
+}
View
9 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/TransUnitUpdatedEvent.java
@@ -34,6 +34,7 @@
private final ContentState previousStatus;
private int wordCount;
private TransUnit tu;
+ private String username;
/**
@@ -61,6 +62,7 @@ public TransUnitUpdatedEvent(HasTransUnitUpdatedData data)
this.previousStatus = data.getPreviousStatus();
this.wordCount = data.getWordCount();
this.tu = data.getTransUnit();
+ this.username = data.getUsername();
}
@Override
@@ -81,7 +83,6 @@ public DocumentId getDocumentId()
return documentId;
}
-
@Override
public ContentState getPreviousStatus()
{
@@ -100,4 +101,10 @@ public TransUnit getTransUnit()
return this.tu;
}
+ @Override
+ public String getUsername()
+ {
+ return username;
+ }
+
}
View
2  .../zanata-war/src/main/java/org/zanata/webtrans/client/presenter/DocumentListPresenter.java
@@ -387,7 +387,7 @@ public void onSuccess(GetDocumentListResult result)
// re-use these stats for the project stats
eventBus.fireEvent(new ProjectStatsUpdatedEvent(projectStats));
- Log.info("Time to calculate project stats: " + String.valueOf(System.currentTimeMillis() - start));
+ Log.info("Time to calculate project stats: " + String.valueOf(System.currentTimeMillis() - start) + "ms");
}
});
}
View
119 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/SidePanelPresenter.java
@@ -20,15 +20,28 @@
*/
package org.zanata.webtrans.client.presenter;
+import java.util.HashMap;
+import java.util.Map;
+
import net.customware.gwt.dispatch.client.DispatchAsync;
import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.widget.WidgetDisplay;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;
import org.zanata.webtrans.client.editor.filter.TransFilterPresenter;
+import org.zanata.webtrans.client.events.ButtonDisplayChangeEvent;
+import org.zanata.webtrans.client.events.FilterViewEvent;
+import org.zanata.webtrans.client.events.FilterViewEventHandler;
+import org.zanata.webtrans.client.events.UserConfigChangeEvent;
+import org.zanata.webtrans.client.resources.EditorConfigConstants;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
import org.zanata.webtrans.client.ui.EditorOptionsPanel;
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
@@ -44,26 +57,124 @@
private final DispatchAsync dispatcher;
private final ValidationOptionsPresenter validationOptionsPresenter;
private final EditorOptionsPanel editorOptionsPanel;
-
+
@Inject
public SidePanelPresenter(final Display display, final EventBus eventBus, CachingDispatchAsync dispatcher, final ValidationOptionsPresenter validationDetailsPresenter, final TransFilterPresenter transFilterPresenter)
{
super(display, eventBus);
- this.editorOptionsPanel = new EditorOptionsPanel(eventBus);
+ this.editorOptionsPanel = new EditorOptionsPanel();
this.validationOptionsPresenter = validationDetailsPresenter;
this.dispatcher = dispatcher;
+
+ configMap.put(EditorConfigConstants.BUTTON_ENTER, false);
+ configMap.put(EditorConfigConstants.BUTTON_ESC, false);
+ configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
+ configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
}
+ private final ValueChangeHandler<Boolean> filterChangeHandler = new ValueChangeHandler<Boolean>()
+ {
+ @Override
+ public void onValueChange(ValueChangeEvent<Boolean> event)
+ {
+ eventBus.fireEvent(new FilterViewEvent(editorOptionsPanel.getTranslatedChk().getValue(), editorOptionsPanel.getNeedReviewChk().getValue(), editorOptionsPanel.getUntranslatedChk().getValue(), false));
+ }
+ };
+
+ private Map<String, Boolean> configMap = new HashMap<String, Boolean>();
+
@Override
protected void onBind()
{
validationOptionsPresenter.bind();
display.setValidationOptionsView(validationOptionsPresenter.getDisplay().asWidget());
-
display.setEditorOptionsPanel(editorOptionsPanel);
- }
+ registerHandler(editorOptionsPanel.getTranslatedChk().addValueChangeHandler(filterChangeHandler));
+ registerHandler(editorOptionsPanel.getNeedReviewChk().addValueChangeHandler(filterChangeHandler));
+ registerHandler(editorOptionsPanel.getUntranslatedChk().addValueChangeHandler(filterChangeHandler));
+
+ registerHandler(eventBus.addHandler(FilterViewEvent.getType(), new FilterViewEventHandler()
+ {
+ @Override
+ public void onFilterView(FilterViewEvent event)
+ {
+ if (event.isCancelFilter())
+ {
+ editorOptionsPanel.getTranslatedChk().setValue(event.isFilterTranslated(), false);
+ editorOptionsPanel.getNeedReviewChk().setValue(event.isFilterNeedReview(), false);
+ editorOptionsPanel.getUntranslatedChk().setValue(event.isFilterUntranslated(), false);
+ }
+
+ // if filter view, hide model navigation
+ if (event.isFilterTranslated() || event.isFilterNeedReview() || event.isFilterUntranslated())
+ {
+ editorOptionsPanel.setNavOptionVisible(false);
+ }
+ else
+ {
+ editorOptionsPanel.setNavOptionVisible(true);
+ }
+ }
+ }));
+
+ registerHandler(editorOptionsPanel.getEditorButtonsChk().addValueChangeHandler(new ValueChangeHandler<Boolean>()
+ {
+ @Override
+ public void onValueChange(ValueChangeEvent<Boolean> event)
+ {
+ Log.info("Show editor buttons: " + event.getValue());
+ eventBus.fireEvent(new ButtonDisplayChangeEvent(event.getValue()));
+ }
+ }));
+ registerHandler(editorOptionsPanel.getEnterChk().addValueChangeHandler(new ValueChangeHandler<Boolean>()
+ {
+ @Override
+ public void onValueChange(ValueChangeEvent<Boolean> event)
+ {
+ Log.info("Enable 'Enter' Key to save and move to next string: " + event.getValue());
+ configMap.put(EditorConfigConstants.BUTTON_ENTER, event.getValue());
+ eventBus.fireEvent(new UserConfigChangeEvent(configMap));
+ }
+ }));
+
+ registerHandler(editorOptionsPanel.getEscChk().addValueChangeHandler(new ValueChangeHandler<Boolean>()
+ {
+ @Override
+ public void onValueChange(ValueChangeEvent<Boolean> event)
+ {
+ Log.info("Enable 'Esc' Key to close editor: " + event.getValue());
+ configMap.put(EditorConfigConstants.BUTTON_ESC, event.getValue());
+ eventBus.fireEvent(new UserConfigChangeEvent(configMap));
+ }
+ }));
+
+ registerHandler(editorOptionsPanel.getOptionsList().addChangeHandler(new ChangeHandler()
+ {
+ @Override
+ public void onChange(ChangeEvent event)
+ {
+ String selectedOption = editorOptionsPanel.getOptionsList().getItemText(editorOptionsPanel.getOptionsList().getSelectedIndex());
+ if (selectedOption.equals(EditorConfigConstants.OPTION_FUZZY_UNTRANSLATED))
+ {
+ configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
+ configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
+ }
+ else if (selectedOption.equals(EditorConfigConstants.OPTION_FUZZY))
+ {
+ configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
+ configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, false);
+ }
+ else if (selectedOption.equals(EditorConfigConstants.OPTION_UNTRANSLATED))
+ {
+ configMap.put(EditorConfigConstants.BUTTON_FUZZY, false);
+ configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
+ }
+ eventBus.fireEvent(new UserConfigChangeEvent(configMap));
+ }
+ }));
+ }
@Override
protected void onUnbind()
View
22 ...-war/src/main/java/org/zanata/webtrans/client/presenter/TransUnitNavigationPresenter.java
@@ -26,6 +26,8 @@
import net.customware.gwt.presenter.client.widget.WidgetDisplay;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;
+import org.zanata.webtrans.client.events.FilterViewEvent;
+import org.zanata.webtrans.client.events.FilterViewEventHandler;
import org.zanata.webtrans.client.events.NavTransUnitEvent;
import org.zanata.webtrans.client.events.NavTransUnitEvent.NavigationType;
import org.zanata.webtrans.client.events.NavTransUnitHandler;
@@ -35,7 +37,6 @@
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
public class TransUnitNavigationPresenter extends WidgetPresenter<TransUnitNavigationPresenter.Display> implements HasNavTransUnitHandlers
@@ -56,6 +57,8 @@
HasClickHandlers getNextStateButton();
void setNavModeTooltip(Map<String, Boolean> configMap);
+
+ void setModelNavVisible(boolean visible);
}
@Inject
@@ -121,6 +124,23 @@ public void onClick(ClickEvent event)
}
});
+ registerHandler(eventBus.addHandler(FilterViewEvent.getType(), new FilterViewEventHandler()
+ {
+ @Override
+ public void onFilterView(FilterViewEvent event)
+ {
+ // if filter view, hide model navigation
+ if (!event.isFilterTranslated() || !event.isFilterNeedReview() || !event.isFilterUntranslated())
+ {
+ display.setModelNavVisible(false);
+ }
+ else
+ {
+ display.setModelNavVisible(true);
+ }
+ }
+ }));
+
}
@Override
View
5 .../zanata-war/src/main/java/org/zanata/webtrans/client/resources/EditorConfigConstants.java
@@ -38,6 +38,11 @@
public static final String LABEL_EDITOR_BUTTONS = "Editor Buttons";
public static final String LABEL_EDITOR_OPTIONS = "Editor Options";
+ public static final String LABEL_TRANSLATED = "Translated";
+ public static final String LABEL_NEED_REVIEW = "Need Review";
+ public static final String LABEL_UNTRANSLATED = "Untranslated";
+ public static final String LABEL_FILTERS = "Message Filters:";
+
public static final String OPTION_FUZZY_UNTRANSLATED = "Next Fuzzy/Untranslated";
public static final String OPTION_FUZZY = "Next Fuzzy";
public static final String OPTION_UNTRANSLATED = "Next Untranslated";
View
130 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorOptionsPanel.java
@@ -20,21 +20,9 @@
*/
package org.zanata.webtrans.client.ui;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.customware.gwt.presenter.client.EventBus;
-
-import org.zanata.webtrans.client.events.ButtonDisplayChangeEvent;
-import org.zanata.webtrans.client.events.UserConfigChangeEvent;
import org.zanata.webtrans.client.resources.EditorConfigConstants;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.CheckBox;
@@ -43,7 +31,6 @@
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
-import com.google.inject.Inject;
/**
*
@@ -62,17 +49,18 @@
VerticalPanel contentPanel;
@UiField
- Label header, navOptionHeader;
+ Label header, navOptionHeader, filterHeader;
@UiField
CheckBox enterChk, escChk, editorButtonsChk;
+
+ @UiField
+ CheckBox translatedChk, needReviewChk, untranslatedChk;
@UiField
ListBox optionsList;
- private Map<String, Boolean> configMap = new HashMap<String, Boolean>();
-
- public EditorOptionsPanel(final EventBus eventBus)
+ public EditorOptionsPanel()
{
initWidget(uiBinder.createAndBindUi(this));
@@ -86,73 +74,16 @@ public EditorOptionsPanel(final EventBus eventBus)
escChk.setValue(false);
editorButtonsChk.setValue(true);
+ translatedChk.setText(EditorConfigConstants.LABEL_TRANSLATED);
+ needReviewChk.setText(EditorConfigConstants.LABEL_NEED_REVIEW);
+ untranslatedChk.setText(EditorConfigConstants.LABEL_UNTRANSLATED);
+ filterHeader.setText(EditorConfigConstants.LABEL_FILTERS);
+
optionsList.addItem(EditorConfigConstants.OPTION_FUZZY_UNTRANSLATED);
optionsList.addItem(EditorConfigConstants.OPTION_FUZZY);
optionsList.addItem(EditorConfigConstants.OPTION_UNTRANSLATED);
optionsList.setSelectedIndex(0);
-
- configMap.put(EditorConfigConstants.BUTTON_ENTER, false);
- configMap.put(EditorConfigConstants.BUTTON_ESC, false);
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
-
- enterChk.addValueChangeHandler(new ValueChangeHandler<Boolean>()
- {
- @Override
- public void onValueChange(ValueChangeEvent<Boolean> event)
- {
- Log.info("Enable 'Enter' Key to save and move to next string: " + event.getValue());
- configMap.put(EditorConfigConstants.BUTTON_ENTER, event.getValue());
- eventBus.fireEvent(new UserConfigChangeEvent(configMap));
- }
- });
-
- editorButtonsChk.addValueChangeHandler(new ValueChangeHandler<Boolean>()
- {
- @Override
- public void onValueChange(ValueChangeEvent<Boolean> event)
- {
- Log.info("Show editor buttons: " + event.getValue());
- eventBus.fireEvent(new ButtonDisplayChangeEvent(event.getValue()));
- }
- });
-
- escChk.addValueChangeHandler(new ValueChangeHandler<Boolean>()
- {
- @Override
- public void onValueChange(ValueChangeEvent<Boolean> event)
- {
- Log.info("Enable 'Esc' Key to close editor: " + event.getValue());
- configMap.put(EditorConfigConstants.BUTTON_ESC, event.getValue());
- eventBus.fireEvent(new UserConfigChangeEvent(configMap));
- }
- });
-
- optionsList.addChangeHandler(new ChangeHandler()
- {
- @Override
- public void onChange(ChangeEvent event)
- {
- String selectedOption = optionsList.getItemText(optionsList.getSelectedIndex());
- if (selectedOption.equals(EditorConfigConstants.OPTION_FUZZY_UNTRANSLATED))
- {
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
- }
- else if (selectedOption.equals(EditorConfigConstants.OPTION_FUZZY))
- {
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, false);
- }
- else if (selectedOption.equals(EditorConfigConstants.OPTION_UNTRANSLATED))
- {
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, false);
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
- }
- eventBus.fireEvent(new UserConfigChangeEvent(configMap));
- }
- });
}
@Override
@@ -160,6 +91,47 @@ public Widget asWidget()
{
return this;
}
+
+ public CheckBox getTranslatedChk()
+ {
+ return translatedChk;
+ }
+
+ public CheckBox getNeedReviewChk()
+ {
+ return needReviewChk;
+ }
+
+ public CheckBox getUntranslatedChk()
+ {
+ return untranslatedChk;
+ }
+
+ public CheckBox getEditorButtonsChk()
+ {
+ return editorButtonsChk;
+ }
+
+ public CheckBox getEnterChk()
+ {
+ return enterChk;
+ }
+
+ public CheckBox getEscChk()
+ {
+ return escChk;
+ }
+
+ public ListBox getOptionsList()
+ {
+ return optionsList;
+ }
+
+ public void setNavOptionVisible(boolean visible)
+ {
+ navOptionHeader.setVisible(visible);
+ optionsList.setVisible(visible);
+ }
}
View
31 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/EditorOptionsPanel.ui.xml
@@ -18,9 +18,25 @@
.subheader{
padding-top:10px;
+ padding-left:5px;
font-weight:bold;
}
+ .translated {
+ border-left:3px solid #099B09;
+ margin-left:5px;
+ }
+
+ .needReview {
+ border-left:3px solid #ffc000;
+ margin-left:5px;
+ }
+
+ .untranslated {
+ border-left:3px solid #e5e5e5;
+ margin-left:5px;
+ }
+
</ui:style>
<g:ScrollPanel>
@@ -31,8 +47,21 @@
<g:CheckBox ui:field="enterChk"/>
<g:CheckBox ui:field="escChk"/>
+ <g:Label ui:field="filterHeader" styleName="{style.subheader}"/>
+ <g:cell>
+ <g:CheckBox ui:field="translatedChk" styleName="{style.translated}"/>
+ </g:cell>
+
+ <g:cell>
+ <g:CheckBox ui:field="needReviewChk" styleName="{style.needReview}"/>
+ </g:cell>
+
+ <g:cell>
+ <g:CheckBox ui:field="untranslatedChk" styleName="{style.untranslated}"/>
+ </g:cell>
+
<g:Label ui:field="navOptionHeader" styleName="{style.subheader}"/>
- <g:cell horizontalAlignment="ALIGN_CENTER">
+ <g:cell>
<g:ListBox ui:field="optionsList"/>
</g:cell>
</g:VerticalPanel>
View
107 ...r/zanata-war/src/main/java/org/zanata/webtrans/client/ui/FilterViewConfirmationPanel.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.zanata.webtrans.client.ui;
+
+import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.DecoratedPopupPanel;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+/**
+ *
+ * @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
+ *
+ **/
+public class FilterViewConfirmationPanel extends DecoratedPopupPanel
+{
+ private Button saveChanges = new Button("Save Changes");
+ private Button discardChanges = new Button("Discard Changes");
+ private Button cancelFilter = new Button("Cancel filter");
+
+ private boolean filterTranslated, filterNeedReview, filterUntranslated;
+
+ public FilterViewConfirmationPanel()
+ {
+ super(false, true);
+ VerticalPanel vp = new VerticalPanel();
+ vp.setSpacing(10);
+ vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+
+ Label message = new Label("Save changes before filtering view?");
+ HorizontalPanel buttonPanel = new HorizontalPanel();
+ buttonPanel.setSpacing(5);
+ buttonPanel.setSize("100%", "100%");
+ buttonPanel.add(saveChanges);
+ buttonPanel.add(discardChanges);
+ buttonPanel.add(cancelFilter);
+ setStyleName("filterConfirmationPanel");
+
+ vp.add(message);
+ vp.add(buttonPanel);
+ add(vp);
+
+ hide();
+ }
+
+ public HasClickHandlers getSaveChangesAndFilterButton()
+ {
+ return saveChanges;
+ }
+
+ public HasClickHandlers getDiscardChangesAndFilterButton()
+ {
+ return discardChanges;
+ }
+
+ public HasClickHandlers getCancelFilterButton()
+ {
+ return cancelFilter;
+ }
+
+ public void updateFilter(boolean filterTranslated, boolean filterNeedReview, boolean filterUntranslated)
+ {
+ this.filterTranslated = filterTranslated;
+ this.filterNeedReview = filterNeedReview;
+ this.filterUntranslated = filterUntranslated;
+ }
+
+ public boolean isFilterTranslated()
+ {
+ return filterTranslated;
+ }
+
+ public boolean isFilterNeedReview()
+ {
+ return filterNeedReview;
+ }
+
+ public boolean isFilterUntranslated()
+ {
+ return filterUntranslated;
+ }
+
+}
+
+
+
View
7 server/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransUnitNavigationView.java
@@ -158,4 +158,11 @@ public Widget asWidget()
{
return this;
}
+
+ @Override
+ public void setModelNavVisible(boolean visible)
+ {
+ prevState.setVisible(visible);
+ nextState.setVisible(visible);
+ }
}
View
118 server/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/GetTransUnitListHandler.java
@@ -23,7 +23,6 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
@@ -43,11 +42,13 @@
import org.zanata.security.ZanataIdentity;
import org.zanata.service.LocaleService;
import org.zanata.webtrans.server.ActionHandlerFor;
+import org.zanata.webtrans.shared.model.DocumentId;
import org.zanata.webtrans.shared.model.TransUnit;
import org.zanata.webtrans.shared.model.TransUnitId;
import org.zanata.webtrans.shared.rpc.GetTransUnitList;
import org.zanata.webtrans.shared.rpc.GetTransUnitListResult;
-
+import org.zanata.webtrans.shared.util.TextFlowFilter;
+import org.zanata.webtrans.shared.util.TextFlowFilterImpl;
@Name("webtrans.gwt.GetTransUnitListHandler")
@Scope(ScopeType.STATELESS)
@@ -69,7 +70,6 @@
@Override
public GetTransUnitListResult execute(GetTransUnitList action, ExecutionContext context) throws ActionException
{
-
ZanataIdentity.instance().checkLoggedIn();
log.info("Fetching Transunits for document {0}", action.getDocumentId());
@@ -83,72 +83,84 @@ public GetTransUnitListResult execute(GetTransUnitList action, ExecutionContext
throw new ActionException(e.getMessage());
}
- int size = 0;
- List<HTextFlow> textFlows = new ArrayList<HTextFlow>();
- if (action.getPhrase() != null && !action.getPhrase().isEmpty())
- {
- log.info("find message:" + action.getPhrase());
- Set<Object[]> idSet = textFlowDAO.getIdsBySearch(action.getDocumentId().getValue(), action.getOffset(), action.getCount(), action.getPhrase(), action.getWorkspaceId().getLocaleId());
- size = idSet.size();
- log.info("size : {0}", size);
- log.info("action.getOffset() : {0}", action.getOffset());
- log.info("action.getCount() : {0}", action.getCount());
-
- List<Object[]> subIds = new ArrayList<Object[]>();
- if ((action.getOffset() + action.getCount()) < size)
- {
- subIds = new ArrayList<Object[]>(idSet).subList(action.getOffset(), action.getOffset() + action.getCount());
- }
- else if (action.getOffset() < size)
- {
- subIds = new ArrayList<Object[]>(idSet).subList(action.getOffset(), size);
- }
- List<Long> idList = new ArrayList<Long>();
- for (Object[] para : subIds)
- {
- idList.add((Long) para[0]);
- }
+ int gotoRow = -1, size = 0;
- textFlows = textFlowDAO.findByIdList(idList);
+ List<HTextFlow> result;
+ TextFlowFilter filter;
+
+ if ((action.getPhrase() != null && !action.getPhrase().isEmpty()) || (action.isFilterTranslated() || action.isFilterNeedReview() || action.isFilterUntranslated()))
+ {
+ log.info("Fetch TransUnits:" + action.getPhrase());
+ filter = new TextFlowFilterImpl(action.getPhrase(), action.isFilterTranslated(), action.isFilterNeedReview(), action.isFilterUntranslated());
+ result = textFlowDAO.getTransUnitList(action.getDocumentId().getValue());
}
else
{
- size = textFlowDAO.getByDocument(action.getDocumentId().getValue()).size();
- textFlows = textFlowDAO.getOffsetListByDocument(action.getDocumentId().getValue(), action.getOffset(), action.getCount());
+ log.info("Fetch TransUnits:*");
+ filter = new TextFlowFilterImpl();
+ result = textFlowDAO.getTransUnitList(action.getDocumentId().getValue());
+ // result =
+ // textFlowDAO.getTransUnitList(action.getDocumentId().getValue(),
+ // action.getOffset(), action.getCount());
+ // size =
+ // textFlowDAO.getCountByDocument(action.getDocumentId().getValue());
}
- ArrayList<TransUnit> units = new ArrayList<TransUnit>();
- for (HTextFlow textFlow : textFlows)
+ List<TransUnit> units = new ArrayList<TransUnit>();
+ for (HTextFlow textFlow : result)
{
-
- TransUnitId tuId = new TransUnitId(textFlow.getId());
-
- String msgContext = null;
- if (textFlow.getPotEntryData() != null)
+ if (!filter.isFilterOut(textFlow, hLocale))
{
- msgContext = textFlow.getPotEntryData().getContext();
- }
-
- TransUnit tu = new TransUnit(tuId, textFlow.getResId(), action.getWorkspaceId().getLocaleId(), textFlow.getContent(), CommentsUtil.toString(textFlow.getComment()), "", ContentState.New, "", "", msgContext, textFlow.getPos());
- HTextFlowTarget target = textFlow.getTargets().get(hLocale);
- if (target != null)
- {
- tu.setTarget(target.getContent());
- tu.setStatus(target.getState());
- if (target.getLastModifiedBy() != null)
+ TransUnit tu = initTransUnit(textFlow, hLocale);
+ units.add(tu);
+ if (action.getTargetTransUnitId() != null && tu.getId().equals(action.getTargetTransUnitId()))
{
- tu.setLastModifiedBy(target.getLastModifiedBy().getName());
+ gotoRow = units.size();
}
- tu.setLastModifiedTime(SIMPLE_FORMAT.format(target.getLastChanged()));
}
- units.add(tu);
}
- return new GetTransUnitListResult(action.getDocumentId(), units, size);
- }
+ size = units.size();
+ if ((action.getOffset() + action.getCount()) < units.size())
+ {
+ units.subList(action.getOffset() + action.getCount() + 1, units.size()).clear();
+
+ int toIndex = (action.getOffset() - 1) >= 0 ? action.getOffset() - 1 : 0;
+ units.subList(0, toIndex).clear();
+ }
+ else if (action.getOffset() < units.size())
+ {
+ int toIndex = (action.getOffset() - 1) >= 0 ? action.getOffset() - 1 : 0;
+ units.subList(0, toIndex).clear();
+ }
+
+ return new GetTransUnitListResult(action.getDocumentId(), units, size, gotoRow);
+ }
@Override
public void rollback(GetTransUnitList action, GetTransUnitListResult result, ExecutionContext context) throws ActionException
{
}
+ private TransUnit initTransUnit(HTextFlow textFlow, HLocale hLocale)
+ {
+ String msgContext = null;
+ if (textFlow.getPotEntryData() != null)
+ {
+ msgContext = textFlow.getPotEntryData().getContext();
+ }
+ HTextFlowTarget target = textFlow.getTargets().get(hLocale);
+ TransUnit tu = new TransUnit(new TransUnitId(textFlow.getId()), textFlow.getResId(), hLocale.getLocaleId(), textFlow.getContent(), CommentsUtil.toString(textFlow.getComment()), "", ContentState.New, "", "", msgContext, textFlow.getPos());
+ if (target != null)
+ {
+ tu.setTarget(target.getContent());
+ tu.setStatus(target.getState());
+ if (target.getLastModifiedBy() != null)
+ {
+ tu.setLastModifiedBy(target.getLastModifiedBy().getName());
+ }
+ tu.setLastModifiedTime(SIMPLE_FORMAT.format(target.getLastChanged()));
+ }
+ return tu;
+ }
+
}
View
4 server/zanata-war/src/main/java/org/zanata/webtrans/server/rpc/UpdateTransUnitHandler.java
@@ -199,7 +199,7 @@ else if (action.getContentState() != ContentState.New && StringUtils.isEmpty(act
authenticatedAccount.getPerson().getName(),
SIMPLE_FORMAT.format(new Date()), msgContext, hTextFlow.getPos());
// @formatter:on
- TransUnitUpdated event = new TransUnitUpdated(new DocumentId(hTextFlow.getDocument().getId()), wordCount, prevStatus, tu);
+ TransUnitUpdated event = new TransUnitUpdated(new DocumentId(hTextFlow.getDocument().getId()), wordCount, prevStatus, tu, ZanataIdentity.instance().getCredentials().getUsername());
TranslationWorkspace workspace = translationWorkspaceManager.getOrRegisterWorkspace(action.getWorkspaceId());
workspace.publish(event);
@@ -275,7 +275,7 @@ public void rollback(UpdateTransUnit action, UpdateTransUnitResult result, Execu
target.getLastModifiedBy().getName(),
SIMPLE_FORMAT.format(target.getLastChanged()), msgContext, hTextFlow.getPos());
// @formatter:on
- TransUnitUpdated event = new TransUnitUpdated(new DocumentId(hTextFlow.getDocument().getId()), wordCount, prevStatus, tu);
+ TransUnitUpdated event = new TransUnitUpdated(new DocumentId(hTextFlow.getDocument().getId()), wordCount, prevStatus, tu, ZanataIdentity.instance().getCredentials().getUsername());
TranslationWorkspace workspace = translationWorkspaceManager.getOrRegisterWorkspace(action.getWorkspaceId());
workspace.publish(event);
View
50 server/zanata-war/src/main/java/org/zanata/webtrans/shared/model/TransUnit.java
@@ -26,26 +26,6 @@
private String lastModifiedTime;
private int rowIndex;
- public String getLastModifiedBy()
- {
- return lastModifiedBy;
- }
-
- public void setLastModifiedBy(String lastModifiedBy)
- {
- this.lastModifiedBy = lastModifiedBy;
- }
-
- public String getLastModifiedTime()
- {
- return lastModifiedTime;
- }
-
- public void setLastModifiedTime(String lastModifiedTime)
- {
- this.lastModifiedTime = lastModifiedTime;
- }
-
// for GWT
@SuppressWarnings("unused")
private TransUnit()
@@ -66,16 +46,6 @@ public TransUnit(TransUnitId id, String resId, LocaleId localeId, String source,
this.msgContext = msgContext;
this.rowIndex = rowIndex;
}
-
- public TransUnit(TransUnit other)
- {
- this(other.id, other.resId, other.localeId, other.source, other.sourceComment, other.target, other.status, other.lastModifiedBy, other.lastModifiedTime, other.msgContext, other.rowIndex);
- }
-
- public static final TransUnit copy(TransUnit other)
- {
- return new TransUnit(other);
- }
public TransUnitId getId()
{
@@ -152,4 +122,24 @@ public void setRowIndex(int rowIndex)
this.rowIndex = rowIndex;
}
+ public String getLastModifiedBy()
+ {
+ return lastModifiedBy;
+ }
+
+ public void setLastModifiedBy(String lastModifiedBy)
+ {
+ this.lastModifiedBy = lastModifiedBy;
+ }
+
+ public String getLastModifiedTime()
+ {
+ return lastModifiedTime;
+ }
+
+ public void setLastModifiedTime(String lastModifiedTime)
+ {
+ this.lastModifiedTime = lastModifiedTime;
+ }
+
}
View
31 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitList.java
@@ -1,27 +1,34 @@
package org.zanata.webtrans.shared.rpc;
import org.zanata.webtrans.shared.model.DocumentId;
+import org.zanata.webtrans.shared.model.TransUnitId;
public class GetTransUnitList extends AbstractWorkspaceAction<GetTransUnitListResult>
{
-
private static final long serialVersionUID = 1L;
private int offset;
private int count;
private DocumentId documentId;
private String phrase;
+ private boolean filterTranslated, filterNeedReview, filterUntranslated;
+ private TransUnitId targetTransUnitId;
@SuppressWarnings("unused")
private GetTransUnitList()
{
}
- public GetTransUnitList(DocumentId id, int offset, int count, String phrase)
+ public GetTransUnitList(DocumentId id, int offset, int count, String phrase, boolean filterTranslated, boolean filterNeedReview, boolean filterUntranslated, TransUnitId targetTransUnitId)
{
this.documentId = id;
this.offset = offset;
this.count = count;
this.phrase = phrase;
+ this.filterTranslated = filterTranslated;
+ this.filterNeedReview = filterNeedReview;
+ this.filterUntranslated = filterUntranslated;
+ this.targetTransUnitId = targetTransUnitId;
+
}
public int getOffset()
@@ -44,4 +51,24 @@ public String getPhrase()
return this.phrase;
}
+ public boolean isFilterTranslated()
+ {
+ return filterTranslated;
+ }
+
+ public boolean isFilterNeedReview()
+ {
+ return filterNeedReview;
+ }
+
+ public boolean isFilterUntranslated()
+ {
+ return filterUntranslated;
+ }
+
+ public TransUnitId getTargetTransUnitId()
+ {
+ return targetTransUnitId;
+ }
+
}
View
15 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/GetTransUnitListResult.java
@@ -1,6 +1,6 @@
package org.zanata.webtrans.shared.rpc;
-import java.util.ArrayList;
+import java.util.List;
import net.customware.gwt.dispatch.shared.Result;
@@ -10,26 +10,27 @@
public class GetTransUnitListResult implements Result
{
-
private static final long serialVersionUID = 1L;
private DocumentId documentId;
private int totalCount;
- private ArrayList<TransUnit> units;
+ private List<TransUnit> units;
+ private int gotoRow;
@SuppressWarnings("unused")
private GetTransUnitListResult()
{
}
- public GetTransUnitListResult(DocumentId documentId, ArrayList<TransUnit> units, int totalCount)
+ public GetTransUnitListResult(DocumentId documentId, List<TransUnit> units, int totalCount, int gotoRow)
{
this.documentId = documentId;
this.units = units;
this.totalCount = totalCount;
+ this.gotoRow = gotoRow;
}
- public ArrayList<TransUnit> getUnits()
+ public List<TransUnit> getUnits()
{
return units;
}
@@ -44,4 +45,8 @@ public DocumentId getDocumentId()
return documentId;
}
+ public int getGotoRow()
+ {
+ return gotoRow;
+ }
}
View
2  server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/HasTransUnitUpdatedData.java
@@ -16,5 +16,7 @@
int getWordCount();
TransUnit getTransUnit();
+
+ String getUsername();
}
View
9 server/zanata-war/src/main/java/org/zanata/webtrans/shared/rpc/TransUnitUpdated.java
@@ -36,6 +36,7 @@
private int wordCount;
private ContentState previousStatus;
private TransUnit tu;
+ private String username;
// for ExposeEntity
@@ -43,12 +44,13 @@ public TransUnitUpdated()
{
}
- public TransUnitUpdated(DocumentId documentId, int wordCount, ContentState previousStatus, TransUnit tu)
+ public TransUnitUpdated(DocumentId documentId, int wordCount, ContentState previousStatus, TransUnit tu, String username)
{
this.documentId = documentId;
this.wordCount = wordCount;
this.previousStatus = previousStatus;
this.tu = tu;
+ this.username = username;
}
@Override
@@ -86,4 +88,9 @@ public TransUnit getTransUnit()
return tu;
}
+ @Override
+ public String getUsername()
+ {
+ return username;
+ }
}
View
37 server/zanata-war/src/main/java/org/zanata/webtrans/shared/util/TextFlowFilter.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.zanata.webtrans.shared.util;
+
+import org.zanata.model.HLocale;
+import org.zanata.model.HTextFlow;
+
+/**
+ *
+ * @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
+ *
+ **/
+public interface TextFlowFilter
+{
+ boolean isFilterOut(HTextFlow textFlow, HLocale locale);
+}
+
+
+
View
120 server/zanata-war/src/main/java/org/zanata/webtrans/shared/util/TextFlowFilterImpl.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.zanata.webtrans.shared.util;
+
+import org.zanata.common.ContentState;
+import org.zanata.model.HLocale;
+import org.zanata.model.HTextFlow;
+import org.zanata.model.HTextFlowTarget;
+
+/**
+ *
+ * @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
+ *
+ **/
+public class TextFlowFilterImpl implements TextFlowFilter
+{
+ private boolean filterTranslated, filterNeedReview, filterUntranslated;
+ private String phrase;
+ private boolean acceptAll;
+
+ public TextFlowFilterImpl(String phrase, boolean filterTranslated, boolean filterNeedReview, boolean filterUntranslated)
+ {
+ this.filterTranslated = filterTranslated;
+ this.filterNeedReview = filterNeedReview;
+ this.filterUntranslated = filterUntranslated;
+ if (phrase != null && !phrase.isEmpty())
+ {
+ this.phrase = phrase.toLowerCase();
+ }
+ acceptAll = false;
+ }
+
+ public TextFlowFilterImpl()
+ {
+ acceptAll = true;
+ }
+
+ /**
+ * Filter out according to target state
+ *
+ * @param target
+ * @return
+ */
+ @Override
+ public boolean isFilterOut(HTextFlow textFlow, HLocale locale)
+ {
+ if (acceptAll)
+ {
+ return false;
+ }
+
+ HTextFlowTarget target = textFlow.getTargets().get(locale);
+ if (isMatchSearch(textFlow, target))
+ {
+ if ((filterTranslated == filterNeedReview) && (filterNeedReview == filterUntranslated) && (filterUntranslated == filterTranslated))
+ {
+ return false;
+ }
+
+ if (target == null)
+ {
+ if (filterUntranslated)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ ContentState state = target.getState();
+ if (state == ContentState.Approved && filterTranslated)
+ {
+ return false;
+ }
+ if (state == ContentState.NeedReview && filterNeedReview)
+ {
+ return false;
+ }
+ if (state == ContentState.New && filterUntranslated)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean isMatchSearch(HTextFlow textFlow, HTextFlowTarget target)
+ {
+ if (phrase != null && !phrase.isEmpty())
+ {
+ if (target != null)
+ {
+ return textFlow.getContent().toLowerCase().contains(phrase) || target.getContent().toLowerCase().contains(phrase);
+ }
+ else
+ {
+ return textFlow.getContent().toLowerCase().contains(phrase);
+ }
+ }
+ return true;
+ }
+}
View
8 server/zanata-war/src/main/resources/org/zanata/webtrans/public/Application.css
@@ -544,4 +544,12 @@ tr.ApprovedStateDecoration td.TableEditorCell-Target .TableEditorContent-Edit {
opacity:0.60;
border-radius:20px;
font-weight:bold;
+}
+
+.filterConfirmationPanel{
+ background:#4C4C4C;
+ padding:5px 20px 0px 20px;
+ color:#FFFFFF;
+ border-radius:20px;
+ font-weight:bold;
}
View
2  server/zanata-war/src/test/java/org/zanata/webtrans/client/rpc/DummyGetTransUnitCommand.java
@@ -37,7 +37,7 @@ public void execute()
int count = action.getCount();
int offset = action.getOffset();
int totalCount = count * 5;
- GetTransUnitListResult result = new GetTransUnitListResult(documentId, generateTransUnitSampleData(action.getWorkspaceId().getLocaleId(), count, offset), totalCount);
+ GetTransUnitListResult result = new GetTransUnitListResult(documentId, generateTransUnitSampleData(action.getWorkspaceId().getLocaleId(), count, offset), totalCount, -1);
callback.onSuccess(result);
Log.info("EXIT DummyGetTransUnitCommand.execute()");
}
Please sign in to comment.
Something went wrong with that request. Please try again.