Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:zanata/zanata
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Munoz committed Dec 12, 2011
2 parents 0ad8a18 + b8a1540 commit 68db78e
Show file tree
Hide file tree
Showing 14 changed files with 437 additions and 161 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,21 @@
# Zanata change log summary

## zanata-1.5
* Allow bookmarking of selected document, document list filter and current view: https://bugzilla.redhat.com/show_bug.cgi?id=757621
* Add workspace query string parameters for generating a custom doclist with a custom title: https://bugzilla.redhat.com/show_bug.cgi?id=758587
* e.g. &title=Custom%20title&doc=full/path/of/first/doc&doc=full/path/of/second/doc

## zanata-1.4.3
* Show message context in editor info panel: https://bugzilla.redhat.com/show_bug.cgi?id=750690
* Update gwteventservice to 1.2.0-RC1
* Modify email templates to include server URL
* Fix problems with editor table when searching or switching pages: https://bugzilla.redhat.com/show_bug.cgi?id=751264
* Add failsafe editor in case of Seam Text problems: https://bugzilla.redhat.com/show_bug.cgi?id=727716
* Change string similarity algorithm so that only identical strings (not substrings) can get 100%: https://bugzilla.redhat.com/show_bug.cgi?id=730189
* Bugfix: 'J' and 'K' navigation keys trigger when entering text in the TM search box: https://bugzilla.redhat.com/show_bug.cgi?id=754637
* Bugfix: Not able to work in parallel on the same workbench: https://bugzilla.redhat.com/show_bug.cgi?id=756293
* Show progress during re-index operations; avoid timeout for large databases: https://bugzilla.redhat.com/show_bug.cgi?id=747836

## zanata-1.4.2
* Language team coordinator: https://bugzilla.redhat.com/show_bug.cgi?id=742083
* Users now have to ask before joining a language team
Expand Down
Expand Up @@ -147,6 +147,8 @@ private void reindex(Class<?> clazz)
session.clear(); // clear since the queue is processed
}
}
session.flushToIndexes(); // apply changes to indexes
session.clear(); // clear since the queue is processed
}
catch (Exception e)
{
Expand Down
Expand Up @@ -270,8 +270,10 @@ protected void onBind()
@Override
public void onSelection(SelectionEvent<TransUnit> event)
{
TransUnit newSelectedItem = event.getSelectedItem();
selectTransUnit(newSelectedItem);
if (event.getSelectedItem() != null)
{
selectTransUnit(event.getSelectedItem());
}
}
}));

Expand Down Expand Up @@ -604,7 +606,7 @@ public void updatePageAndRowIndex()
public void updateRowIndex(int curPage)
{
curRowIndex = curPage * TableConstants.PAGE_SIZE + display.getSelectedRowNumber();
Log.info("Current Row Index" + curRowIndex);
Log.info("Current Row Index: " + curRowIndex);
}

@Override
Expand Down Expand Up @@ -736,6 +738,7 @@ public void gotoRow(int rowIndex, boolean andEdit)
display.gotoPage(pageNum, false);
}


selectTransUnit(display.getTransUnitValue(rowNum));
display.gotoRow(rowNum, andEdit);
}
Expand Down Expand Up @@ -1019,6 +1022,7 @@ public DocumentId getDocumentId()
public void selectTransUnit(TransUnit transUnit)
{
tableModelHandler.updateRowIndex(display.getCurrentPage());

if (selectedTransUnit == null || !transUnit.getId().equals(selectedTransUnit.getId()))
{
selectedTransUnit = transUnit;
Expand Down
@@ -1,10 +1,8 @@
package org.zanata.webtrans.client.history;

import java.util.HashMap;
import java.util.Map;

import org.zanata.webtrans.client.presenter.AppPresenter;
import org.zanata.webtrans.shared.model.DocumentId;

import com.allen_sauer.gwt.log.client.Log;

/**
* Encapsulates a string token of key-value pairs for GWT history operations.
Expand All @@ -14,24 +12,40 @@
*/
public class HistoryToken
{
private static final String KEY_VALUE_SEPARATOR = ":";
private static final String DELIMITER_K_V = ":";
private static final String PAIR_SEPARATOR = ";";

public static final String KEY_VIEW = "view";
public static final String KEY_DOCUMENT = "doc";

public static final String VALUE_DOCLIST_VIEW = "list";
public static final String KEY_VIEW = "view";
// public static final String VALUE_DOCLIST_VIEW = "list";
public static final String VALUE_EDITOR_VIEW = "doc";

private Map<String, String> members;
public static final String KEY_DOC_FILTER_TEXT = "filter";

public static final String KEY_DOC_FILTER_OPTION = "filtertype";
public static final String VALUE_DOC_FILTER_EXACT = "exact";
// public static final String VALUE_DOC_FILTER_INEXACT = "substr";

private AppPresenter.Display.MainView view;
private String fullDocPath;
private boolean docFilterExact;
private String docFilterText;

// defaults
private static final AppPresenter.Display.MainView DEFAULT_VIEW = AppPresenter.Display.MainView.Documents;
private static final String DEFAULT_DOCUMENT_PATH = "";
private static final String DEFAULT_DOC_FILTER_TEXT = "";
private static final boolean DEFAULT_DOC_FILTER_EXACT = false;

public HistoryToken()
{
members = new HashMap<String, String>();
view = DEFAULT_VIEW;
fullDocPath = DEFAULT_DOCUMENT_PATH;
docFilterText = DEFAULT_DOC_FILTER_TEXT;
docFilterExact = DEFAULT_DOC_FILTER_EXACT;
}


/**
* Generate a history token from the given token string
*
Expand All @@ -41,96 +55,104 @@ public static HistoryToken fromTokenString(String token)
{
HistoryToken historyToken = new HistoryToken();

String[] pair;
if (token == null || token.length() == 0)
{
return historyToken;
}

if (!token.isEmpty() && token != null)
for (String pairString : token.split(PAIR_SEPARATOR))
{
String[] pair = pairString.split(DELIMITER_K_V);
String key;
String value;
try
{
for (String pairString : token.split(PAIR_SEPARATOR))
key = pair[0];
value = pair[1];
}
catch (ArrayIndexOutOfBoundsException e)
{
continue;
}

if (key == HistoryToken.KEY_DOCUMENT)
{
historyToken.setDocumentPath(value);
}
else if (key == HistoryToken.KEY_VIEW)
{
if (value.equals(VALUE_EDITOR_VIEW))
{
pair = pairString.split(KEY_VALUE_SEPARATOR);
historyToken.members.put(pair[0], pair[1]);
historyToken.setView(AppPresenter.Display.MainView.Editor);
}
// else default will be used
}
else if (key == HistoryToken.KEY_DOC_FILTER_OPTION)
{
if (value == VALUE_DOC_FILTER_EXACT)
historyToken.setDocFilterExact(true);
// else default used
}
catch (IllegalArgumentException e)
else if (key == HistoryToken.KEY_DOC_FILTER_TEXT)
{
throw new IllegalArgumentException("token must be a list of key-value pairs in the form key1:value1,key2:value2,...", e);
historyToken.setDocFilterText(value);
}

else
Log.info("unrecognised history key: " + key);

}

return historyToken;
}

public boolean hasDocumentId()
public String getDocumentPath()
{
return members.containsKey(HistoryToken.KEY_DOCUMENT);
return fullDocPath;
}

public DocumentId getDocumentId()
public void setDocumentPath(String fullDocPath)
{
try
{
return new DocumentId(Long.parseLong(members.get(HistoryToken.KEY_DOCUMENT)));
}
catch (NullPointerException e)
{
return null;
}
catch (NumberFormatException e)
{
return null;
}
if (fullDocPath == null)
this.fullDocPath = DEFAULT_DOCUMENT_PATH;
else
this.fullDocPath = fullDocPath;
}

public void setDocumentId(DocumentId docId)
public AppPresenter.Display.MainView getView()
{
members.put(HistoryToken.KEY_DOCUMENT, docId.toString());
return view;
}

public boolean hasView()
public void setView(AppPresenter.Display.MainView view)
{
return members.containsKey(HistoryToken.KEY_VIEW);
if (view == null)
this.view = DEFAULT_VIEW;
else
this.view = view;
}

public AppPresenter.Display.MainView getView()
public Boolean getDocFilterExact()
{
try
{
String view = members.get(KEY_VIEW);
if (view.equals(VALUE_EDITOR_VIEW))
{
return AppPresenter.Display.MainView.Editor;
}
else if (view.equals(VALUE_DOCLIST_VIEW))
{
return AppPresenter.Display.MainView.Documents;
}
else
{ // invalid view
return null;
}
}
catch (ClassCastException e)
{
return null;
}
catch (NullPointerException e)
{
return null;
}
return docFilterExact;
}

public void setView(AppPresenter.Display.MainView view)
public void setDocFilterExact(boolean exactMatch)
{
if (view == AppPresenter.Display.MainView.Editor)
{
members.put(HistoryToken.KEY_VIEW, VALUE_EDITOR_VIEW);
}
else if (view == AppPresenter.Display.MainView.Documents)
{
members.put(HistoryToken.KEY_VIEW, VALUE_DOCLIST_VIEW);
}
docFilterExact = exactMatch;
}

public String getDocFilterText()
{
return docFilterText;
}

public void setDocFilterText(String value)
{
if (value == null || value.length() == 0)
this.docFilterText = DEFAULT_DOC_FILTER_TEXT;
else
this.docFilterText = value;
}

/**
Expand All @@ -141,18 +163,45 @@ public String toTokenString()
{
String token = "";
boolean first = true;
for (Map.Entry<String, String> pair : members.entrySet())

if (view != DEFAULT_VIEW)
{
if (pair.getKey() != null && pair.getKey() != "" && pair.getValue() != null && pair.getValue() != "")
{
if (first)
first = false;
else
token += PAIR_SEPARATOR;
token += pair.getKey() + KEY_VALUE_SEPARATOR + pair.getValue();
}
if (first)
first = false;
else
token += PAIR_SEPARATOR;
// editor is the only non-default view
token += KEY_VIEW + DELIMITER_K_V + VALUE_EDITOR_VIEW;
}

if (!fullDocPath.equals(DEFAULT_DOCUMENT_PATH))
{
if (first)
first = false;
else
token += PAIR_SEPARATOR;
token += KEY_DOCUMENT + DELIMITER_K_V + fullDocPath;
}

if (docFilterExact != DEFAULT_DOC_FILTER_EXACT)
{
if (first)
first = false;
else
token += PAIR_SEPARATOR;
// exact is the only non-default filter value
token += KEY_DOC_FILTER_OPTION + DELIMITER_K_V + VALUE_DOC_FILTER_EXACT;
}

if (!docFilterText.equals(DEFAULT_DOC_FILTER_TEXT))
{
if (first)
first = false;
else
token += PAIR_SEPARATOR;
token += KEY_DOC_FILTER_TEXT + DELIMITER_K_V + docFilterText;
}

return token;
}

}

0 comments on commit 68db78e

Please sign in to comment.