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

Commit

Permalink
rhbz882770 - add new search field to history token
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Apr 13, 2014
1 parent 0e14dc3 commit 810e9ab
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import com.google.common.base.Strings;

enum EditorTokens implements TokensConverter {
INSTANCE;

Expand All @@ -15,6 +17,13 @@ enum EditorTokens implements TokensConverter {
static final String KEY_MESSAGE_FILTER_REJECTED = "rejected";
static final String KEY_MESSAGE_FILTER_ERROR = "error";
static final String VALUE_MESSAGE_FILTER = "show";
static final String KEY_RES_ID = "resid";
static final String KEY_MSG_CONTEXT = "msgcontext";
static final String KEY_SOURCE_COMMENT = "sourcecomment";
static final String KEY_TARGET_COMMENT = "targetcomment";
static final String KEY_LAST_MODIFIED_BY = "lastmodifiedby";
static final String KEY_CHANGED_BEFORE = "changedbefore";
static final String KEY_CHANGED_AFTER = "changedafter";

@Override
public void populateHistoryToken(HistoryToken historyToken, Token token) {
Expand Down Expand Up @@ -45,6 +54,27 @@ public void populateHistoryToken(HistoryToken historyToken, Token token) {
if (key.equals(KEY_MESSAGE_FILTER_ERROR)) {
historyToken.setFilterHasError(true);
}
if (key.equals(KEY_RES_ID)) {
historyToken.setResId(value);
}
if (key.equals(KEY_CHANGED_AFTER)) {
historyToken.setChangedAfter(value);
}
if (key.equals(KEY_CHANGED_BEFORE)) {
historyToken.setChangedBefore(value);
}
if (key.equals(KEY_MSG_CONTEXT)) {
historyToken.setMsgContext(value);
}
if (key.equals(KEY_SOURCE_COMMENT)) {
historyToken.setSourceComment(value);
}
if (key.equals(KEY_TARGET_COMMENT)) {
historyToken.setTargetComment(value);
}
if (key.equals(KEY_LAST_MODIFIED_BY)) {
historyToken.setLastModifiedBy(value);
}
}

@Override
Expand Down Expand Up @@ -96,5 +126,20 @@ public void toTokenString(HistoryToken historyToken, List<Token> tokens) {
VALUE_MESSAGE_FILTER));
}
}
setIfExists(tokens, KEY_RES_ID, historyToken.getResId());
setIfExists(tokens, KEY_MSG_CONTEXT, historyToken.getMsgContext());
setIfExists(tokens, KEY_SOURCE_COMMENT, historyToken.getSourceComment());
setIfExists(tokens, KEY_TARGET_COMMENT, historyToken.getTargetComment());
setIfExists(tokens, KEY_LAST_MODIFIED_BY,
historyToken.getLastModifiedBy());
setIfExists(tokens, KEY_CHANGED_AFTER, historyToken.getChangedAfter());
setIfExists(tokens, KEY_CHANGED_BEFORE, historyToken.getChangedBefore());
}

private static void
setIfExists(List<Token> tokens, String key, String value) {
if (!Strings.isNullOrEmpty(value)) {
tokens.add(new Token(key, value));
}
}
}
Expand Up @@ -349,7 +349,7 @@ public void clearEditorFilterAndSearch() {
filterUntranslated = false;
filterApproved = false;
filterRejected = false;
searchText = null;
searchText = DEFAULT_SEARCH_TEXT;
resId = null;
changedBefore = null;
changedAfter = null;
Expand Down

0 comments on commit 810e9ab

Please sign in to comment.